Nordic Thingy:52 v2.2.0
Battery measurement

Battery measurement module API. More...

Data Structures

struct  batt_meas_init_t
 Init parameters for m_batt_meas. More...
 
struct  batt_meas_param_t
 Input parameters for m_batt_meas. More...
 
struct  m_batt_meas_event_t
 The struct passed to the handler with relevant battery information. More...
 
struct  state_of_charge_t
 Struct for providing m_batt_meas with information on converting voltage to state of charge (Remaining battery capacity). More...
 
struct  voltage_divider_t
 Struct for providing m_batt_meas with physical voltage divider information. More...
 

Typedefs

typedef 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()
 

Enumerations

enum  { M_BATT_STATUS_CODE_SUCCESS, M_BATT_STATUS_CODE_INVALID_PARAM }
 The m_batt_meas return status codes. More...
 
enum  m_batt_meas_event_type_t {
  M_BATT_MEAS_EVENT_DATA, M_BATT_MEAS_EVENT_LOW, M_BATT_MEAS_EVENT_FULL, M_BATT_MEAS_EVENT_USB_CONN_CHARGING,
  M_BATT_MEAS_EVENT_USB_CONN_CHARGING_FINISHED, M_BATT_MEAS_EVENT_USB_DISCONN, M_BATT_MEAS_EVENT_ERROR
}
 Battery and charge event codes. More...
 

Functions

uint32_t m_batt_meas_disable (void)
 Function for stopping the battery measurement. More...
 
uint32_t m_batt_meas_enable (uint32_t meas_interval_ms)
 Function for enabling battery measurement at the given interval. More...
 
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. More...
 

Detailed Description

Battery measurement module API.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

The m_batt_meas return status codes.

Enumerator
M_BATT_STATUS_CODE_SUCCESS 

Successfull.

M_BATT_STATUS_CODE_INVALID_PARAM 

Invalid parameters.

◆ m_batt_meas_event_type_t

Battery and charge event codes.

Enumerator
M_BATT_MEAS_EVENT_DATA 

Is called back at the desired frequency.

M_BATT_MEAS_EVENT_LOW 

Low battery event (<= set by user).

M_BATT_MEAS_EVENT_FULL 

Full battery event (>= value set by user).

M_BATT_MEAS_EVENT_USB_CONN_CHARGING 

Battery main og tricle charging active.

M_BATT_MEAS_EVENT_USB_CONN_CHARGING_FINISHED 

Battery charging finished/not charging.

M_BATT_MEAS_EVENT_USB_DISCONN 

USB disconnected, battery not charging.

M_BATT_MEAS_EVENT_ERROR 

Error state detected signalled by the charger (not implemeted, CHG and CHG finished will toggle in case of error).

Function Documentation

◆ m_batt_meas_disable()

uint32_t m_batt_meas_disable ( void  )

Function for stopping the battery measurement.

Returns
M_BATT_STATUS_CODE_SUCCESS
Other codes from the underlying driver.

◆ m_batt_meas_enable()

uint32_t m_batt_meas_enable ( uint32_t  meas_interval_ms)

Function for enabling battery measurement at the given interval.

Parameters
meas_interval_msSampling interval given in milliseconds.
Note
This will call the handler supplied in p_batt_meas_init at the given interval which is supplied with a m_batt_meas_event_t struct containing the information.
Returns
M_BATT_STATUS_CODE_SUCCESS
Other codes from the underlying driver.

◆ m_batt_meas_init()

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.

Parameters
[out]p_handlePointer to the location to store the service handle.
[in]p_batt_meas_initStruct containing the configuration parameters.
Returns
M_BATT_STATUS_CODE_SUCCESS
M_BATT_STATUS_CODE_INVALID_PARAM
NRF_ERROR_NULL
Other codes from the underlying driver.