# HG changeset patch # User Ideenmodellierer # Date 1618334312 -7200 # Node ID e58f81cb25a7127043372e741ae0a533b049539f # Parent ebe3fc302ab80a506d85eec42cd998e02c06a18a Small changes in charger state handling: Charger debounce time has been reduced to 5 seconds and the detection time of charger removal has been reduced to 15 second to be able to provide a faster feedback to the user. In addition the battery stage reset has been added (only relevant for a getState function which is not used within the firmware at the moment. diff -r ebe3fc302ab8 -r e58f81cb25a7 Small_CPU/Src/batteryCharger.c --- a/Small_CPU/Src/batteryCharger.c Tue Mar 30 10:34:12 2021 +0200 +++ b/Small_CPU/Src/batteryCharger.c Tue Apr 13 19:18:32 2021 +0200 @@ -45,7 +45,7 @@ #define CHARGE_OUT_GPIO_PORT GPIOC #define CHARGE_OUT_GPIO_ENABLE() __GPIOC_CLK_ENABLE() -#define CHARGER_DEBOUNCE_SECONDS (120u) /* 120 seconds used to avoid problems with charger interrupts / disconnections */ +#define CHARGER_DEBOUNCE_SECONDS (5u) /* 5 seconds used to avoid problems with charger interrupts / disconnections */ uint8_t battery_i_charge_status = 0; uint16_t battery_charger_counter = 0; @@ -165,7 +165,7 @@ batteryChargerState = Charger_Finished; global.dataSendToMaster.chargeStatus = CHARGER_complete; global.deviceDataSendToMaster.chargeStatus = CHARGER_complete; - battery_charger_counter = 30; + battery_charger_counter = 15; notifyChargeComplete = 1; } break; @@ -181,6 +181,7 @@ else { battery_charger_counter = 0; + battery_i_charge_status = 0; global.dataSendToMaster.chargeStatus = CHARGER_off; global.deviceDataSendToMaster.chargeStatus = CHARGER_off; @@ -253,6 +254,7 @@ GPIO_InitStructure.Pull = GPIO_NOPULL; GPIO_InitStructure.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(CHARGE_OUT_GPIO_PORT, &GPIO_InitStructure); + HAL_Delay(1); break; default: /* wait for disconnection */