/** * Initialize Frame List for sending audio data. * \param pAudf Pointer to AUDDSpeakerPhone instance. * \param pListInit Pointer to the allocated list for audio write. * \param pDmaInit Pointer to the allocated DMA descriptors for autio write * (if DMA supported). * \param listSize Circular list size. * \param delaySize Start transfer after delaySize frames filled in. * \param callback Optional callback function for transfer. * \param argument Optional callback argument. * \return USBD_STATUS_SUCCESS if setup successfully; otherwise an error code. */ uint32_t AUDDSpeakerPhone_SetupWrite( AUDDSpeakerPhone *pAudf, void * pListInit, void * pDmaInit, uint16_t listSize, uint16_t delaySize, TransferCallback callback, void * argument) { uint32_t error; if (pAudf->pMicrophone == 0) return USBRC_PARAM_ERR; if (pAudf->pMicrophone->bEndpointIn == 0) return USBRC_STATE_ERR; error = USBD_HAL_SetupMblTransfer(pAudf->pMicrophone->bEndpointIn, pListInit, listSize, delaySize); if (error) return error; error = USBD_HAL_SetTransferCallback( pAudf->pMicrophone->bEndpointIn, callback, argument); return error; }
/** * Reads incoming data on an USB endpoint This methods sets the transfer * descriptor and activate the endpoint interrupt. The actual transfer is * then carried out by the endpoint interrupt handler. The Read operation * finishes either when the buffer is full, or a short packet (inferior to * endpoint maximum size) is received. * * *The buffer must be kept allocated until the transfer is finished*. * \param bEndpoint Endpoint number. * \param pData Pointer to a data buffer. * \param dLength Size of the data buffer in bytes. * \param fCallback Optional end-of-transfer callback function. * \param pArgument Optional argument to the callback function. * \return USBD_STATUS_SUCCESS if the read operation has been started; * otherwise, the corresponding error code. */ uint8_t USBD_Read(uint8_t bEndpoint, void *pData, uint32_t dLength, TransferCallback fCallback, void *pArgument) { USBD_HAL_SetTransferCallback(bEndpoint, fCallback, pArgument); return USBD_HAL_Read(bEndpoint, pData, dLength); }
/** * Reads incoming data on an USB endpoint This methods sets the transfer * descriptor and activate the endpoint interrupt. The actual transfer is * then carried out by the endpoint interrupt handler. The Read operation * finishes either when the buffer is full, or a short packet (inferior to * endpoint maximum size) is received. * * *The buffer must be kept allocated until the transfer is finished*. * \param bEndpoint Endpoint number. * \param pData Pointer to a data buffer. * \param dLength Size of the data buffer in bytes. * \param fCallback Optional end-of-transfer callback function. * \param pArgument Optional argument to the callback function. * \return USBD_STATUS_SUCCESS if the read operation has been started; * otherwise, the corresponding error code. */ uint8_t USBD_Read(uint8_t bEndpoint, 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_Read(bEndpoint, pData, dLength); }
/** * Initialize Frame List for sending audio data. * \param pAuds Pointer to AUDDStream instance. * \param pListInit Pointer to the allocated list for audio write. * \param pDmaInit Pointer to the allocated DMA descriptors for autio write * (if DMA supported). * \param listSize Circular list size. * \param delaySize Start transfer after delaySize frames filled in. * \param callback Optional callback function for transfer. * \param argument Optional callback argument. * \return USBD_STATUS_SUCCESS if setup successfully; otherwise an error code. */ uint32_t AUDDStream_SetupWrite( AUDDStream *pAuds, void * pListInit, void * pDmaInit, uint16_t listSize, uint16_t delaySize, TransferCallback callback, void * argument) { uint32_t error; if (pAuds->bEndpointIn == 0) return USBRC_STATE_ERR; error = USBD_HAL_SetupMblTransfer(pAuds->bEndpointIn, pListInit, listSize, delaySize); if (error) return error; error = USBD_HAL_SetTransferCallback(pAuds->bEndpointIn, callback, argument); return error; }