48 #ifndef __M_BATT_MEAS_H__ 49 #define __M_BATT_MEAS_H__ 52 #include "nrf_saadc.h" 56 #define MEAS_INTERVAL_LOW_LIMIT_MS 50 uint8_t adc_pin_no
Analog in pin connected to battery (with possible voltage divider).
Definition: m_batt_meas.h:121
voltage_divider_t voltage_divider
Voltage divider type containing resistor information.
Definition: m_batt_meas.h:129
uint16_t batt_voltage_limit_low
Low voltage limit [milliVolts].
Definition: m_batt_meas.h:127
uint16_t batt_voltage_limit_full
Full voltage limit [milliVolts].
Definition: m_batt_meas.h:128
uint16_t voltage_mv
Battery voltage given in millivolts.
Definition: m_batt_meas.h:86
uint32_t m_batt_meas_enable(uint32_t meas_interval_ms)
Function for enabling battery measurement at the given interval.
Invalid parameters.
Definition: m_batt_meas.h:65
batt_meas_param_t batt_meas_param
Input parameters.
Definition: m_batt_meas.h:138
uint16_t app_timer_prescaler
App timer prescaler. See APP_TIMER_PRESCALER.
Definition: m_batt_meas.h:120
m_batt_meas_event_type_t
Battery and charge event codes.
Definition: m_batt_meas.h:70
Error state detected signalled by the charger (not implemeted, CHG and CHG finished will toggle in ca...
Definition: m_batt_meas.h:78
bool valid_voltage
True if an event is generated by a ADC conversion.
Definition: m_batt_meas.h:88
Low battery event (<= set by user).
Definition: m_batt_meas.h:73
Successfull.
Definition: m_batt_meas.h:64
BLE service handle structure.
Definition: m_ble.h:83
void(* m_batt_meas_event_handler_t)(m_batt_meas_event_t const *p_event)
m_batt sensor event handler type. Should be implemented by user e.g. in main.c()
Definition: m_batt_meas.h:93
Battery charging finished/not charging.
Definition: m_batt_meas.h:76
uint8_t level_percent
Remaining battery capacity percent.
Definition: m_batt_meas.h:87
Full battery event (>= value set by user).
Definition: m_batt_meas.h:74
uint16_t num_elements
Number of elements in the voltage to state of charge vector.
Definition: m_batt_meas.h:109
state_of_charge_t state_of_charge
Information on mapping from voltage to state of charge.
Definition: m_batt_meas.h:130
Struct for providing m_batt_meas with information on converting voltage to state of charge (Remaining...
Definition: m_batt_meas.h:107
m_batt_meas_event_type_t type
Given event type.
Definition: m_batt_meas.h:85
uint16_t first_element_mv
Voltage of the first element in the vector [mV];.
Definition: m_batt_meas.h:110
nrf_saadc_input_t adc_pin_no_ain
Same as above, but given as nrf_saadc_input_t. These two values must correspond.
Definition: m_batt_meas.h:122
Input parameters for m_batt_meas.
Definition: m_batt_meas.h:118
USB disconnected, battery not charging.
Definition: m_batt_meas.h:77
bool batt_mon_en_pin_used
Indicates if a pin is used to enable battery monitoring. (E.g. activates a voltage divider)...
Definition: m_batt_meas.h:125
Battery main og tricle charging active.
Definition: m_batt_meas.h:75
uint8_t const * voltage_to_soc
Pointer to vector mapping from voltage to state of charge.
Definition: m_batt_meas.h:112
Init parameters for m_batt_meas.
Definition: m_batt_meas.h:135
m_batt_meas_event_handler_t evt_handler
Function pointer to the event handler (executed in main context).
Definition: m_batt_meas.h:137
uint32_t m_batt_meas_init(m_ble_service_handle_t *p_handle, batt_meas_init_t const *const p_batt_meas_init)
Function for initializing the battery driver.
uint8_t delta_mv
Distance in voltage between elements in the SoC vector [mV].
Definition: m_batt_meas.h:111
Is called back at the desired frequency.
Definition: m_batt_meas.h:72
Struct for providing m_batt_meas with physical voltage divider information.
Definition: m_batt_meas.h:99
The struct passed to the handler with relevant battery information.
Definition: m_batt_meas.h:83
uint32_t m_batt_meas_disable(void)
Function for stopping the battery measurement.
uint8_t batt_mon_en_pin_no
Pin for enabling battery monitoring.
Definition: m_batt_meas.h:126
uint8_t batt_chg_stat_pin_no
Pin connected to "Charging status output pin" (CSO) of the battery charger.
Definition: m_batt_meas.h:124
uint8_t usb_detect_pin_no
Pin = high when USB is connected.
Definition: m_batt_meas.h:123