//*****************************************************************************
//
// Initializes the display task.
//
//*****************************************************************************
unsigned long
DisplayTaskInit(void)
{
    //
    // Create a queue for sending messages to the display task.
    //
    if(xQueueCreate((signed portCHAR *)g_pulDisplayQueueMem, DISPLAY_MEM_SIZE,
                    DISPLAY_QUEUE_SIZE, DISPLAY_ITEM_SIZE,
                    &g_pDisplayQueue) != pdPASS)
    {
        return(1);
    }

    //
    // Create the display task.
    //
    if(xTaskCreate(DisplayTask, (signed portCHAR *)"Display",
                   (signed portCHAR *)g_pulDisplayTaskStack,
                   sizeof(g_pulDisplayTaskStack), NULL, PRIORITY_DISPLAY_TASK,
                   NULL) != pdPASS)
    {
        return(1);
    }
    TaskCreated();

    //
    // Success.
    //
    return(0);
}
Example #2
0
//*****************************************************************************
//
// Initializes the USB OTG task.
//
//*****************************************************************************
unsigned long
USBOTGTaskInit(void)
{
    //
    // Configure the required pins for USB operation.
    //
    ROM_GPIOPinTypeUSBDigital(GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7);
    ROM_GPIOPinTypeUSBDigital(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Initialize the USB stack mode and pass in a mode callback.
    //
    USBStackModeSet(0, USB_MODE_OTG, ModeCallback);

    //
    // Initialize the host stack.
    //
    HostMSCInit();

    //
    // Initialize the device stack.
    //
    DeviceMSCInit();

    //
    // Initialize the USB controller for dual mode operation with a 2ms polling
    // rate.
    //
    USBOTGModeInit(0, 2000, g_pHCDPool, HCD_MEMORY_SIZE);
    //
    // Set the new state so that the screen updates on the first
    // pass.
    //
    g_ulNewState = 1;
    //
    // Create a queue for sending messages to the display task.
    //
    if(xQueueCreate((signed portCHAR *)g_pulDisplayQueueMem, DISPLAY_MEM_SIZE,
                    DISPLAY_QUEUE_SIZE, DISPLAY_ITEM_SIZE,
                    &g_pDisplayQueue) != pdPASS)
    {
        return(1);
    }

    //
    // Create the display task.
    //
    if(xTaskCreate(USBOTGTask, (signed portCHAR *)"USB-OTG",
                   (signed portCHAR *)ulUSBOTGTaskStack,
                   sizeof(ulUSBOTGTaskStack), NULL, PRIORITY_USB_CTRL_TASK,
                   NULL) != pdPASS)
    {
        return(1);
    }
    TaskCreated();

    //
    // Success.
    //
    return(0);
}
//*****************************************************************************
//
// Creates a spider task.
//
//*****************************************************************************
static unsigned long
CreateSpider(long lX, long lY)
{
    unsigned long lSpider;

    //
    // Search to see if there is a spider task available.
    //
    for(lSpider = 0; lSpider < MAX_SPIDERS; lSpider++)
    {
        if(HWREGBITW(&g_ulSpiderAlive, lSpider) == 0)
        {
            break;
        }
    }

    //
    // Return a failure if no spider tasks are available (in other words, the
    // maximum number of spiders are already alive).
    //
    if(lSpider == MAX_SPIDERS)
    {
        return(1);
    }

    //
    // Adjust the starting horizontal position to make sure it is inside the
    // allowable area for the spiders.
    //
    if(lX < SPIDER_MIN_X)
    {
        lX = SPIDER_MIN_X;
    }
    else if(lX > SPIDER_MAX_X)
    {
        lX = SPIDER_MAX_X;
    }

    //
    // Adjust the starting vertical position to make sure it is inside the
    // allowable area for the spiders.
    //
    if(lY < SPIDER_MIN_Y)
    {
        lY = SPIDER_MIN_Y;
    }
    else if(lY > SPIDER_MAX_Y)
    {
        lY = SPIDER_MAX_Y;
    }

    //
    // Save the starting position for this spider.
    //
    g_plSpiderX[lSpider] = lX;
    g_plSpiderY[lSpider] = lY;

    //
    // Create a task to animate this spider.
    //
    if(xTaskCreate(SpiderTask, (signed portCHAR *)"Spider",
                   (signed portCHAR *)(g_ppulSpiderTaskStack[lSpider]),
                   sizeof(g_ppulSpiderTaskStack[0]), (void *)lSpider, 0,
                   NULL) != pdPASS)
    {
        return(1);
    }
    TaskCreated();

    //
    // Success.
    //
    return(0);
}