changeset 645:e58f81cb25a7

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.
author Ideenmodellierer
date Tue, 13 Apr 2021 19:18:32 +0200
parents ebe3fc302ab8
children 0fc1b47d2482
files Small_CPU/Src/batteryCharger.c
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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 */