APP_DATA appData;

int APP_Bootloader_ForceEvent(void)
{
    /* Check the switch press to trigger bootloader */
    if (BOOTStateGet()) return (1);

    /* Check the trigger memory location and return true/false. */
    if (*(uint32_t *)APP_RESET_ADDRESS == 0xFFFFFFFF) return (1);
    
    return (0);
}

void APP_Initialize ( void )
{
    appData.state = APP_STATE_INIT;

    // Register the bootloader callbacks
    BOOTLOADER_ForceBootloadRegister(APP_Bootloader_ForceEvent);
}

void APP_Tasks ( void )
{
    switch ( appData.state ){
        case APP_STATE_INIT:
        {
            bool appInitialized = true;             
            if (appInitialized) appData.state = APP_STATE_SERVICE_TASKS;
            break;
        }

        case APP_STATE_SERVICE_TASKS:
        {
            static uint32_t cntr = 0;
            // Blink the LED
            if (cntr++ == 100000) {
                LEDToggle();
                cntr = 0;
            }       
            break;
        }
    }
}