Skip to content

Commit db7954b

Browse files
committed
STM32: allow high speed USB endpoints
1 parent 6068428 commit db7954b

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
@@ -29,10 +29,21 @@
2929
#define IDX_TO_EP(idx) (((idx) >> 1)|((idx) & 1) << 7)
3030

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

45+
#endif
46+
3647
static const uint32_t tx_ep_sizes[NUM_ENDPOINTS] = {
3748
MAX_PACKET_SIZE_NON_ISO,
3849
MAX_PACKET_SIZE_NON_ISO,
@@ -333,8 +344,11 @@ void USBPhyHw::init(USBPhyEvents *events)
333344
total_bytes += fifo_size;
334345
}
335346

347+
#if (MBED_CONF_TARGET_USB_SPEED != USE_USB_OTG_HS)
336348
/* 1.25 kbytes */
337349
MBED_ASSERT(total_bytes <= 1280);
350+
#endif
351+
338352
#endif
339353

340354
// Configure interrupt vector

0 commit comments

Comments
 (0)