Esempio n. 1
0
void APP_Tasks ( void )
{
   /* Take appropriate action, depending on the current state. */
    switch (appData.state)
    {

        /* Application is stuck in a counting loop. */
        case APP_STATE_COUNT:
        {
            /* Keep incrementing the count if it's less than the blink delay */
            if (i < APP_LED_BLINK_DELAY)
            {
                /* Increment count. */
                i++;
            }

            else
            {
                /* If count is reached, switch states */
                appData.state = APP_STATE_BLINK_LED;
            }

            break;
        }

        /* Toggle the LED and switch back to the delay loop. */
        case APP_STATE_BLINK_LED:
        {
            /* Toggle LED */
            BSP_LEDToggle(BSP_LED_3);

            /* Put the application back to the count state */
            appData.state = APP_STATE_COUNT;

            /* Restart count. */
            i = 0;

            break;
        }

        /* Should not come here during normal operation */
        default:
        {
            PLIB_ASSERT(false , "unknown application state");

            break;
        }

    }
}
Esempio n. 2
0
int main ( void )
{
    /* Initialize the application. */
    SYS_Initialize();

    while (true)
    {
        /* Maintain the application's state machine. */
        SYS_Tasks();
    }

    /* Should not come here during normal operation */
    PLIB_ASSERT(false, "leaving main");
    
    return (EXIT_FAILURE);
}
Esempio n. 3
0
void APP_Tasks ( void )
{
    /* Take appropriate action, depending on the current state. */
    switch (appObject.state)
    {

         /* Application is stuck in an idle loop. */
        case APP_STATE_IDLE:
        {
            break;
        }

        /* Continuously blinking the LED. */
        case APP_STATE_BLINKING:
        {
            /* Blink LED every 1/4 second */
            if (BSP_ReadCoreTimer() >= (APP_LED_BLINK_DELAY_1s/4))
            {
               /* Toggle LED */
               BSP_ToggleLED(LED_1);

               /* Clear the core timer to restart count. */
               BSP_WriteCoreTimer(0);
            }

            break;
        }

        /* Should not come here during normal operation */
        default:
        {
            PLIB_ASSERT(false , "unknown application state");

            break;
        }

    }
}