forked from achamaikin/CCSModuleSW30Web
Use 30-second elapsed button hold and bounded reboot UART wait
This commit is contained in:
1 parent
4f33a19387
commit
1c0811d343
6 files changed
+8876
-8854
No files matched your search
+12
-6
@@ -110,7 +110,9 @@ void ED_Delay(uint32_t Delay)
|
||||
|
||||
static void StopButtonControl(void){
|
||||
static uint32_t tick;
|
||||
static uint32_t hold_time;
|
||||
static uint32_t pressed_at;
|
||||
static uint8_t holding;
|
||||
static uint8_t unlocked;
|
||||
static uint8_t stop_btn_fault = 1;
|
||||
uint32_t now = HAL_GetTick();
|
||||
|
||||
@@ -130,14 +132,17 @@ static void StopButtonControl(void){
|
||||
}
|
||||
|
||||
if(pressed){
|
||||
if(hold_time == 0){
|
||||
if(!holding){
|
||||
pressed_at = now;
|
||||
holding = 1;
|
||||
CONN.connControl = CMD_STOP;
|
||||
}
|
||||
hold_time += 10;
|
||||
if(hold_time == 5000){
|
||||
uint32_t hold_time = now - pressed_at;
|
||||
if(!unlocked && hold_time >= 5000u){
|
||||
unlocked = 1;
|
||||
CONN.connControl = CMD_FORCE_UNLOCK;
|
||||
}
|
||||
if(hold_time > 40000){
|
||||
if(hold_time >= 30000u){
|
||||
SC_SendPacket(NULL, 0, EVENT_HOST_REBOOT);
|
||||
{
|
||||
uint32_t t0 = HAL_GetTick();
|
||||
@@ -153,7 +158,8 @@ static void StopButtonControl(void){
|
||||
}
|
||||
}
|
||||
else{
|
||||
hold_time = 0;
|
||||
holding = 0;
|
||||
unlocked = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user