mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-19 17:23:25 +00:00
f05ffddbde
* Power: add portability layer, port to F3. * F3: bq25896 driver stab * GUI: new primary and secondary fonts * F3: bq25896 register map, basic functions * F3: move bq27220 command descritpion to separate file. Code format. * Power: OTG enable/disable * Power: choose more correct profile * F3: pet bq25896 watchdog sometimes
34 lines
691 B
C
34 lines
691 B
C
#include <api-hal-power.h>
|
|
#include <adc.h>
|
|
|
|
#define BATTERY_MIN_VOLTAGE 3.2f
|
|
#define BATTERY_MAX_VOLTAGE 4.0f
|
|
|
|
void api_hal_power_init() {}
|
|
|
|
uint8_t api_hal_power_get_pct() {
|
|
float value;
|
|
HAL_ADC_Start(&hadc1);
|
|
if(HAL_ADC_PollForConversion(&hadc1, 1000) != HAL_TIMEOUT) {
|
|
value = HAL_ADC_GetValue(&hadc1);
|
|
}
|
|
|
|
value = ((float)value / 10 * 2 - BATTERY_MIN_VOLTAGE) /
|
|
(BATTERY_MAX_VOLTAGE - BATTERY_MIN_VOLTAGE);
|
|
|
|
if(value > 100) {
|
|
value = 100;
|
|
}
|
|
|
|
return value;
|
|
}
|
|
|
|
bool api_hal_power_is_charging() {
|
|
return false;
|
|
}
|
|
|
|
void api_hal_power_off() {}
|
|
|
|
void api_hal_power_enable_otg() {}
|
|
|
|
void api_hal_power_disable_otg() {}
|