nrfcxx
0.1.0
C++-17 Framework for Nordic nRF5 Devices
|
Go to the documentation of this file. 8 #ifndef NRFCXX_MISC_LIPOMON_HPP 9 #define NRFCXX_MISC_LIPOMON_HPP 70 using flags_type = uint8_t;
73 enum flags_enum : flags_type
77 FL_PWRSRCCAP_Pos = 0U,
78 FL_PWRSRCCAP_Msk = 0x03 << FL_PWRSRCCAP_Pos,
82 FL_PWRSRCPRC_Pos = 2U,
83 FL_PWRSRCPRC_Msk = 0x03 << FL_PWRSRCPRC_Pos,
95 FL_SAMPLE_CORRUPTED = 0x40,
184 return vchg_detect_.
read();
190 return vchg_detect_.
read() && !chgn_state_.
read();
225 int lpsm_process_ (
int& delay,
226 process_flags_type& pf)
override;
233 int16_t batt_mV_ = 0;
236 flags_type
volatile flags_bi_ = 0;
239 bool volatile adc_pending_ =
false;
240 int8_t
volatile adc_calibrating_ = 0;
241 int8_t
volatile adc_sampling_ = 0;
lipo_monitor(notifier_type notify, const gpio::gpio_pin &vchg_detect, const gpio::gpio_pin &chgn_state, sensor::adc::voltage_divider &battmeas)
Construct an instance.
static constexpr auto PF_MAINS
Sensor-specific indication from lpm::lpsm_capable::lpsm_process() that a powered USB cable has been i...
Definition: lipomon.hpp:144
V_BUS is non-zero and TCK106 charging active.
Definition: lipomon.hpp:64
int calibrate()
Initiate a calibration of the ADC used to measure voltage.
Material supporting low-power-mode operations.
Object used to manage sense callbacks.
Definition: periph.hpp:854
Extension of generic_pin using an owned pin_reference.
Definition: gpio.hpp:507
GPIOTE::mutex_type mutex_type
Mutex used for blocked interrupts related to the listener.
Definition: periph.hpp:869
static constexpr process_flags_type PF_STARTED
lpsm_capable::lpsm_process() flag bit when the machine is ready to provide observations.
Definition: lpm.hpp:222
static constexpr auto PF_CHARGING
Sensor-specific indication from lpm::lpsm_capable::lpsm_process() that the LiPo battery is being char...
Definition: lipomon.hpp:149
bool charging_live()
Read the live charging signal.
Definition: lipomon.hpp:188
static constexpr state_type MS_SAMPLE
States available to implement a sample state.
Definition: lpm.hpp:192
bool read() const override
Return the input signal observed at the pin, or zero if the reference is invalid.
Definition: gpio.hpp:554
static constexpr auto PF_CALIBRATED
Sensor-specific indication from lpm::lpsm_capable::lpsm_process() that the battery voltage sensor has...
Definition: lipomon.hpp:159
static constexpr auto PF_LIPO
Sensor-specific indication from lpm::lpsm_capable::lpsm_process() that a powered USB cable has been r...
Definition: lipomon.hpp:136
V_BUS is zero.
Definition: lipomon.hpp:62
Specializations of nrfcxx::periph::ADC for common ADC operations.
Structure used to convey information about pin levels to sense_listener callbacks.
Definition: periph.hpp:672
No information available.
Definition: lipomon.hpp:60
static constexpr auto PF_CHARGED
Sensor-specific indication from lpm::lpsm_capable::lpsm_process() that the LiPo battery has completed...
Definition: lipomon.hpp:154
std::function< void()> notifier_type
Type used to hold a notifier.
Definition: core.hpp:514
int batt_mV() const
The most recently collected LiPo output voltage.
Definition: lipomon.hpp:205
int power_source() const
Get the latest processed power source.
static constexpr state_type MS_EXIT_SAMPLE
States available to guard exit from a sample state.
Definition: lpm.hpp:201
Base (or mixin) class for anything that supports a state_machine.
Definition: lpm.hpp:426
V_BUS is non-zero and TCK106 charging not active.
Definition: lipomon.hpp:66
bool vchg_detected_live()
Read the live USB detection signal.
Definition: lipomon.hpp:182
static constexpr state_type MS_ENTRY_SAMPLE
States available to guard entry to a sample state.
Definition: lpm.hpp:183
A state machine to monitor a LiPo battery and charger.
Definition: lipomon.hpp:49
static constexpr process_flags_type PF_APP_BASE
First lpsm_capable::lpsm_process() flag bit available for application-specific result code bits.
Definition: lpm.hpp:255
peripheral::mutex_type mutex_type
Mutex required to inhibit ADC interrupts.
Definition: periph.hpp:2178
ADC instance for voltage dividers.
Definition: adc.hpp:96
Abstraction of Nordic device peripherals.
Primary namespace for nrfcxx functionality.
Definition: clock.hpp:17
PowerSource_e
State of power source as inferred from VCHG_DETECT and BAT_CHG_STAT signals.
Definition: lipomon.hpp:57