2021-02-09 09:57:24 +01:00
|
|
|
#pragma once
|
|
|
|
|
2021-02-09 14:34:35 +01:00
|
|
|
#include <devicetree.h>
|
2021-02-09 09:57:24 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2021-02-09 14:34:35 +01:00
|
|
|
// Generic voltage divider based battery support
|
|
|
|
#if DT_NODE_HAS_STATUS(DT_PATH(vbatt), okay)
|
|
|
|
#define BATTERY_SUPPORTED
|
2021-02-09 09:57:24 +01:00
|
|
|
int battery_init();
|
|
|
|
int battery_update();
|
2021-02-09 13:48:33 +01:00
|
|
|
uint16_t battery_get_voltage_mv();
|
2021-02-09 14:34:35 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// SOC estimation support
|
|
|
|
#if DT_NODE_HAS_STATUS(DT_PATH(battery), okay)
|
|
|
|
#define BATTERY_SOC_SUPPORTED
|
|
|
|
uint32_t battery_voltage_mv_to_soc(uint16_t batt_mv);
|
|
|
|
#endif
|