Skip to content

Commit 61a4a8e

Browse files
mbrossardmathias-arm
authored andcommitted
sam3u2c: Use CMSIS-DAP v2 interface for sam3u2c_if project
Disabling CMSIS-DAP v1 interface for improved performance
1 parent 3cf9b13 commit 61a4a8e

File tree

5 files changed

+51
-25
lines changed

5 files changed

+51
-25
lines changed

docs/hic/sam3u2c.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Based on ATSAM3U2C chip ([Datasheet](https://ww1.microchip.com/downloads/en/Devi
44
- Cortex-M3 96 Mhz
55
- 128 KB Flash
66
- 36 KB RAM
7-
- High-speed USB 2.0 device controller: up to 7 bi-directional endpoints including EP0 (*)
7+
- High-speed USB 2.0 device controller: up to 7 endpoints including EP0 (*)
88
- LQFP100 packaging
99

1010
(*) "up to 7 bidirectional Endpoints" (source: Datasheet](https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-6430-32-bit-Cortex-M3-Microcontroller-SAM3U4-SAM3U2-SAM3U1_Datasheet.pdf))

projects.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ projects:
215215
sam3u2c_if:
216216
- *module_if
217217
- *module_hic_sam3u2c
218+
- records/usb/usb-bulk.yaml
219+
- records/board/sam3u2c_if.yaml
218220
- records/family/all_family.yaml
219221
stm32f072x8_if:
220222
- *module_if

records/board/sam3u2c_if.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
common:
2+
macros:
3+
- HID_ENDPOINT_DISABLE
4+
- MSC_ENDPOINT_DISABLE
5+
- DRAG_N_DROP_DISABLE

source/hic_hal/atmel/sam3u2c/DAP_config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ This information includes:
8383
/// This configuration settings is used to optimize the communication performance with the
8484
/// debugger and depends on the USB peripheral. Typical vales are 64 for Full-speed USB HID or WinUSB,
8585
/// 1024 for High-speed USB HID and 512 for High-speed USB WinUSB.
86-
#ifndef HID_ENDPOINT //HID end points currently set limits to 64
87-
#define DAP_PACKET_SIZE 512 ///< Specifies Packet Size in bytes.
88-
#else
86+
#if defined(HID_ENDPOINT) && !defined(HID_ENDPOINT_DISABLE) // HID end points currently set limits to 64
8987
#define DAP_PACKET_SIZE 64 ///< Specifies Packet Size in bytes.
88+
#else
89+
#define DAP_PACKET_SIZE 512 ///< Specifies Packet Size in bytes.
9090
#endif
9191

9292
/// Maximum Package Buffers for Command and Response data.

source/hic_hal/atmel/sam3u2c/usb_config.c

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,46 @@
8787
#endif
8888
#endif
8989

90+
#if (BULK_ENDPOINT)
91+
/* SAM3UC only has 7 endpoints, and as a consequence BULK_ENDPOINT cannot
92+
* be enabled at the same time as CDC_ENDPOINT and MSC_ENDPOINT.
93+
*/
94+
#if (CDC_ENDPOINT && MSC_ENDPOINT)
95+
#error "SAM3U2C does not have enough endpoints to support this configuration"
96+
#endif
97+
#if (CDC_ENDPOINT)
98+
#define USBD_HID_EP_INTOUT 0
99+
#define USBD_BULK_EP_BULKIN 1
100+
#define USBD_BULK_EP_BULKOUT 2
101+
#define USBD_HID_EP_INTIN 3
102+
#define USBD_CDC_ACM_EP_INTIN 4
103+
#define USBD_CDC_ACM_EP_BULKOUT 5
104+
#define USBD_CDC_ACM_EP_BULKIN 6
105+
#define USBD_MSC_EP_BULKIN 7 /* Unused */
106+
#define USBD_MSC_EP_BULKOUT 7 /* Unused */
107+
#else // !(CDC_ENDPOINT)
108+
#define USBD_MSC_EP_BULKIN 1
109+
#define USBD_MSC_EP_BULKOUT 2
110+
#define USBD_HID_EP_INTIN 3
111+
#define USBD_HID_EP_INTOUT 4
112+
#define USBD_BULK_EP_BULKOUT 5
113+
#define USBD_BULK_EP_BULKIN 6
114+
#define USBD_CDC_ACM_EP_INTIN 7 /* Unused */
115+
#define USBD_CDC_ACM_EP_BULKIN 7 /* Unused */
116+
#define USBD_CDC_ACM_EP_BULKOUT 7 /* Unused */
117+
#endif
118+
#else // !(BULK_ENDPOINT)
119+
#define USBD_HID_EP_INTOUT 0
120+
#define USBD_MSC_EP_BULKIN 1
121+
#define USBD_MSC_EP_BULKOUT 2
122+
#define USBD_HID_EP_INTIN 3
123+
#define USBD_CDC_ACM_EP_INTIN 4
124+
#define USBD_CDC_ACM_EP_BULKOUT 5
125+
#define USBD_CDC_ACM_EP_BULKIN 6
126+
#define USBD_BULK_EP_BULKIN 7 /* Unused */
127+
#define USBD_BULK_EP_BULKOUT 7 /* Unused */
128+
#endif
129+
90130
// <e> USB Device
91131
// <i> Enable the USB Device functionality
92132
#define USBD_ENABLE 1
@@ -209,9 +249,7 @@
209249
// </e>
210250

211251
#define USBD_HID_ENABLE HID_ENDPOINT
212-
#define USBD_HID_EP_INTIN 3
213252
#define USBD_HID_EP_INTIN_STACK 0
214-
#define USBD_HID_EP_INTOUT 0
215253
#define USBD_HID_EP_INTOUT_STACK 0
216254
#define USBD_HID_WMAXPACKETSIZE 64
217255
#define USBD_HID_BINTERVAL 1
@@ -258,9 +296,7 @@
258296
// </e>
259297

260298
#define USBD_MSC_ENABLE MSC_ENDPOINT
261-
#define USBD_MSC_EP_BULKIN 1
262299
#define USBD_MSC_EP_BULKIN_STACK 0
263-
#define USBD_MSC_EP_BULKOUT 2
264300
#define USBD_MSC_EP_BULKOUT_STACK 0
265301
#define USBD_MSC_WMAXPACKETSIZE 64
266302
#define USBD_MSC_HS_ENABLE 1
@@ -374,16 +410,13 @@
374410
// </e>
375411

376412
#define USBD_CDC_ACM_ENABLE CDC_ENDPOINT
377-
#define USBD_CDC_ACM_EP_INTIN 4
378413
#define USBD_CDC_ACM_EP_INTIN_STACK 0
379414
#define USBD_CDC_ACM_WMAXPACKETSIZE 16
380415
#define USBD_CDC_ACM_BINTERVAL 32
381416
#define USBD_CDC_ACM_HS_ENABLE 1
382417
#define USBD_CDC_ACM_HS_WMAXPACKETSIZE 64
383418
#define USBD_CDC_ACM_HS_BINTERVAL 2
384-
#define USBD_CDC_ACM_EP_BULKIN 6
385419
#define USBD_CDC_ACM_EP_BULKIN_STACK 0
386-
#define USBD_CDC_ACM_EP_BULKOUT 5
387420
#define USBD_CDC_ACM_EP_BULKOUT_STACK 0
388421
#define USBD_CDC_ACM_WMAXPACKETSIZE1 64
389422
#define USBD_CDC_ACM_HS_ENABLE1 1
@@ -431,20 +464,6 @@
431464
// </e>
432465

433466
#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-
448467
#define USBD_BULK_WMAXPACKETSIZE 64
449468
#define USBD_BULK_HS_ENABLE 1
450469
#define USBD_BULK_HS_WMAXPACKETSIZE 512

0 commit comments

Comments
 (0)