Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
lampda::bsp::balancer Namespace Reference

Handles the battery balancing process. More...

Classes

struct  Status
 Store the balancer component status. More...
 

Typedefs

using balancer_t = bq76905::BQ76905
 

Functions

static void publish_status ()
 Publish the working balancer status to the readers.
 
uint16_t get_battery_voltage_mv (const uint8_t index)
 
uint8_t compute_cell_balancing_max ()
 Compute the maximum number of cells that should be balanced at the same time prevent the breakage of the component at high temperatures.
 
void set_balancing (uint8_t cellIndex, bool shouldBalance)
 
bool is_balancing (uint8_t cellIndex)
 
void balance_batteries ()
 
void disable_battery_balancing ()
 
Status get_status ()
 Return the status of the balancer.
 
bool init ()
 Call once on init.
 
void loop ()
 call often to refresh measurments
 
void enable_balancing (bool enable)
 enable the battery balancing process
 
void go_to_sleep ()
 call before the system goes to sleep
 

Variables

constexpr uint16_t unbalancedMv = 3
 threshold at which point a battery is considered unbalanced with another
 
Status _status
 Working balancer status: only accessed by the power thread, that runs the balancer loop.
 
static Status _publishedStatus
 Copy of the balancer status given to the readers of all threads, see get_status(). The power thread updates it from _status once a measurement is complete: only access it under _publishedStatusMutex.
 
static hal::mutex::hal_mutex_t _publishedStatusMutex
 Guards _publishedStatus: a reader never sees a partial measurement. Not recursive.
 
static const bool _isPublishedStatusMutexInit
 Initialized at program start: the status can be read before the balancer init.
 
balancer_t balancer
 
balancer_t::Regt balancerRegisters
 
bool isBalancingEnabled = false
 
bool isInit = false
 
bool isInitFirstFullScanDone = false
 

Detailed Description

Handles the battery balancing process.

Function Documentation

◆ init()

bool lampda::bsp::balancer::init ( )

Call once on init.

Returns
false if the component detect an issue

Variable Documentation

◆ _isPublishedStatusMutexInit

const bool lampda::bsp::balancer::_isPublishedStatusMutexInit
static
Initial value:
=
(hal::mutex::hal_mutex_init(&_publishedStatusMutex), true)

Initialized at program start: the status can be read before the balancer init.