stm32/usb: Change CDC tx/rx funcs to take CDC state, not usbdev state.
This commit is contained in:
parent
68271a27e6
commit
91bca340ec
@ -186,7 +186,7 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
|
|||||||
|
|
||||||
buffptr = cdc->tx_buf_ptr_out_shadow;
|
buffptr = cdc->tx_buf_ptr_out_shadow;
|
||||||
|
|
||||||
if (USBD_CDC_TransmitPacket(cdc->base.usbd, buffsize, &cdc->tx_buf[buffptr]) == USBD_OK) {
|
if (USBD_CDC_TransmitPacket(&cdc->base, buffsize, &cdc->tx_buf[buffptr]) == USBD_OK) {
|
||||||
cdc->tx_buf_ptr_out_shadow += buffsize;
|
cdc->tx_buf_ptr_out_shadow += buffsize;
|
||||||
if (cdc->tx_buf_ptr_out_shadow == USBD_CDC_TX_DATA_SIZE) {
|
if (cdc->tx_buf_ptr_out_shadow == USBD_CDC_TX_DATA_SIZE) {
|
||||||
cdc->tx_buf_ptr_out_shadow = 0;
|
cdc->tx_buf_ptr_out_shadow = 0;
|
||||||
@ -226,7 +226,7 @@ int8_t usbd_cdc_receive(usbd_cdc_state_t *cdc_in, size_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initiate next USB packet transfer
|
// initiate next USB packet transfer
|
||||||
USBD_CDC_ReceivePacket(cdc->base.usbd, cdc->rx_packet_buf);
|
USBD_CDC_ReceivePacket(&cdc->base, cdc->rx_packet_buf);
|
||||||
|
|
||||||
return USBD_OK;
|
return USBD_OK;
|
||||||
}
|
}
|
||||||
|
@ -162,8 +162,8 @@ int USBD_SelectMode(usbd_cdc_msc_hid_state_t *usbd, uint32_t mode, USBD_HID_Mode
|
|||||||
// returns the current usb mode
|
// returns the current usb mode
|
||||||
uint8_t USBD_GetMode(usbd_cdc_msc_hid_state_t *usbd);
|
uint8_t USBD_GetMode(usbd_cdc_msc_hid_state_t *usbd);
|
||||||
|
|
||||||
uint8_t USBD_CDC_ReceivePacket(usbd_cdc_msc_hid_state_t *usbd, uint8_t *buf);
|
uint8_t USBD_CDC_ReceivePacket(usbd_cdc_state_t *cdc, uint8_t *buf);
|
||||||
uint8_t USBD_CDC_TransmitPacket(usbd_cdc_msc_hid_state_t *usbd, size_t len, const uint8_t *buf);
|
uint8_t USBD_CDC_TransmitPacket(usbd_cdc_state_t *cdc, size_t len, const uint8_t *buf);
|
||||||
|
|
||||||
static inline void USBD_MSC_RegisterStorage(usbd_cdc_msc_hid_state_t *usbd, USBD_StorageTypeDef *fops) {
|
static inline void USBD_MSC_RegisterStorage(usbd_cdc_msc_hid_state_t *usbd, USBD_StorageTypeDef *fops) {
|
||||||
usbd->MSC_BOT_ClassData.bdev_ops = fops;
|
usbd->MSC_BOT_ClassData.bdev_ops = fops;
|
||||||
|
@ -1111,13 +1111,13 @@ uint8_t *USBD_CDC_MSC_HID_GetDeviceQualifierDescriptor(USBD_HandleTypeDef *pdev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// data received on non-control OUT endpoint
|
// data received on non-control OUT endpoint
|
||||||
uint8_t USBD_CDC_TransmitPacket(usbd_cdc_msc_hid_state_t *usbd, size_t len, const uint8_t *buf) {
|
uint8_t USBD_CDC_TransmitPacket(usbd_cdc_state_t *cdc, size_t len, const uint8_t *buf) {
|
||||||
if (usbd->cdc->tx_in_progress == 0) {
|
if (cdc->tx_in_progress == 0) {
|
||||||
// transmit next packet
|
// transmit next packet
|
||||||
USBD_LL_Transmit(usbd->pdev, CDC_IN_EP, (uint8_t*)buf, len);
|
USBD_LL_Transmit(cdc->usbd->pdev, cdc->in_ep, (uint8_t*)buf, len);
|
||||||
|
|
||||||
// Tx transfer in progress
|
// Tx transfer in progress
|
||||||
usbd->cdc->tx_in_progress = 1;
|
cdc->tx_in_progress = 1;
|
||||||
return USBD_OK;
|
return USBD_OK;
|
||||||
} else {
|
} else {
|
||||||
return USBD_BUSY;
|
return USBD_BUSY;
|
||||||
@ -1125,17 +1125,17 @@ uint8_t USBD_CDC_TransmitPacket(usbd_cdc_msc_hid_state_t *usbd, size_t len, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
// prepare OUT endpoint for reception
|
// prepare OUT endpoint for reception
|
||||||
uint8_t USBD_CDC_ReceivePacket(usbd_cdc_msc_hid_state_t *usbd, uint8_t *buf) {
|
uint8_t USBD_CDC_ReceivePacket(usbd_cdc_state_t *cdc, uint8_t *buf) {
|
||||||
// Suspend or Resume USB Out process
|
// Suspend or Resume USB Out process
|
||||||
|
|
||||||
#if !USBD_SUPPORT_HS_MODE
|
#if !USBD_SUPPORT_HS_MODE
|
||||||
if (usbd->pdev->dev_speed == USBD_SPEED_HIGH) {
|
if (cdc->usbd->pdev->dev_speed == USBD_SPEED_HIGH) {
|
||||||
return USBD_FAIL;
|
return USBD_FAIL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Prepare Out endpoint to receive next packet
|
// Prepare Out endpoint to receive next packet
|
||||||
USBD_LL_PrepareReceive(usbd->pdev, CDC_OUT_EP, buf, usbd_cdc_max_packet(usbd->pdev));
|
USBD_LL_PrepareReceive(cdc->usbd->pdev, CDC_OUT_EP, buf, usbd_cdc_max_packet(cdc->usbd->pdev));
|
||||||
|
|
||||||
return USBD_OK;
|
return USBD_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user