Exemplo n.º 1
0
/* Helper function to send EP0 setup packet. */
CyU3PReturnStatus_t
CyFxSendSetupRqt (
    uint8_t type,
    uint8_t request,
    uint16_t value,
    uint16_t index,
    uint16_t length,
    uint8_t *buffer_p)
{
    CyU3PUsbHostEpStatus_t epStatus;
    CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

    glSetupPkt[0] = type;
    glSetupPkt[1] = request;
    glSetupPkt[2] = CY_U3P_GET_LSB(value);
    glSetupPkt[3] = CY_U3P_GET_MSB(value);
    glSetupPkt[4] = CY_U3P_GET_LSB(index);
    glSetupPkt[5] = CY_U3P_GET_MSB(index);
    glSetupPkt[6] = CY_U3P_GET_LSB(length);
    glSetupPkt[7] = CY_U3P_GET_MSB(length);

    status = CyU3PUsbHostSendSetupRqt (glSetupPkt, buffer_p);
    if (status != CY_U3P_SUCCESS)
    {
        return status;
    }
    status = CyU3PUsbHostEpWaitForCompletion (0, &epStatus,
             CY_FX_HOST_EP0_WAIT_TIMEOUT);

    return status;
}
/* Helper function to format the setup packet. */
static void
CyFxFormatSetupRqt (uint8_t *ptr,
                  uint8_t type,
                  uint8_t request,
                  uint16_t value,
                  uint16_t index,
                  uint16_t length)
{
    ptr[0] = type;
    ptr[1] = request;
    ptr[2] = CY_U3P_GET_LSB(value);
    ptr[3] = CY_U3P_GET_MSB(value);
    ptr[4] = CY_U3P_GET_LSB(index);
    ptr[5] = CY_U3P_GET_MSB(index);
    ptr[6] = CY_U3P_GET_LSB(length);
    ptr[7] = CY_U3P_GET_MSB(length);
}