Browse Source

stm32/usb: Make CDC endpoint definitions private to core usbdev driver.

pull/3784/head
Damien George 7 years ago
parent
commit
68271a27e6
  1. 2
      ports/stm32/usbd_cdc_interface.c
  2. 6
      ports/stm32/usbdev/class/inc/usbd_cdc_msc_hid.h
  3. 9
      ports/stm32/usbdev/class/src/usbd_cdc_msc_hid.c

2
ports/stm32/usbd_cdc_interface.c

@ -165,7 +165,7 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
// doing other things and we must give it a chance to read our data.
if (cdc->tx_buf_ptr_wait_count < 500) {
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
if (USBx_INEP(CDC_IN_EP & 0x7f)->DIEPTSIZ & USB_OTG_DIEPTSIZ_XFRSIZ) {
if (USBx_INEP(cdc->base.in_ep & 0x7f)->DIEPTSIZ & USB_OTG_DIEPTSIZ_XFRSIZ) {
// USB in-endpoint is still reading the data
cdc->tx_buf_ptr_wait_count++;
return;

6
ports/stm32/usbdev/class/inc/usbd_cdc_msc_hid.h

@ -39,17 +39,13 @@
#define MSC_IN_EP (0x81)
#define MSC_OUT_EP (0x01)
// Need to define here for usbd_cdc_interface.c (it needs CDC_IN_EP)
#define CDC_IN_EP (0x83)
#define CDC_OUT_EP (0x03)
#define CDC_CMD_EP (0x82)
struct _usbd_cdc_msc_hid_state_t;
typedef struct {
struct _usbd_cdc_msc_hid_state_t *usbd; // The parent USB device
uint32_t ctl_packet_buf[CDC_DATA_MAX_PACKET_SIZE / 4]; // Force 32-bit alignment
uint8_t iface_num;
uint8_t in_ep;
uint8_t cur_request;
uint8_t cur_length;
volatile uint8_t tx_in_progress;

9
ports/stm32/usbdev/class/src/usbd_cdc_msc_hid.c

@ -61,6 +61,11 @@
#define MSC_IFACE_NUM_WITH_CDC (0)
#define HID_IFACE_NUM_WITH_CDC (0)
#define HID_IFACE_NUM_WITH_MSC (1)
#define CDC_IN_EP (0x83)
#define CDC_OUT_EP (0x03)
#define CDC_CMD_EP (0x82)
#define HID_IN_EP_WITH_CDC (0x81)
#define HID_OUT_EP_WITH_CDC (0x01)
#define HID_IN_EP_WITH_MSC (0x83)
@ -650,6 +655,10 @@ int USBD_SelectMode(usbd_cdc_msc_hid_state_t *usbd, uint32_t mode, USBD_HID_Mode
return -1;
}
if (usbd->usbd_mode & USBD_MODE_CDC) {
usbd->cdc->in_ep = CDC_IN_EP;
}
// configure the HID descriptor, if needed
if (usbd->usbd_mode & USBD_MODE_HID) {
uint8_t *hid_desc = usbd->hid->desc;

Loading…
Cancel
Save