12#ifndef __NRF_FUEL_GAUGE_H__
13#define __NRF_FUEL_GAUGE_H__
63#define NRF_FUEL_GAUGE_DEFAULT_INIT_PARAMETERS_PRIMARY(_v0, _i0, _t0, _battery_model)\
64 ((struct nrf_fuel_gauge_init_parameters) {\
68 .model_primary = _battery_model,\
82#define NRF_FUEL_GAUGE_DEFAULT_INIT_PARAMETERS_SECONDARY(_v0, _i0, _t0, _battery_model)\
83 ((struct nrf_fuel_gauge_init_parameters) {\
87 .model = _battery_model,\
nrf_fuel_gauge_variant_type
Definition nrf_fuel_gauge.h:93
@ NRF_FUEL_GAUGE_VARIANT_SECONDARY
Definition nrf_fuel_gauge.h:97
@ NRF_FUEL_GAUGE_VARIANT_PRIMARY
Definition nrf_fuel_gauge.h:95
int nrf_fuel_gauge_idle_set(float v, float T, float i_avg)
Put library into the idle state.
int nrf_fuel_gauge_soh_get(float *soh)
Get predicted battery state-of-health (SOH) as a percentage of modeled battery capacity.
int nrf_fuel_gauge_state_get(void *state, size_t size)
Retrieve library state data.
enum nrf_fuel_gauge_variant_type nrf_fuel_gauge_variant
Build variant of nRF Fuel Gauge library.
const char * nrf_fuel_gauge_build_date
Build date of nRF Fuel Gauge library.
int nrf_fuel_gauge_config_params_adjust(const struct nrf_fuel_gauge_config_parameters *params)
Update configuraton parameters.
int nrf_fuel_gauge_tte_get(float *tte)
Get predicted "time-to-empty" discharge duration.
int nrf_fuel_gauge_process(float v, float i, float T, float t_delta, float *soc, struct nrf_fuel_gauge_state_info *state)
Process battery measurement values.
int nrf_fuel_gauge_init(const struct nrf_fuel_gauge_init_parameters *parameters, float *v0)
Initialize the nRF Fuel Gauge library.
int nrf_fuel_gauge_config_params_current_get(struct nrf_fuel_gauge_config_parameters *params)
Initialize configuration parameter structure to the currently used values.
int nrf_fuel_gauge_config_params_default_get(struct nrf_fuel_gauge_config_parameters *params)
Initialize configuration parameter structure to default values.
int nrf_fuel_gauge_ttf_get(float *ttf)
Get predicted "time-to-full" charging duration.
nrf_fuel_gauge_ext_state_info_type
State info type used for informing the library of external factors and events.
Definition nrf_fuel_gauge.h:383
@ NRF_FUEL_GAUGE_EXT_STATE_INFO_DISCHARGE_CURRENT_CORRECTION
Definition nrf_fuel_gauge.h:393
@ NRF_FUEL_GAUGE_EXT_STATE_INFO_VBUS_DISCONNECTED
Definition nrf_fuel_gauge.h:387
@ NRF_FUEL_GAUGE_EXT_STATE_INFO_VBUS_CONNECTED
Definition nrf_fuel_gauge.h:385
@ NRF_FUEL_GAUGE_EXT_STATE_INFO_CHARGE_CURRENT_LIMIT
Definition nrf_fuel_gauge.h:395
@ NRF_FUEL_GAUGE_EXT_STATE_INFO_BATTERY_REPLACED
Definition nrf_fuel_gauge.h:399
@ NRF_FUEL_GAUGE_EXT_STATE_INFO_TERM_CURRENT
Definition nrf_fuel_gauge.h:397
@ NRF_FUEL_GAUGE_EXT_STATE_INFO_CHARGE_CURRENT_CORRECTION
Definition nrf_fuel_gauge.h:391
@ NRF_FUEL_GAUGE_EXT_STATE_INFO_CHARGE_STATE_CHANGE
Definition nrf_fuel_gauge.h:389
const size_t nrf_fuel_gauge_state_size
Size of the internal state memory used by nRF Fuel Gauge library.
nrf_fuel_gauge_charge_state
Charger state enum.
Definition nrf_fuel_gauge.h:356
@ NRF_FUEL_GAUGE_CHARGE_STATE_TRICKLE
Definition nrf_fuel_gauge.h:360
@ NRF_FUEL_GAUGE_CHARGE_STATE_CC_LIMITED
Definition nrf_fuel_gauge.h:371
@ NRF_FUEL_GAUGE_CHARGE_STATE_COMPLETE
Definition nrf_fuel_gauge.h:375
@ NRF_FUEL_GAUGE_CHARGE_STATE_CV
Definition nrf_fuel_gauge.h:373
@ NRF_FUEL_GAUGE_CHARGE_STATE_IDLE
Definition nrf_fuel_gauge.h:358
@ NRF_FUEL_GAUGE_CHARGE_STATE_CC
Definition nrf_fuel_gauge.h:365
int nrf_fuel_gauge_soc_get(float *soc)
Get predicted state-of-charge value.
const char * nrf_fuel_gauge_version
Version number of nRF Fuel Gauge library in format "x.y.z".
int nrf_fuel_gauge_ext_state_update(enum nrf_fuel_gauge_ext_state_info_type type, union nrf_fuel_gauge_ext_state_info_data *data)
Optional function to inform library of external events and factors.
int nrf_fuel_gauge_state_compatible_check(const void *state, size_t state_size)
Check if the provided state is compatible with the current library version.
signed char param_17[20]
Definition nrf_fuel_gauge.h:161
float param_5[201]
Definition nrf_fuel_gauge.h:151
float param_12
Definition nrf_fuel_gauge.h:158
float param_15
Definition nrf_fuel_gauge.h:159
float param_4[201]
Definition nrf_fuel_gauge.h:148
float param_13[201]
Definition nrf_fuel_gauge.h:156
float param_1[201]
Definition nrf_fuel_gauge.h:150
float param_16
Definition nrf_fuel_gauge.h:160
float param_14[201]
Definition nrf_fuel_gauge.h:157
float param_8[88]
Definition nrf_fuel_gauge.h:154
float param_2[88]
Definition nrf_fuel_gauge.h:153
float param_18[2]
Definition nrf_fuel_gauge.h:162
char name[64]
Definition nrf_fuel_gauge.h:164
float param_3[201]
Definition nrf_fuel_gauge.h:149
float param_6[201]
Definition nrf_fuel_gauge.h:152
float param_19
Definition nrf_fuel_gauge.h:163
float param_7[88]
Definition nrf_fuel_gauge.h:155
Primary cell (non-rechargeable) battery model parameters.
Definition nrf_fuel_gauge.h:147
float temps[3]
Definition nrf_fuel_gauge.h:127
float param_8[122]
Definition nrf_fuel_gauge.h:134
float param_10[6]
Definition nrf_fuel_gauge.h:136
float param_3[201]
Definition nrf_fuel_gauge.h:129
float param_7[122]
Definition nrf_fuel_gauge.h:133
float param_9[3]
Definition nrf_fuel_gauge.h:135
char name[64]
Definition nrf_fuel_gauge.h:139
float param_12[3]
Definition nrf_fuel_gauge.h:138
float param_5[201]
Definition nrf_fuel_gauge.h:131
float param_4[201]
Definition nrf_fuel_gauge.h:130
float param_11[6]
Definition nrf_fuel_gauge.h:137
float param_6[201]
Definition nrf_fuel_gauge.h:132
float param_2[122]
Definition nrf_fuel_gauge.h:128
float param_1[201]
Definition nrf_fuel_gauge.h:126
Secondary cell (rechargeable) battery model parameters.
Definition nrf_fuel_gauge.h:125
float soh_partial_R_penalty
Definition nrf_fuel_gauge.h:287
float neta1
Definition nrf_fuel_gauge.h:267
float soh_partial_min_deltaSOC
Definition nrf_fuel_gauge.h:286
float tau2
Definition nrf_fuel_gauge.h:266
float c
Definition nrf_fuel_gauge.h:279
float a
Definition nrf_fuel_gauge.h:277
float beta1
Definition nrf_fuel_gauge.h:269
float tte_reset_threshold
Definition nrf_fuel_gauge.h:222
float soh_calc_threshold
Definition nrf_fuel_gauge.h:245
float soh_rep_up_max
Definition nrf_fuel_gauge.h:284
float volt_drop
Definition nrf_fuel_gauge.h:272
float gating
Definition nrf_fuel_gauge.h:271
float cycle_repl_min
Definition nrf_fuel_gauge.h:281
float neta2
Definition nrf_fuel_gauge.h:268
float beta2
Definition nrf_fuel_gauge.h:270
float soh_jump_thr
Definition nrf_fuel_gauge.h:285
uint8_t vk_buffer_length
Definition nrf_fuel_gauge.h:273
float tau1
Definition nrf_fuel_gauge.h:265
float soh_up_cap_cycle_min
Definition nrf_fuel_gauge.h:282
float b
Definition nrf_fuel_gauge.h:278
float soh
Definition nrf_fuel_gauge.h:238
float d
Definition nrf_fuel_gauge.h:280
bool soh_estimate_enable
Definition nrf_fuel_gauge.h:227
float soh_alpha1
Definition nrf_fuel_gauge.h:274
float soh_alpha2
Definition nrf_fuel_gauge.h:275
float soh_up_max
Definition nrf_fuel_gauge.h:283
float soh_raw
Definition nrf_fuel_gauge.h:276
bool discard_positive_deltaz
Definition nrf_fuel_gauge.h:215
float cycle_count_cumulative_mah
Definition nrf_fuel_gauge.h:263
bool soh_partial_charge_enable
Definition nrf_fuel_gauge.h:234
float battery_min_capacity
Definition nrf_fuel_gauge.h:253
uint16_t cycle_count
Definition nrf_fuel_gauge.h:258
float tte_min_time
Definition nrf_fuel_gauge.h:217
Configuration parameters.
Definition nrf_fuel_gauge.h:210
float t0
Definition nrf_fuel_gauge.h:299
const void * state
Definition nrf_fuel_gauge.h:344
const struct battery_model * model
Definition nrf_fuel_gauge.h:303
size_t state_size
Definition nrf_fuel_gauge.h:346
const struct nrf_fuel_gauge_config_parameters * opt_params
Definition nrf_fuel_gauge.h:311
float i0
Definition nrf_fuel_gauge.h:297
const struct battery_model_primary * model_primary
Definition nrf_fuel_gauge.h:305
int(* lock_func)(const void *context, bool lock)
Definition nrf_fuel_gauge.h:320
const void * lock_context
Definition nrf_fuel_gauge.h:322
float v0
Definition nrf_fuel_gauge.h:295
Library init parameter struct.
Definition nrf_fuel_gauge.h:293
float T_truncated
Definition nrf_fuel_gauge.h:179
float k1
Definition nrf_fuel_gauge.h:197
float r0
Definition nrf_fuel_gauge.h:174
float cycle_count_cumulative_mah
Definition nrf_fuel_gauge.h:195
float i_corrected
Definition nrf_fuel_gauge.h:181
float k2
Definition nrf_fuel_gauge.h:198
float yhat
Definition nrf_fuel_gauge.h:172
float soc_raw
Definition nrf_fuel_gauge.h:183
float soh_raw
Definition nrf_fuel_gauge.h:185
uint16_t cycle_count
Definition nrf_fuel_gauge.h:190
Library state information. Useful for debugging.
Definition nrf_fuel_gauge.h:170
float charge_term_current
Definition nrf_fuel_gauge.h:413
float current_correction_factor
Definition nrf_fuel_gauge.h:409
float charge_current_limit
Definition nrf_fuel_gauge.h:411
enum nrf_fuel_gauge_charge_state charge_state
Definition nrf_fuel_gauge.h:407
State info data type used for additional information.
Definition nrf_fuel_gauge.h:405