Skip to content

Commit f705455

Browse files
michalmosurfdado
authored andcommitted
enable shutdown sequence on ADV2
1 parent f31b1f3 commit f705455

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

LCM/Code/App/task.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@ void KEY1_Task(void)
100100
case 3: // Long press
101101
if(Power_Flag == 2) // Boot completed
102102
{
103-
#ifndef ADV2
103+
#ifdef ADV2
104+
Power_Flag = 5; // external power off
105+
#else
104106
Power_Flag = 4; // VESC power off
105-
Power_Time = 0;
106107
#endif
108+
Power_Time = 0;
107109
}
108110
break;
109111

@@ -510,6 +512,13 @@ void Power_Task(void)
510512
Power_Flag = 3;
511513
}
512514
}
515+
else if (Power_Flag == 5) {
516+
if(Power_Time > VESC_SHUTDOWN_TIME)
517+
{
518+
// BMS should shutdown the board by now, otherwise it was a false positive
519+
Power_Flag = 2;
520+
}
521+
}
513522

514523
if(power_flag_last == Power_Flag && Power_Flag != 1)
515524
{
@@ -548,6 +557,7 @@ void Power_Task(void)
548557
break;
549558

550559
case 4:// New Power state for shutdown sequence
560+
case 5:// New Power state for ADV2 external shutdown sequence
551561
WS2812_Display_Flag = 3;
552562
break;
553563

@@ -844,7 +854,7 @@ void Buzzer_Task(void)
844854
buzzer_step = 0;
845855
return;
846856
}
847-
else if (Power_Flag == 4)
857+
else if (Power_Flag == 4 || Power_Flag == 5)
848858
{
849859
// Beep when powering off
850860
if (buzzer_step == 0)

LCM/Code/App/task.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
#define SHUTDOWN_TIME 20
1313
#define VESC_RPM 1000
1414
#define VESC_BOOT_TIME 4000
15+
#ifndef VESC_SHUTDOWN_TIME
1516
#define VESC_SHUTDOWN_TIME 1000
17+
#endif
1618
#define DUTY_CYCLE 0.9
1719
#define VOLTAGE_RECEIPT 0.02
1820
#define CHARGE_COMMAND_TIME 1000 // frequency of notifying the float package of current charge state

LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ solution:
1414
- BATTERY_STRING: 20
1515
- FULL_VOLTAGE: 83
1616
- CHARGING_VOLTAGE: 3\.0
17+
- VESC_SHUTDOWN_TIME: 4000
1718
- FIRMWARE_ID_PREFIX: '"ADV2"'
1819
device: HK_MicroChip::HK32F030MF4P6
1920
- type: ADV-P42A

LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New.uvprojx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3204,7 +3204,7 @@
32043204
<v6Rtti>0</v6Rtti>
32053205
<VariousControls>
32063206
<MiscControls></MiscControls>
3207-
<Define>HK32F030M HK32F030MF4P6 ADV2 S50S IWDG_DEBUG BATTERY_STRING=20 FULL_VOLTAGE=83 CHARGING_VOLTAGE=3.0 FIRMWARE_ID_PREFIX=\"ADV2\"</Define>
3207+
<Define>HK32F030M HK32F030MF4P6 ADV2 S50S IWDG_DEBUG BATTERY_STRING=20 FULL_VOLTAGE=83 CHARGING_VOLTAGE=3.0 VESC_SHUTDOWN_TIME=4000 FIRMWARE_ID_PREFIX=\"ADV2\"</Define>
32083208
<Undefine></Undefine>
32093209
<IncludePath>..\..\Code\App;..\..\Code\Drive;..\..\Code\User;..\..\Library\HK32F030Mxx_Library_V1.1.6\HK32F030M\HK32F030M_Lib\inc;..\..\Library\HK32F030Mxx_Library_V1.1.6\HK32F030M\CMSIS\CM0\Core;..\..\Library\HK32F030Mxx_Library_V1.1.6\HK32F030M\CMSIS\HK32F030M\Include</IncludePath>
32103210
</VariousControls>

0 commit comments

Comments
 (0)