Skip to content

Commit 7665c7f

Browse files
committed
UBox100 Firmware Block
1 parent ea6e053 commit 7665c7f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

comm/commands.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,9 @@ void commands_process_packet(unsigned char *data, unsigned int len,
569569
if (!REJECT_FLASH_LOADING) {
570570
flash_res = flash_helper_erase_new_app(buffer_get_uint32(data, &ind));
571571
}
572+
else {
573+
commands_printf("Firmware loading rejected by the controller.");
574+
}
572575
if (flash_res == FLASH_COMPLETE) {
573576
// For now, erase the PIN as well - in the future we may want to let the PIN persist
574577
conf_general_set_writelock_pin(0, false);

hwconf/Ubox/100v/hw_ubox_100_core.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,12 @@ bool shutdown_button_pressed(void)
365365

366366
bool hw_reject_flash_loading(void)
367367
{
368+
bool do_reject = power_key_type == power_key_type_momentary;
369+
if (do_reject)
370+
commands_printf("Momentary button detected, firmware loading is not permitted!");
371+
368372
// Don't allow loading firmware if the power button behaves like a momentary one
369-
return power_key_type == power_key_type_momentary;
373+
return do_reject;
370374
}
371375

372376
static THD_FUNCTION(shutdown_thread, arg) {
@@ -501,7 +505,14 @@ static THD_FUNCTION(shutdown_thread, arg) {
501505
}
502506

503507
if(power_key_pressed_ms > 2000) {
504-
do_shutdown(true);
508+
if (conf->shutdown_mode == SHUTDOWN_MODE_OFF_AFTER_10M) {
509+
mcpwm_foc_play_tone(0, 1046.5, 0.9);
510+
chThdSleepMilliseconds(30);
511+
mcpwm_foc_stop_audio(true);
512+
}
513+
if (conf->shutdown_mode == SHUTDOWN_MODE_OFF_AFTER_5H) {
514+
do_shutdown(true);
515+
}
505516
}
506517
} else {
507518
m_inactivity_time += dt;

0 commit comments

Comments
 (0)