本文整理汇总了C++中USBD_LL_PrepareReceive函数的典型用法代码示例。如果您正苦于以下问题:C++ USBD_LL_PrepareReceive函数的具体用法?C++ USBD_LL_PrepareReceive怎么用?C++ USBD_LL_PrepareReceive使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了USBD_LL_PrepareReceive函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: USBD_CDC_ReceivePacket
/**
* @brief USBD_CDC_ReceivePacket
* prepare OUT Endpoint for reception
* @param pdev: device instance
* @retval status
*/
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev)
{
USBD_CDC_HandleTypeDef *hcdc = pdev->pClassData;
/* Suspend or Resume USB Out process */
if(pdev->pClassData != NULL)
{
if(pdev->dev_speed == USBD_SPEED_HIGH )
{
/* Prepare Out endpoint to receive next packet */
USBD_LL_PrepareReceive(pdev,
CDC_OUT_EP,
hcdc->RxBuffer,
CDC_DATA_HS_OUT_PACKET_SIZE);
}
else
{
/* Prepare Out endpoint to receive next packet */
USBD_LL_PrepareReceive(pdev,
CDC_OUT_EP,
hcdc->RxBuffer,
CDC_DATA_FS_OUT_PACKET_SIZE);
}
return USBD_OK;
}
else
{
return USBD_FAIL;
}
}
示例2: SCSI_ProcessWrite
// Handle write process
// input:
// pdev - pointer to the USB device handle
// lun - logical unit number
static int8_t SCSI_ProcessWrite(USBD_HandleTypeDef *pdev, uint8_t lun) {
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData;
uint32_t len;
len = MIN(hmsc->scsi_blk_len,MSC_MEDIA_PACKET);
if (((USBD_StorageTypeDef *)pdev->pUserData)->Write(lun,hmsc->bot_data,hmsc->scsi_blk_addr / hmsc->scsi_blk_size,len / hmsc->scsi_blk_size) < 0) {
SCSI_SenseCode(pdev,lun,HARDWARE_ERROR,WRITE_FAULT);
return -1;
}
hmsc->scsi_blk_addr += len;
hmsc->scsi_blk_len -= len;
// case 12 : Ho = Do
hmsc->csw.dDataResidue -= len;
if (hmsc->scsi_blk_len == 0) {
MSC_BOT_SendCSW(pdev,USBD_CSW_CMD_PASSED);
} else {
// Prepare endpoint to receive next packet
USBD_LL_PrepareReceive(pdev,MSC_EPOUT_ADDR,hmsc->bot_data,MIN(hmsc->scsi_blk_len,MSC_MEDIA_PACKET));
}
return 0;
}
示例3: USBD_CDC_ReceivePacket
/**
* @brief USBD_CDC_ReceivePacket
* prepare OUT Endpoint for reception
* @param pdev: device instance
* @retval status
*/
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev, uint8_t endpoint_pair)
{
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*) pdev->pClassData;
/* Suspend or Resume USB Out process */
if(pdev->pClassData != NULL)
{
// Select Endpoint
USBD_CDC_EP_HandleTypeDef* hEP_Rx;
uint8_t out_ep;
if (endpoint_pair == CDC_OUT_EP) {
hEP_Rx = &hcdc->CDC_Rx;
out_ep = CDC_OUT_EP;
} else if (endpoint_pair == ODRIVE_OUT_EP) {
hEP_Rx = &hcdc->ODRIVE_Rx;
out_ep = ODRIVE_OUT_EP;
} else {
return USBD_FAIL;
}
/* Prepare Out endpoint to receive next packet */
USBD_LL_PrepareReceive(pdev,
out_ep,
hEP_Rx->Buffer,
pdev->dev_speed == USBD_SPEED_HIGH ? CDC_DATA_HS_OUT_PACKET_SIZE : CDC_DATA_FS_OUT_PACKET_SIZE);
return USBD_OK;
}
else
{
return USBD_FAIL;
}
}
示例4: USBD_HID_DataOut_impl
uint8_t USBD_HID_DataOut_impl (USBD_HandleTypeDef *pdev,
uint8_t epnum, uint8_t* buffer)
{
// only the data hid endpoint will receive data
if (epnum == 2) {
// prepare receiving the next chunk (masked time)
USBD_LL_PrepareReceive(pdev, HID_EPOUT_ADDR , HID_EPOUT_SIZE);
// avoid troubles when an apdu has not been replied yet
if (G_io_apdu_media == IO_APDU_MEDIA_NONE) {
// add to the hid transport
switch(io_usb_hid_receive(io_usb_send_apdu_data, buffer, io_seproxyhal_get_ep_rx_size(HID_EPOUT_ADDR))) {
default:
break;
case IO_USB_APDU_RECEIVED:
G_io_apdu_media = IO_APDU_MEDIA_USB_HID; // for application code
G_io_apdu_state = APDU_USB_HID; // for next call to io_exchange
G_io_apdu_length = G_io_usb_hid_total_length;
break;
}
}
}
return USBD_OK;
}
示例5: USBD_HID_GetReportDescriptor_impl
uint8_t* USBD_HID_GetReportDescriptor_impl(uint16_t* len) {
switch (USBD_Device.request.wIndex&0xFF) {
case 0:
// very dirty work due to lack of callback when USB_HID_Init is called
USBD_LL_OpenEP(&USBD_Device,
0x81,
USBD_EP_TYPE_INTR,
8);
USBD_LL_OpenEP(&USBD_Device,
0x01,
USBD_EP_TYPE_INTR,
8);
/* Prepare Out endpoint to receive 1st packet */
USBD_LL_PrepareReceive(&USBD_Device, 0x01, 8);
*len = sizeof(HID_ReportDesc_kbd);
return (uint8_t*)HID_ReportDesc_kbd;
case 1:
*len = sizeof(HID_ReportDesc);
return (uint8_t*)HID_ReportDesc;
}
*len = 0;
return 0;
}
示例6: USBD_CtlReceiveStatus
/**
* @brief USBD_CtlReceiveStatus
* receive zero lzngth packet on the ctl pipe
* @param pdev: device instance
* @retval status
*/
USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev) {
/* Set EP0 State */
pdev->ep0_state = USBD_EP0_STATUS_OUT;
/* Start the transfer */
USBD_LL_PrepareReceive(pdev, 0,
NULL, 0);
return USBD_OK;
}
示例7: USBD_CDC_ReceivePacket
static uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev, unsigned index)
{
USBD_StatusTypeDef outcome;
outcome = USBD_LL_PrepareReceive(pdev, parameters[index].data_out_ep, (uint8_t *)context[index].OutboundBuffer, CDC_DATA_OUT_MAX_PACKET_SIZE);
context[index].OutboundTransferNeedsRenewal = (USBD_OK != outcome); /* set if the HAL was busy so that we know to retry it */
return outcome;
}
示例8: USBD_CtlPrepareRx
/**
* @brief USBD_CtlPrepareRx
* receive data on the ctl pipe
* @param pdev: device instance
* @param buff: pointer to data buffer
* @param len: length of data to be received
* @retval status
*/
USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint16_t len) {
/* Set EP0 State */
pdev->ep0_state = USBD_EP0_DATA_OUT;
pdev->ep_out[0].total_length = len;
pdev->ep_out[0].rem_length = len;
/* Start the transfer */
USBD_LL_PrepareReceive(pdev, 0, pbuf, len);
return USBD_OK;
}
示例9: USBD_CtlContinueRx
/**
* @brief USBD_CtlContinueRx
* continue receive data on the ctl pipe
* @param pdev: device instance
* @param buff: pointer to data buffer
* @param len: length of data to be received
* @retval status
*/
USBD_StatusTypeDef USBD_CtlContinueRx (USBD_HandleTypeDef *pdev,
uint8_t *pbuf,
uint16_t len)
{
USBD_LL_PrepareReceive (pdev,
0,
pbuf,
len);
return USBD_OK;
}
示例10: USBD_CDC_HID_Init
/**
* @brief USBD_CDC_HID_Init
* Initialize the CDC interface
* @param pdev: device instance
* @param cfgidx: Configuration index
* @retval status
*/
static uint8_t USBD_CDC_HID_Init (USBD_HandleTypeDef *pdev,
uint8_t cfgidx)
{
pdev->pClassData = &cdc_hid;
USBD_CDC_HID_HandleTypeDef *handle = (USBD_CDC_HID_HandleTypeDef*) pdev->pClassData;
NOT_USED(cfgidx);
uint8_t ret = 0;
/* Open EP IN */
USBD_LL_OpenEP(pdev,
CDC_IN_EP,
USBD_EP_TYPE_BULK,
CDC_DATA_FS_IN_PACKET_SIZE);
/* Open EP OUT */
USBD_LL_OpenEP(pdev,
CDC_OUT_EP,
USBD_EP_TYPE_BULK,
CDC_DATA_FS_OUT_PACKET_SIZE);
/* Open Command IN EP */
USBD_LL_OpenEP(pdev,
CDC_CMD_EP,
USBD_EP_TYPE_INTR,
CDC_CMD_PACKET_SIZE);
/* Init Xfer states */
handle->cdcState = CDC_IDLE;
/* Prepare Out endpoint to receive next packet */
USBD_LL_PrepareReceive(pdev,
CDC_OUT_EP,
handle->cdcRX,
CDC_DATA_FS_OUT_PACKET_SIZE);
#ifdef USE_USB_HID
unsigned int reportSize = 0;
handle->hidReportDesc = USB_GetHIDReportDesc(&reportSize);
handle->hidReportDescSize = (uint16_t)reportSize;
/* Open HID EP IN - even if we're not using it */
USBD_LL_OpenEP(pdev,
HID_IN_EP,
USBD_EP_TYPE_INTR,
HID_DATA_IN_PACKET_SIZE);
handle->hidState = HID_IDLE;
#endif
return ret;
}
示例11: MSC_BOT_Reset
/**
* @brief MSC_BOT_Reset
* Reset the BOT Machine
* @param pdev: device instance
* @retval None
*/
void MSC_BOT_Reset (USBD_HandleTypeDef *pdev)
{
USBD_MSC_BOT_HandleTypeDef *hmsc = pdev->pClassData;
hmsc->bot_state = USBD_BOT_IDLE;
hmsc->bot_status = USBD_BOT_STATUS_RECOVERY;
/* Prapare EP to Receive First BOT Cmd */
USBD_LL_PrepareReceive (pdev,
MSC_EPOUT_ADDR,
(uint8_t *)&hmsc->cbw,
USBD_BOT_CBW_LENGTH);
}
示例12: SCSI_Write10
// Process SCSI WRITE10 command
// input:
// pdev - pointer to the USB device handle
// lun - logical unit number
// params - pointer to the buffer with command parameters
static int8_t SCSI_Write10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params) {
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData;
if (hmsc->bot_state == USBD_BOT_IDLE) {
// case 8 : Hi <> Do
if (hmsc->cbw.bmFlags & 0x80) {
SCSI_SenseCode(pdev,hmsc->cbw.bLUN,ILLEGAL_REQUEST,INVALID_CDB);
return -1;
}
// Check whether media is ready
if (((USBD_StorageTypeDef *)pdev->pUserData)->IsReady(lun) != 0) {
SCSI_SenseCode(pdev,lun,NOT_READY,MEDIUM_NOT_PRESENT);
return -1;
}
// Check if media is write-protected
if (((USBD_StorageTypeDef *)pdev->pUserData)->IsWriteProtected(lun) != 0) {
SCSI_SenseCode(pdev,lun,NOT_READY,WRITE_PROTECTED);
return -1;
}
hmsc->scsi_blk_addr = (params[2] << 24) | (params[3] << 16) | (params[4] << 8) | params[5];
hmsc->scsi_blk_len = (params[7] << 8) | params[8];
// Check if LBA address is in the right range
if (SCSI_CheckAddressRange(pdev,lun,hmsc->scsi_blk_addr,hmsc->scsi_blk_len) < 0) return -1;
hmsc->scsi_blk_addr *= hmsc->scsi_blk_size;
hmsc->scsi_blk_len *= hmsc->scsi_blk_size;
// cases 3,11,13 : Hn,Ho <> D0
if (hmsc->cbw.dDataLength != hmsc->scsi_blk_len) {
SCSI_SenseCode(pdev,hmsc->cbw.bLUN,ILLEGAL_REQUEST,INVALID_CDB);
return -1;
}
// Prepare endpoint to receive first data packet
hmsc->bot_state = USBD_BOT_DATA_OUT;
USBD_LL_PrepareReceive(pdev,MSC_EPOUT_ADDR,hmsc->bot_data,MIN(hmsc->scsi_blk_len,MSC_MEDIA_PACKET));
} else {
// Write Process ongoing
return SCSI_ProcessWrite(pdev,lun);
}
return 0;
}
示例13: USBD_AUDIO_DataOut
/**
* @brief USBD_AUDIO_DataOut
* handle data OUT Stage
* @param pdev: device instance
* @param epnum: endpoint index
* @retval status
*/
static uint8_t USBD_AUDIO_DataOut (USBD_HandleTypeDef *pdev,
uint8_t epnum)
{
USBD_AUDIO_HandleTypeDef *haudio;
haudio = (USBD_AUDIO_HandleTypeDef*) pdev->pClassData;
if (epnum == AUDIO_OUT_EP)
{
/* Increment the Buffer pointer or roll it back when all buffers are full */
haudio->wr_ptr += AUDIO_OUT_PACKET;
if (haudio->wr_ptr == AUDIO_TOTAL_BUF_SIZE)
{/* All buffers are full: roll back */
haudio->wr_ptr = 0;
if(haudio->offset == AUDIO_OFFSET_UNKNOWN)
{
((USBD_AUDIO_ItfTypeDef *)pdev->pUserData)->AudioCmd(&haudio->buffer[0],
AUDIO_TOTAL_BUF_SIZE/2,
AUDIO_CMD_START);
haudio->offset = AUDIO_OFFSET_NONE;
}
}
if(haudio->rd_enable == 0)
{
if (haudio->wr_ptr == (AUDIO_TOTAL_BUF_SIZE / 2))
{
haudio->rd_enable = 1;
}
}
/* Prepare Out endpoint to receive next audio packet */
USBD_LL_PrepareReceive(pdev,
AUDIO_OUT_EP,
&haudio->buffer[haudio->wr_ptr],
AUDIO_OUT_PACKET);
}
return USBD_OK;
}
示例14: MSC_BOT_Abort
static void MSC_BOT_Abort (USBD_HandleTypeDef *pdev)
{
USBD_MSC_BOT_HandleTypeDef *hmsc = &((usbd_cdc_msc_hid_state_t*)pdev->pClassData)->MSC_BOT_ClassData;
if ((hmsc->cbw.bmFlags == 0) &&
(hmsc->cbw.dDataLength != 0) &&
(hmsc->bot_status == USBD_BOT_STATUS_NORMAL) )
{
USBD_LL_StallEP(pdev, MSC_OUT_EP );
}
USBD_LL_StallEP(pdev, MSC_IN_EP);
if(hmsc->bot_status == USBD_BOT_STATUS_ERROR)
{
USBD_LL_PrepareReceive (pdev,
MSC_OUT_EP,
(uint8_t *)&hmsc->cbw,
USBD_BOT_CBW_LENGTH);
}
}
示例15: MSC_BOT_Abort
static void MSC_BOT_Abort (USBD_HandleTypeDef *pdev)
{
USBD_MSC_BOT_HandleTypeDef *hmsc = pdev->pClassData;
if ((hmsc->cbw.bmFlags == 0) &&
(hmsc->cbw.dDataLength != 0) &&
(hmsc->bot_status == USBD_BOT_STATUS_NORMAL) )
{
USBD_LL_StallEP(pdev, MSC_EPOUT_ADDR );
}
USBD_LL_StallEP(pdev, MSC_EPIN_ADDR);
if(hmsc->bot_status == USBD_BOT_STATUS_ERROR)
{
USBD_LL_PrepareReceive (pdev,
MSC_EPOUT_ADDR,
(uint8_t *)&hmsc->cbw,
USBD_BOT_CBW_LENGTH);
}
}