Esempio n. 1
0
//*****************************************************************************
//
// Calls the USB host stack tick function.
//
// This function is called periodically to allow the USB host stack to
// process any outstanding items.
//
// \return None.
//
//*****************************************************************************
void
ScopeUSBHostTick(void)
{
    tBoolean bRetcode;

    //
    // Call the stack to allow it to perform any processing needing done.
    //
    USBHCDMain();

    //
    // See if we need to do anything here.
    //
    if(g_eState == STATE_DEVICE_ENUM)
    {
        //
        // The device is available.  Try to open its root directory just
        // to make sure it is accessible.
        //
        bRetcode = FileIsDrivePresent(1);

        if(bRetcode)
        {
            //
            // The USB drive is accessible so dump a message and set the state
            // to indicate that the device is ready for use.
            //
            UARTprintf("Opened root directory - USB drive present.\n");
            RendererSetAlert("USB drive\ndetected.", 200);
            g_eState = STATE_DEVICE_READY;
        }
    }
}
Esempio n. 2
0
//*****************************************************************************
//
// This is the callback from the MSC driver.
//
// \param ulInstance is the driver instance which is needed when communicating
// with the driver.
// \param ulEvent is one of the events defined by the driver.
// \param pvData is a pointer to data passed into the initial call to register
// the callback.
//
// This function handles callback events from the MSC driver.  The only events
// currently handled are the MSC_EVENT_OPEN and MSC_EVENT_CLOSE.  This allows
// the main routine to know when an MSC device has been detected and
// enumerated and when an MSC device has been removed from the system.
//
// \return Returns \e true on success or \e false on failure.
//
//*****************************************************************************
void
MSCCallback(unsigned long ulInstance, unsigned long ulEvent, void *pvData)
{
    //
    // Determine the event.
    //
    switch(ulEvent)
    {
        //
        // Called when the device driver has successfully enumerated an MSC
        // device.
        //
        case MSC_EVENT_OPEN:
        {
            //
            // Mount the USB flash stick as logical drive 1 in the file system.
            //
            FileMountUSB(true);

            //
            // Proceed to the enumeration state.
            //
            g_eState = STATE_DEVICE_ENUM;

            break;
        }

        //
        // Called when the device driver has been unloaded due to error or
        // the device is no longer present.
        //
        case MSC_EVENT_CLOSE:
        {
            //
            // Remove the USB stick from the file system.
            //
            FileMountUSB(false);

            //
            // Close our MSC drive instance.
            //
            USBHMSCDriveClose(g_ulMSCInstance);
            g_ulMSCInstance = 0;

            //
            // Go back to the "no device" state and wait for a new connection.
            //
            g_eState = STATE_NO_DEVICE;
            RendererSetAlert("USB drive\nremoved.", 200);

            break;
        }

        default:
        {
            break;
        }
    }
}
Esempio n. 3
0
//*****************************************************************************
//
// Calls the USB host stack tick function.
//
// This function is called periodically to allow the USB host stack to
// process any outstanding items.
//
// \return None.
//
//*****************************************************************************
void
ScopeUSBHostTick(void)
{
    tBoolean bRetcode;

    //
    // Call the stack to allow it to perform any processing needing done.
    //
    USBHCDMain();

    //
    // See if we need to do anything here.
    //
    if(g_eState == STATE_DEVICE_ENUM)
    {
        //
        // Take it easy on the Mass storage device if it is slow to
        // start up after connecting.
        //
        if(USBHMSCDriveReady(g_ulMSCInstance) != 0)
        {
            //
            // Wait about 500ms before attempting to check if the
            // device is ready again.
            //
            SysCtlDelay(SysCtlClockGet()/(3*2));
        }
        else
        {
            //
            // The device is available.  Try to open its root directory just
            // to make sure it is accessible.
            //
            bRetcode = FileIsDrivePresent(1);

            if(bRetcode)
            {
                //
                // The USB drive is accessible so dump a message and set the state
                // to indicate that the device is ready for use.
                //
                UARTprintf("Opened root directory - USB drive present.\n");
                RendererSetAlert("USB drive\ndetected.", 200);
                g_eState = STATE_DEVICE_READY;
            }
        }
    }
}