Skip to content

Commit 21cec66

Browse files
facchinmpennam
authored andcommitted
STM32: allow high speed USB endpoints
1 parent 73b7e45 commit 21cec66

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

drivers/include/drivers/USBCDC.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class AsyncOp;
3333
* @{
3434
*/
3535

36+
#define CDC_MAX_PACKET_SIZE 64
37+
3638
class USBCDC: public USBDevice {
3739
public:
3840

@@ -219,13 +221,13 @@ class USBCDC: public USBDevice {
219221

220222
OperationList<AsyncWrite> _tx_list;
221223
bool _tx_in_progress;
222-
uint8_t _tx_buffer[64];
224+
uint8_t _tx_buffer[CDC_MAX_PACKET_SIZE];
223225
uint8_t *_tx_buf;
224226
uint32_t _tx_size;
225227

226228
OperationList<AsyncRead> _rx_list;
227229
bool _rx_in_progress;
228-
uint8_t _rx_buffer[64];
230+
uint8_t _rx_buffer[CDC_MAX_PACKET_SIZE];
229231
uint8_t *_rx_buf;
230232
uint32_t _rx_size;
231233
};

drivers/source/usb/USBCDC.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ static const uint8_t cdc_line_coding_default[7] = {0x80, 0x25, 0x00, 0x00, 0x00,
3434
#define CLS_DTR (1 << 0)
3535
#define CLS_RTS (1 << 1)
3636

37-
#define CDC_MAX_PACKET_SIZE 64
38-
3937
class USBCDC::AsyncWrite: public AsyncOp {
4038
public:
4139
AsyncWrite(USBCDC *serial, uint8_t *buf, uint32_t size):

targets/TARGET_STM/USBPhy_STM32.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,21 @@
2828
#define IDX_TO_EP(idx) (((idx) >> 1)|((idx) & 1) << 7)
2929

3030
/* endpoint defines */
31-
#define NUM_ENDPOINTS 4
31+
32+
#if (MBED_CONF_TARGET_USB_SPEED == USE_USB_OTG_HS)
33+
34+
#define NUM_ENDPOINTS 6
35+
#define MAX_PACKET_SIZE_NON_ISO 512
36+
#define MAX_PACKET_SIZE_ISO 1023 // Spec can go up to 1023, only ram for this though
37+
38+
#else
39+
40+
#define NUM_ENDPOINTS 4
3241
#define MAX_PACKET_SIZE_NON_ISO 64
3342
#define MAX_PACKET_SIZE_ISO (256 + 128) // Spec can go up to 1023, only ram for this though
3443

44+
#endif
45+
3546
static const uint32_t tx_ep_sizes[NUM_ENDPOINTS] = {
3647
MAX_PACKET_SIZE_NON_ISO,
3748
MAX_PACKET_SIZE_NON_ISO,
@@ -329,8 +340,11 @@ void USBPhyHw::init(USBPhyEvents *events)
329340
total_bytes += fifo_size;
330341
}
331342

343+
#if (MBED_CONF_TARGET_USB_SPEED != USE_USB_OTG_HS)
332344
/* 1.25 kbytes */
333345
MBED_ASSERT(total_bytes <= 1280);
346+
#endif
347+
334348
#endif
335349

336350
// Configure interrupt vector

0 commit comments

Comments
 (0)