Beispiel #1
0
/**
 *  Add frame buffer to audio sending list.
 *  \param pAuds   Pointer to AUDDStream instance.
 *  \param pBuffer Pointer to data frame to send.
 *  \param wLength Frame size in bytes.
 *  \return USBD_STATUS_SUCCESS if the transfer is started successfully;
 *          otherwise an error code.
 */
uint32_t AUDDStream_Write(AUDDStream *pAuds, void* pBuffer, uint16_t wLength)
{
    if (pAuds->bEndpointIn == 0)
        return USBRC_STATE_ERR;

    return USBD_HAL_Write(pAuds->bEndpointIn,
                          pBuffer, wLength);
}
Beispiel #2
0
/**
 * Sends data through a USB endpoint. Sets up the transfer descriptor,
 * writes one or two data payloads (depending on the number of FIFO bank
 * for the endpoint) and then starts the actual transfer. The operation is
 * complete when all the data has been sent.
 *
 * *If the size of the buffer is greater than the size of the endpoint
 *  (or twice the size if the endpoint has two FIFO banks), then the buffer
 *  must be kept allocated until the transfer is finished*. This means that
 *  it is not possible to declare it on the stack (i.e. as a local variable
 *  of a function which returns after starting a transfer).
 *
 * \param bEndpoint Endpoint number.
 * \param pData Pointer to a buffer with the data to send.
 * \param dLength Size of the data buffer.
 * \param fCallback Optional callback function to invoke when the transfer is
 *        complete.
 * \param pArgument Optional argument to the callback function.
 * \return USBD_STATUS_SUCCESS if the transfer has been started;
 *         otherwise, the corresponding error status code.
 */
uint8_t USBD_Write( uint8_t          bEndpoint,
                    const void       *pData,
                    uint32_t         dLength,
                    TransferCallback fCallback,
                    void             *pArgument )
{
    USBD_HAL_SetTransferCallback(bEndpoint, fCallback, pArgument);
    return USBD_HAL_Write(bEndpoint, pData, dLength);
}
Beispiel #3
0
/**
 *  Add frame buffer to audio sending list.
 *  \param pAudf   Pointer to AUDDSpeakerPhone instance.
 *  \param pBuffer Pointer to data frame to send.
 *  \param wLength Frame size in bytes.
 *  \return USBD_STATUS_SUCCESS if the transfer is started successfully;
 *          otherwise an error code.
 */
uint32_t AUDDSpeakerPhone_Write(AUDDSpeakerPhone *pAudf, void* pBuffer, uint16_t wLength)
{
    if (pAudf->pSpeaker == 0)
        return USBRC_PARAM_ERR;
    if (pAudf->pSpeaker->bEndpointIn == 0)
        return USBRC_STATE_ERR;

    return USBD_HAL_Write(pAudf->pSpeaker->bEndpointIn,
                          pBuffer, wLength);
}
Beispiel #4
0
/**
 * Sends data through a USB endpoint. Sets up the transfer descriptor,
 * writes one or two data payloads (depending on the number of FIFO bank
 * for the endpoint) and then starts the actual transfer. The operation is
 * complete when all the data has been sent.
 *
 * *If the size of the buffer is greater than the size of the endpoint
 *  (or twice the size if the endpoint has two FIFO banks), then the buffer
 *  must be kept allocated until the transfer is finished*. This means that
 *  it is not possible to declare it on the stack (i.e. as a local variable
 *  of a function which returns after starting a transfer).
 *
 * \param bEndpoint Endpoint number.
 * \param pData Pointer to a buffer with the data to send.
 * \param dLength Size of the data buffer.
 * \param fCallback Optional callback function to invoke when the transfer is
 *        complete.
 * \param pArgument Optional argument to the callback function.
 * \return USBD_STATUS_SUCCESS if the transfer has been started;
 *         otherwise, the corresponding error status code.
 */
uint8_t USBD_Write( uint8_t          bEndpoint,
                    const void       *pData,
                    uint32_t         dLength,
                    TransferCallback fCallback,
                    void             *pArgument )
{
    //USBD_HAL_SetTransferCallback(bEndpoint, fCallback, pArgument);
	if(USBD_HAL_SetTransferCallback(bEndpoint, fCallback, pArgument) == USBD_STATUS_LOCKED) {
    	return USBD_STATUS_LOCKED;
    }

    return USBD_HAL_Write(bEndpoint, pData, dLength);
}