Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Namespaces | Classes | Functions | Variables
lampda::component::charger Namespace Reference

Handles the battery charging processes, and power output control. More...

Namespaces

namespace  policy
 Charge stop rules, from a snapshot of the battery measurements.
 

Classes

struct  BatteryStatus_t
 Raw battery status measurments. More...
 
struct  Charger_t
 Store the charger characteristics. More...
 

Functions

static void publish_state ()
 Publish the working charger state to the readers.
 
bool should_charge ()
 
void control_OTG (const uint16_t mv, const uint16_t ma)
 Set the OTG control parameters. Set the parameters to zero to disable OTG mode.
 
bool is_status_error ()
 
void update_state_status ()
 
void update_state ()
 
bool setup ()
 call once at program startup
 
void loop ()
 call at every loop runs
 
void shutdown ()
 Call when system goes to sleep.
 
void set_enable_charge (const bool shouldCharge)
 debug feature: enable/disable the charging process
 
bool is_vbus_powered ()
 Return true if voltage is detected on VBUS.
 
bool can_use_vbus_power ()
 Return true if we are allowed to use the VBUS power.
 
bool is_vbus_signal_detected ()
 Return true if the USB VBUS presence signal is active.
 
Charger_t get_state ()
 Return the latest known state of the charger.
 

Variables

static policy::ChargeLimiter chargeLimiter_s
 Charge stop rules state (battery full, over voltage)
 
static bool enableCharge_s = true
 
static BatteryStatus_t batteryStatus
 
static Charger_t charger
 Working charger state: only accessed by the power thread, that runs the charger loop.
 
static Charger_t publishedCharger
 Copy of the charger state given to the readers of all threads, see get_state(). The power thread updates it from charger once its update is complete: only access it under _publishedChargerMutex.
 
static hal::mutex::hal_mutex_t _publishedChargerMutex
 Guards publishedCharger: a reader never sees a partial update (status, measurements and error messages). Not recursive.
 
static const bool _isPublishedChargerMutexInit
 Initialized at program start: the state can be read before the charger setup.
 
bool isOtgEnabled_s = false
 
bool isSetup = false
 
const hal::gpio::DigitalPin chargeOkPin (hal::gpio::DigitalPin::GPIO::Input_isChargeOk)
 

Detailed Description

Handles the battery charging processes, and power output control.

Function Documentation

◆ control_OTG()

void lampda::component::charger::control_OTG ( const uint16_t  mv,
const uint16_t  ma 
)

Set the OTG control parameters. Set the parameters to zero to disable OTG mode.

Parameters
[in]mvDesired output voltage in millivolts
[in]maDesired maximum output current in milliamps

Variable Documentation

◆ _isPublishedChargerMutexInit

const bool lampda::component::charger::_isPublishedChargerMutexInit
static
Initial value:
=
(hal::mutex::hal_mutex_init(&_publishedChargerMutex), true)

Initialized at program start: the state can be read before the charger setup.

◆ isSetup

bool lampda::component::charger::isSetup = false

HEADER DEFINITIONS