Skip to content

Commit 3cf9b13

Browse files
9namesmathias-arm
authored andcommitted
sam3u2c: use MSC/CDC EPs for BULK if disabled
1 parent a98713a commit 3cf9b13

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

source/hic_hal/atmel/sam3u2c/usb_config.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,21 @@
430430
// </e>
431431
// </e>
432432

433-
#define USBD_BULK_ENABLE BULK_ENDPOINT //no endpts left
434-
#define USBD_BULK_EP_BULKIN 7
435-
#define USBD_BULK_EP_BULKOUT 8
433+
#define USBD_BULK_ENABLE BULK_ENDPOINT
434+
// We don't have enough endpoints for BULK unless MSC or CDC are disabled.
435+
// MSC is the best choice, since this is only useful in the fixed target IF config and we can still upload firmware via DAP.
436+
// We'll still want MSC for the BL though, but in that case BULK isn't useful anyway.
437+
#if USBD_MSC_ENABLE == 0
438+
#define USBD_BULK_EP_BULKIN 1 // Use the MSC endpoints for BULK
439+
#define USBD_BULK_EP_BULKOUT 2
440+
#elif USBD_CDC_ACM_ENABLE == 0
441+
#define USBD_BULK_EP_BULKIN 5 // Use the CDC endpoints for BULK
442+
#define USBD_BULK_EP_BULKOUT 6
443+
#else
444+
#define USBD_BULK_EP_BULKIN 7 // Use non-existent endpoints to force an error
445+
#define USBD_BULK_EP_BULKOUT 8 // if BULK is enabled but MSC + CDC are still enabled
446+
#endif
447+
436448
#define USBD_BULK_WMAXPACKETSIZE 64
437449
#define USBD_BULK_HS_ENABLE 1
438450
#define USBD_BULK_HS_WMAXPACKETSIZE 512

0 commit comments

Comments
 (0)