Refactoring menu code to be non-blocking

Added macros for GPIO read/write
This commit is contained in:
2025-05-16 07:56:18 -05:00
parent a3ef12e24a
commit da0dd55b20
11 changed files with 316 additions and 41 deletions

View File

@@ -49,6 +49,9 @@
//temp
#include "fsl_sctimer.h"
#include "System/system.h"
#include "io.h"
extern volatile uint8_t BC_Duty_Cycle;
uint8_t Task,Tx_Time_Out_Flag,i,Test_Mode;
@@ -68,6 +71,7 @@ extern uint8_t frq_update_flag,Ports_Cleared_Flag;
extern HARDWARE_FIX_t hwf;
extern uint8_t tempString[40]; // Todo move
extern SYSTEM_DATA_t sys;
#define BYPASS_USB_SAFETY 0 //Use for debugging
#define DDS_PLL_TEST 0
@@ -203,6 +207,10 @@ int main(void)
USB_Init();
Menu_init();
sys.guiMode = GUI_MODE_NORMAL;
#if DDS_PLL_TEST
//# Insert special test code here.
@@ -215,24 +223,6 @@ uint32_t tmp;
//# End Test code
#endif
//#########################
// if(Read_Model_type() == LEICA) // Read Model Patches erroneous boards sent to Leica 8/2/24
// {
// sprintf(tempString, "%d", hwf.mainPcbaPN);
// if(strncmp(tempString,"208021",6) == 0) // check for HW rev.
// {
// hwf.mainPcbaPN = 208025;
// EE_WriteUINT32(EE_HWFIX_MAIN_PCBA_PN, hwf.mainPcbaPN);// Change to 208025 Assembly
// }
// }
// Leica_Patch(); // Patches erroneous boards sent to Leica 8/2/24
// Umag_Patch();
//########################
while(1)
{
@@ -243,7 +233,7 @@ uint32_t tmp;
#if !BYPASS_USB_SAFETY
//#####################
Check_For_Usb();
if(GPIO_PinRead(GPIO,1,6))
if(GPIO_READ(PIN_VBUS))
{
Task = USB_SAFE_TASK; // process primary keys as safety menu
safe_key(); // process primary keys as safety menu
@@ -253,7 +243,7 @@ uint32_t tmp;
}
else
if(!GPIO_PinRead(GPIO,1,6) && Ports_Cleared_Flag)
if(!GPIO_READ(PIN_VBUS) && Ports_Cleared_Flag)
{
Normal_Init(); // USB is unplugged so reinitialize
}
@@ -263,9 +253,32 @@ uint32_t tmp;
Delay_Ticks(1); //10mS delay
KEY_Update();
if (sys.guiMode == GUI_MODE_MENU)
{
Menu_service();
}
else
{
switch(KEY_GetPressed())
{
case MENU_KEY:
{
Menu_mainMenu();
break;
}
}
Display_Update();
}
#if !BYPASS_USB_SAFETY
if((tickCount++ % 10 == 0) && !GPIO_PinRead(GPIO,1,6)) //every 10 ticks = 100mS AND !USB
if((tickCount++ % 10 == 0) && !GPIO_READ(PIN_VBUS)) //every 10 ticks = 100mS AND !USB
#else
if(tickCount++ % 10 == 0) //every 10 ticks = 100mS
#endif
@@ -287,7 +300,7 @@ uint32_t tmp;
break;
case PRIMARY_TASK:
pro_key(); // process primary keys front 6 first menu
//pro_key(); // process primary keys front 6 first menu
break;
case MENU_TASK: // Allows user to select options
@@ -378,7 +391,7 @@ uint32_t tmp;
if (Taps_adjust_timer == 0)
Check_Taps(); // Check for optimum Taps
#endif
Display_Update();
// Display_Update();
}