Skip to content

Commit

Permalink
stm32/usb: Add support for 2xVCP on L0, L432 and WB MCUs.
Browse files Browse the repository at this point in the history
There are a maximum of 8 USB endpoints and each has 2 buffer slots
(in/out).  This commit add support for up to 8 endpoints and adds FIFO
configuration for USB profiles with 2xVCP on MCUs that have device-only USB
peripherals.

Tested on NUCLEO_WB55 in 2xVCP, 2xVCP+MSC and 2xVCP+MSC+HID mode.

Signed-off-by: Damien George <[email protected]>
  • Loading branch information
dpgeorge committed Jun 16, 2020
1 parent da99e0f commit 289be6b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions ports/stm32/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,29 @@ pyb_usb_storage_medium_t pyb_usb_storage_medium = PYB_USB_STORAGE_MEDIUM_NONE;
// Units of FIFO size arrays below are 4x 16-bit words = 8 bytes
// There are 512x 16-bit words it total to use here (when using PCD_SNG_BUF)

// EP0(out), EP0(in), MSC/HID(out), MSC/HID(in), unused, CDC_CMD(in), CDC_DATA(out), CDC_DATA(in)
STATIC const uint8_t usbd_fifo_size_cdc1[] = {16, 16, 16, 16, 0, 16, 16, 16};
STATIC const uint8_t usbd_fifo_size_cdc1[USBD_PMA_NUM_FIFO] = {
16, 16, 16, 16, // EP0(out), EP0(in), MSC/HID(out), MSC/HID(in)
0, 16, 16, 16, // unused, CDC_CMD(in), CDC_DATA(out), CDC_DATA(in)
0, 0, 0, 0, 0, 0, 0, 0, // 8x unused
};

#if MICROPY_HW_USB_CDC_NUM >= 2
STATIC const uint8_t usbd_fifo_size_cdc2[USBD_PMA_NUM_FIFO] = {
8, 8, 16, 16, // EP0(out), EP0(in), MSC/HID(out), MSC/HID(in)
0, 8, 12, 12, // unused, CDC_CMD(in), CDC_DATA(out), CDC_DATA(in)
0, 8, 12, 12, // unused, CDC2_CMD(in), CDC2_DATA(out), CDC2_DATA(in)
0, 0, 0, 0, // 4x unused
};

// RX; EP0(in), MSC/HID, CDC_CMD, CDC_DATA, CDC2_CMD/HID, CDC2_DATA, HID
STATIC const uint8_t usbd_fifo_size_cdc2_msc_hid[USBD_PMA_NUM_FIFO] = {
8, 8, 16, 16, // EP0(out), EP0(in), MSC/HID(out), MSC/HID(in)
0, 8, 8, 8, // unused, CDC_CMD(in), CDC_DATA(out), CDC_DATA(in)
0, 8, 8, 8, // unused, CDC2_CMD(in), CDC2_DATA(out), CDC2_DATA(in)
8, 8, // HID(out), HID(in)
0, 0, // 2x unused
};
#endif

#else

Expand Down
2 changes: 1 addition & 1 deletion ports/stm32/usbd_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

// For MCUs with a device-only USB peripheral
#define USBD_PMA_RESERVE (64)
#define USBD_PMA_NUM_FIFO (8)
#define USBD_PMA_NUM_FIFO (16) // Maximum 8 endpoints, 2 FIFOs each

// For MCUs with multiple OTG USB peripherals
#define USBD_FS_NUM_TX_FIFO (6)
Expand Down

0 comments on commit 289be6b

Please sign in to comment.