Safer menu interrupt call

This commit is contained in:
Alex Voinea 2020-03-04 22:14:53 +02:00
parent 22432b1053
commit 40ebd455f2
No known key found for this signature in database
GPG key ID: F5034E7CFCF2F973

View file

@ -42,12 +42,12 @@ static_assert(sizeof(menu_data)>= sizeof(menu_data_edit_t),"menu_data_edit_t doe
void menu_goto(menu_func_t menu, const uint32_t encoder, const bool feedback, bool reset_menu_state) void menu_goto(menu_func_t menu, const uint32_t encoder, const bool feedback, bool reset_menu_state)
{ {
asm("cli"); CRITICAL_SECTION_START;
if (menu_menu != menu) if (menu_menu != menu)
{ {
menu_menu = menu; menu_menu = menu;
lcd_encoder = encoder; lcd_encoder = encoder;
asm("sei"); CRITICAL_SECTION_END;
if (reset_menu_state) if (reset_menu_state)
{ {
// Resets the global shared C union. // Resets the global shared C union.
@ -57,7 +57,7 @@ void menu_goto(menu_func_t menu, const uint32_t encoder, const bool feedback, bo
if (feedback) lcd_quick_feedback(); if (feedback) lcd_quick_feedback();
} }
else else
asm("sei"); CRITICAL_SECTION_END;
} }
void menu_start(void) void menu_start(void)