Exemplo n.º 1
0
//*****************************************************************************
//
//! This function is used to retrieve a report from a HID device.
//!
//! \param psHIDInstance is the value that was returned from the call to
//! USBHHIDOpen().
//! \param ui32Interface is the interface to retrieve the report from.
//! \param pui8Data is the memory buffer to use to store the report.
//! \param ui32Size is the size in bytes of the buffer pointed to by
//! \e pui8Buffer.
//!
//! This function is used to retrieve a report from a USB pipe.  It is usually
//! called when the USB HID layer has detected a new data available in a USB
//! pipe.  The USB HID host device code will receive a
//! \b USB_EVENT_RX_AVAILABLE event when data is available, allowing the
//! callback function to retrieve the data.
//!
//! \return Returns the number of bytes read from report.
//
//*****************************************************************************
uint32_t
USBHHIDGetReport(tHIDInstance *psHIDInstance, uint32_t ui32Interface,
                 uint8_t *pui8Data, uint32_t ui32Size)
{
    //
    // Read the Data out.
    //
    ui32Size = USBHCDPipeReadNonBlocking(psHIDInstance->ui32IntInPipe,
                                         pui8Data, ui32Size);

    //
    // Return the number of bytes read from the interrupt in pipe.
    //
    return(ui32Size);
}
Exemplo n.º 2
0
static void USBHCDCInterruptCallback(uint32_t ulPipe, uint32_t ulEvent)
{
        uint32_t ulSize;
        //
        // Handles a request to schedule a new request on the interrupt IN
        // pipe.
        //
        if(ulEvent == USB_EVENT_SCHEDULER)
        {
            USBHCDPipeSchedule(ulPipe, SchedulePipeInterruptBuffer, 100);
        }

        //
        // Called when new data is available on the interrupt IN pipe.
        //
        if(ulEvent == USB_EVENT_RX_AVAILABLE)
        {
              //
              // If the callback exists then call it.
              //
              if(g_USBHCDCDevice.pfnCallback != 0)
              {
                  //
                  // Read the Data out.
                  //
                  ulSize = USBHCDPipeReadNonBlocking(ulPipe, SchedulePipeInterruptBuffer,
                                                 100);
                  //
                  // Call
                  //
                  g_USBHCDCDevice.pfnCallback(&g_USBHCDCDevice,
                                              CDC_EVENT_INTERRUPT,
                                              (void*)SchedulePipeInterruptBuffer,
                                              ulSize);


                  //
                  // Schedule another read
                  //
                  USBHCDPipeSchedule(ulPipe, SchedulePipeInterruptBuffer, 100);

                  //UARTprintf("USBHCDCInterruptCallback\n\r");
              }
        }
}
Exemplo n.º 3
0
//*****************************************************************************
//
//! This function is used to retrieve a report from a HID device.
//!
//! \param ulInstance is the value that was returned from the call to
//! USBHHIDOpen().
//! \param ulInterface is the interface to retrieve the report from.
//! \param pucData is the memory buffer to use to store the report.
//! \param ulSize is the size in bytes of the buffer pointed to by
//! \e pucBuffer.
//!
//! This function is used to retrieve a report from a USB pipe.  It is usually
//! called when the USB HID layer has detected a new data available in a USB
//! pipe.  The USB HID host device code will receive a
//! \b USB_EVENT_RX_AVAILABLE event when data is available, allowing the
//! callback function to retrieve the data.
//!
//! \return Returns the number of bytes read from report.
//
//*****************************************************************************
unsigned long
USBHHIDGetReport(unsigned long ulInstance,
                 unsigned long ulInterface,
                 unsigned char *pucData,
                 unsigned long ulSize)
{
    tHIDInstance *pHIDInstance;

    //
    // Cast the instance pointer to the correct type for ease of use.
    //
    pHIDInstance = (tHIDInstance *)ulInstance;

    //
    // Read the Data out.
    //
    ulSize = USBHCDPipeReadNonBlocking(pHIDInstance->ulIntInPipe, pucData,
                                       ulSize);

    //
    // Return the number of bytes read from the interrupt in pipe.
    //
    return(ulSize);
}