|
Lamp-Da 0.1
A compact lantern project
|
Handles the battery charging processes. More...
Classes | |
| struct | Battery |
| Store the battery specific measurments ans status. It is a refined data version of the Measurments class. More... | |
| struct | Measurments |
| Store the DAC values mesured by some system sensors, relative to the battery and power. More... | |
| struct | PowerLimits |
| Store the power limits for the battery charge protocol. More... | |
Typedefs | |
| using | charger_ic = bq25713::BQ25713 |
Enumerations | |
| enum class | ChargerErrorCodeMask : uint32_t { InputOverVoltage = 0 , InputOverCurrent = 1 , BatteryOverCurrent = 2 , SystemOverVoltage = 3 , OtgOverVoltage = 4 , OtgOverCurrent = 5 } |
| enum class | Status_t { UNINITIALIZED , NOMINAL , ERROR , ERROR_COMPONENT , ERROR_HAS_FAULTS } |
| Store the status of the charge component. More... | |
| enum class | ChargeStatus_t { OFF , PRECHARGE , FASTCHARGE , SLOW_CHARGE } |
| Status of the charge process. More... | |
Functions | |
| static void | read_charge_option3 () |
| Read ChargeOption3 into the cached registers, without its command bits. RESET_VINDPM and RESET_REG are commands, that read as 1 while the IC executes them (a VINDPM measurement disables the converter). Keeping them in the cache would trigger them again on the next write of this register, and the frequent writes would then keep the converter disabled forever. | |
| etl::string< 64 > | get_software_error_message () |
| contains details on software error if any | |
| void | set_software_error_message (const etl::string< 64 > &msg) |
| uint32_t | run_fault_detection () |
| Detect the faults on the charger status. | |
| void | run_status_update () |
| void | control_charge () |
| void | control_OTG () |
| void | enable_charge (const bool enable) |
| Enable the charge process. this will start the charge only if the conditions are right. | |
| void | enable_input_current_optimization (const bool enable) |
| enable/disable the Input Current Optimizer algorithm | |
| void | update_battery () |
| void | run_ADC () |
| void | program_input_current_limit () |
| bool | enable (const uint16_t minSystemVoltage_mV, const uint16_t maxBatteryVoltage_mV, const uint16_t maxChargingCurrent_mA, const uint16_t maxDichargingCurrent_mA, const bool forceReset=false) |
| Call once on program start. | |
| void | loop (const bool isChargeOk) |
| Call often during execution. | |
| void | shutdown () |
| call on program stop to gracefully shutdown the component. | |
| void | set_input_current_limit (const uint16_t maxInputCurrent_mA, const bool shouldUseICO) |
| Set the input current limit. | |
| uint16_t | get_charge_current () |
| return the actual charge current, in milliamps. | |
| bool | is_input_source_present () |
| return true if an input source is present for the charger on the USB port. | |
| void | try_clear_faults () |
| try to clear the faults that can be cleared. if this succeeds, the status will be to NOMINAL next loop call. | |
| void | enable_OTG () |
| Enable the OTG and disable the charging process. | |
| void | disable_OTG () |
| Disable the OTG. | |
| void | set_OTG_targets (const uint16_t voltage_mV, const uint16_t maxCurrent_mA) |
| set the desired OTG capabilities | |
| bool | is_in_OTG () |
| Return true if the system is in OTG mode. | |
| Status_t | get_status () |
| return the status of the component | |
| etl::string< 64 > | get_status_detail () |
| return a string with details on the error status | |
| ChargeStatus_t | get_charge_status () |
| return the charge status object of the battery | |
| Measurments | get_measurments () |
| Battery | get_battery () |
Variables | |
| charger_ic | chargerIc |
| charger_ic::Regt | chargerIcRegisters |
| static Measurments | measurments_s |
| static Battery | battery_s |
| static Status_t | status_s = Status_t::UNINITIALIZED |
| static etl::string< 64 > | status_error = "" |
| static ChargeStatus_t | chargeStatus_s = ChargeStatus_t::OFF |
| static bool | isChargeOk_s = false |
| static bool | isChargeEnabled_s = false |
| static bool | isInOtg_s = false |
| etl::string< 64 > | softwareError_detail = "" |
| static PowerLimits | powerLimits_s |
| define the power limits for input power | |
| bool | isInit = false |
Handles the battery charging processes.
|
strong |
|
strong |
| bool lampda::bsp::charger::enable | ( | const uint16_t | minSystemVoltage_mV, |
| const uint16_t | maxBatteryVoltage_mV, | ||
| const uint16_t | maxChargingCurrent_mA, | ||
| const uint16_t | maxDichargingCurrent_mA, | ||
| const bool | forceReset = false |
||
| ) |
Call once on program start.
| [in] | minSystemVoltage_mV | Minimal allowed battery voltage. |
| [in] | maxBatteryVoltage_mV | Maximal allowed battery voltage |
| [in] | maxChargingCurrent_mA | Maximum allowed charge current for the battery. |
| [in] | maxDichargingCurrent_mA | Maximum allowed discharging current of the battery. |
| [in] | forceReset | If true, will reset the internal registers of the component. |
| void lampda::bsp::charger::enable_input_current_optimization | ( | const bool | enable | ) |
enable/disable the Input Current Optimizer algorithm
| [in] | enable | If true, the InputCurrentOptimization algorithm will be activated and the VBUS charge current will be optimized to reach a target droop voltage |
| void lampda::bsp::charger::loop | ( | const bool | isChargeOk | ) |
Call often during execution.
| [in] | isChargeOk | Should match what is read on the CHRG_OK IC pin of the charger. |
| uint32_t lampda::bsp::charger::run_fault_detection | ( | ) |
Detect the faults on the charger status.
| void lampda::bsp::charger::set_input_current_limit | ( | const uint16_t | maxInputCurrent_mA, |
| const bool | shouldUseICO | ||
| ) |
Set the input current limit.
| [in] | maxInputCurrent_mA | Maximum allowed current use on VBUS, in milliamps. |
| [in] | shouldUseICO | If True, the InputCurrentInitialization will be used. It automatically finds the most allowed current. |
| bool lampda::bsp::charger::isInit = false |
HEADER FUNCTIONS