//*****************************************************************************
//
// Initialize SafeRTOS and start the initial set of tasks.
//
//*****************************************************************************
int
main(void)
{
    tContext sContext;
    tRectangle sRect;

    //
    // Set the clocking to run at 80 MHz from the PLL.
    //
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
                       SYSCTL_OSC_MAIN);

    //
    // Initialize the device pinout appropriately for this board.
    //
    PinoutSet();

    //
    // Initialize the display driver.
    //
    Kitronix320x240x16_SSD2119Init();

    //
    // Initialize the graphics context.
    //
    GrContextInit(&sContext, &g_sKitronix320x240x16_SSD2119);

    //
    // Fill the top 24 rows of the screen with blue to create the banner.
    //
    sRect.sXMin = 0;
    sRect.sYMin = 0;
    sRect.sXMax = GrContextDpyWidthGet(&sContext) - 1;
    sRect.sYMax = 23;
    GrContextForegroundSet(&sContext, ClrDarkBlue);
    GrRectFill(&sContext, &sRect);

    //
    // Put a white box around the banner.
    //
    GrContextForegroundSet(&sContext, ClrWhite);
    GrRectDraw(&sContext, &sRect);

    //
    // Put the application name in the middle of the banner.
    //
    GrContextFontSet(&sContext, g_pFontCm20);
    GrStringDrawCentered(&sContext, "safertos-demo", -1,
                         GrContextDpyWidthGet(&sContext) / 2, 10, 0);

    //
    // Set the location and size of the system stack.
    //
    g_sSafeRTOSPortInit.pulSystemStackLocation =
        (unsigned portLONG *)(*(unsigned long *)0);
    g_sSafeRTOSPortInit.ulSystemStackSizeBytes = 128 * 4;

    //
    // Set the location of the vector table.
    //
    g_sSafeRTOSPortInit.pulVectorTableBase =
        (unsigned portLONG *)HWREG(NVIC_VTABLE);

    //
    // Initialize the SafeRTOS kernel.
    //
    vTaskInitializeScheduler((signed portCHAR *)g_pulIdleTaskStack,
                             sizeof(g_pulIdleTaskStack), 0,
                             &g_sSafeRTOSPortInit);

    //
    // Create the display task.
    //
    if(DisplayTaskInit() != 0)
    {
        GrContextForegroundSet(&sContext, ClrRed);
        GrStringDrawCentered(&sContext, "Failed to create display task!", -1,
                             GrContextDpyWidthGet(&sContext) / 2,
                             (((GrContextDpyHeightGet(&sContext) - 24) / 2) +
                              24), 0);
        while(1)
        {
        }
    }

    //
    // Create the spider task.
    //
    if(SpiderTaskInit() != 0)
    {
        GrContextForegroundSet(&sContext, ClrRed);
        GrStringDrawCentered(&sContext, "Failed to create spider task!", -1,
                             GrContextDpyWidthGet(&sContext) / 2,
                             (((GrContextDpyHeightGet(&sContext) - 24) / 2) +
                              24), 0);
        while(1)
        {
        }
    }

    //
    // Create the LED task.
    //
    if(LEDTaskInit() != 0)
    {
        GrContextForegroundSet(&sContext, ClrRed);
        GrStringDrawCentered(&sContext, "Failed to create LED task!", -1,
                             GrContextDpyWidthGet(&sContext) / 2,
                             (((GrContextDpyHeightGet(&sContext) - 24) / 2) +
                              24), 0);
        while(1)
        {
        }
    }

    //
    // Create the lwIP tasks.
    //
    if(lwIPTaskInit() != 0)
    {
        GrContextForegroundSet(&sContext, ClrRed);
        GrStringDrawCentered(&sContext, "Failed to create lwIP tasks!", -1,
                             GrContextDpyWidthGet(&sContext) / 2,
                             (((GrContextDpyHeightGet(&sContext) - 24) / 2) +
                              24), 0);
        while(1)
        {
        }
    }

    //
    // Start the scheduler.  This should not return.
    //
    xTaskStartScheduler(pdTRUE);

    //
    // In case the scheduler returns for some reason, print an error and loop
    // forever.
    //
    GrContextForegroundSet(&sContext, ClrRed);
    GrStringDrawCentered(&sContext, "Failed to start scheduler!", -1,
                         GrContextDpyWidthGet(&sContext) / 2,
                         (((GrContextDpyHeightGet(&sContext) - 24) / 2) + 24),
                         0);
    while(1)
    {
    }
}
예제 #2
0
//*****************************************************************************
//
// Initialize FreeRTOS and start the initial set of tasks.
//
//*****************************************************************************
int
main(void)
{
    tContext sContext;

    //
    // Run from the PLL at 120 MHz.
    //
    g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                            SYSCTL_OSC_MAIN |
                                            SYSCTL_USE_PLL |
                                            SYSCTL_CFG_VCO_480),
                                            configCPU_CLOCK_HZ);

    //
    // Initialize the device pinout appropriately for this board.
    //
    PinoutSet();

    //
    // Initialize the display driver.
    //
    Kentec320x240x16_SSD2119Init(g_ui32SysClock);

    //
    // Initialize the graphics context.
    //
    GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119);

    //
    // Draw the application frame.
    //
    FrameDraw(&sContext, "freertos-demo");

    //
    // Make sure the main oscillator is enabled because this is required by
    // the PHY.  The system must have a 25MHz crystal attached to the OSC
    // pins.  The SYSCTL_MOSC_HIGHFREQ parameter is used when the crystal
    // frequency is 10MHz or higher.
    //
    SysCtlMOSCConfigSet(SYSCTL_MOSC_HIGHFREQ);

    //
    // Create the display task.
    //
    if(DisplayTaskInit() != 0)
    {
        GrContextForegroundSet(&sContext, ClrRed);
        GrStringDrawCentered(&sContext, "Failed to create display task!", -1,
                             GrContextDpyWidthGet(&sContext) / 2,
                             (((GrContextDpyHeightGet(&sContext) - 24) / 2) +
                              24), 0);
        while(1)
        {
        }
    }

    //
    // Create the spider task.
    //
    if(SpiderTaskInit() != 0)
    {
        GrContextForegroundSet(&sContext, ClrRed);
        GrStringDrawCentered(&sContext, "Failed to create spider task!", -1,
                             GrContextDpyWidthGet(&sContext) / 2,
                             (((GrContextDpyHeightGet(&sContext) - 24) / 2) +
                              24), 0);
        while(1)
        {
        }
    }

    //
    // Create the LED task.
    //
    if(LEDTaskInit() != 0)
    {
        GrContextForegroundSet(&sContext, ClrRed);
        GrStringDrawCentered(&sContext, "Failed to create LED task!", -1,
                             GrContextDpyWidthGet(&sContext) / 2,
                             (((GrContextDpyHeightGet(&sContext) - 24) / 2) +
                              24), 0);
        while(1)
        {
        }
    }

    //
    // Create the lwIP tasks.
    //
    if(lwIPTaskInit() != 0)
    {
        GrContextForegroundSet(&sContext, ClrRed);
        GrStringDrawCentered(&sContext, "Failed to create lwIP tasks!", -1,
                             GrContextDpyWidthGet(&sContext) / 2,
                             (((GrContextDpyHeightGet(&sContext) - 24) / 2) +
                              24), 0);
        while(1)
        {
        }
    }

    //
    // Start the scheduler.  This should not return.
    //
    vTaskStartScheduler();

    //
    // In case the scheduler returns for some reason, print an error and loop
    // forever.
    //
    GrContextForegroundSet(&sContext, ClrRed);
    GrStringDrawCentered(&sContext, "Failed to start scheduler!", -1,
                         GrContextDpyWidthGet(&sContext) / 2,
                         (((GrContextDpyHeightGet(&sContext) - 24) / 2) + 24),
                         0);
    while(1)
    {
    }
}