Skip to content

Commit

Permalink
sam3u2c: Use CMSIS-DAP v2 interface for sam3u2c_if project
Browse files Browse the repository at this point in the history
Disabling CMSIS-DAP v1 interface for improved performance
  • Loading branch information
mbrossard authored and mathias-arm committed Feb 13, 2024
1 parent 3cf9b13 commit 61a4a8e
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 25 deletions.
2 changes: 1 addition & 1 deletion docs/hic/sam3u2c.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Based on ATSAM3U2C chip ([Datasheet](https://ww1.microchip.com/downloads/en/Devi
- Cortex-M3 96 Mhz
- 128 KB Flash
- 36 KB RAM
- High-speed USB 2.0 device controller: up to 7 bi-directional endpoints including EP0 (*)
- High-speed USB 2.0 device controller: up to 7 endpoints including EP0 (*)
- LQFP100 packaging

(*) "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))
Expand Down
2 changes: 2 additions & 0 deletions projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ projects:
sam3u2c_if:
- *module_if
- *module_hic_sam3u2c
- records/usb/usb-bulk.yaml
- records/board/sam3u2c_if.yaml
- records/family/all_family.yaml
stm32f072x8_if:
- *module_if
Expand Down
5 changes: 5 additions & 0 deletions records/board/sam3u2c_if.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
common:
macros:
- HID_ENDPOINT_DISABLE
- MSC_ENDPOINT_DISABLE
- DRAG_N_DROP_DISABLE
6 changes: 3 additions & 3 deletions source/hic_hal/atmel/sam3u2c/DAP_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ This information includes:
/// This configuration settings is used to optimize the communication performance with the
/// debugger and depends on the USB peripheral. Typical vales are 64 for Full-speed USB HID or WinUSB,
/// 1024 for High-speed USB HID and 512 for High-speed USB WinUSB.
#ifndef HID_ENDPOINT //HID end points currently set limits to 64
#define DAP_PACKET_SIZE 512 ///< Specifies Packet Size in bytes.
#else
#if defined(HID_ENDPOINT) && !defined(HID_ENDPOINT_DISABLE) // HID end points currently set limits to 64
#define DAP_PACKET_SIZE 64 ///< Specifies Packet Size in bytes.
#else
#define DAP_PACKET_SIZE 512 ///< Specifies Packet Size in bytes.
#endif

/// Maximum Package Buffers for Command and Response data.
Expand Down
61 changes: 40 additions & 21 deletions source/hic_hal/atmel/sam3u2c/usb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,46 @@
#endif
#endif

#if (BULK_ENDPOINT)
/* SAM3UC only has 7 endpoints, and as a consequence BULK_ENDPOINT cannot
* be enabled at the same time as CDC_ENDPOINT and MSC_ENDPOINT.
*/
#if (CDC_ENDPOINT && MSC_ENDPOINT)
#error "SAM3U2C does not have enough endpoints to support this configuration"
#endif
#if (CDC_ENDPOINT)
#define USBD_HID_EP_INTOUT 0
#define USBD_BULK_EP_BULKIN 1
#define USBD_BULK_EP_BULKOUT 2
#define USBD_HID_EP_INTIN 3
#define USBD_CDC_ACM_EP_INTIN 4
#define USBD_CDC_ACM_EP_BULKOUT 5
#define USBD_CDC_ACM_EP_BULKIN 6
#define USBD_MSC_EP_BULKIN 7 /* Unused */
#define USBD_MSC_EP_BULKOUT 7 /* Unused */
#else // !(CDC_ENDPOINT)
#define USBD_MSC_EP_BULKIN 1
#define USBD_MSC_EP_BULKOUT 2
#define USBD_HID_EP_INTIN 3
#define USBD_HID_EP_INTOUT 4
#define USBD_BULK_EP_BULKOUT 5
#define USBD_BULK_EP_BULKIN 6
#define USBD_CDC_ACM_EP_INTIN 7 /* Unused */
#define USBD_CDC_ACM_EP_BULKIN 7 /* Unused */
#define USBD_CDC_ACM_EP_BULKOUT 7 /* Unused */
#endif
#else // !(BULK_ENDPOINT)
#define USBD_HID_EP_INTOUT 0
#define USBD_MSC_EP_BULKIN 1
#define USBD_MSC_EP_BULKOUT 2
#define USBD_HID_EP_INTIN 3
#define USBD_CDC_ACM_EP_INTIN 4
#define USBD_CDC_ACM_EP_BULKOUT 5
#define USBD_CDC_ACM_EP_BULKIN 6
#define USBD_BULK_EP_BULKIN 7 /* Unused */
#define USBD_BULK_EP_BULKOUT 7 /* Unused */
#endif

// <e> USB Device
// <i> Enable the USB Device functionality
#define USBD_ENABLE 1
Expand Down Expand Up @@ -209,9 +249,7 @@
// </e>

#define USBD_HID_ENABLE HID_ENDPOINT
#define USBD_HID_EP_INTIN 3
#define USBD_HID_EP_INTIN_STACK 0
#define USBD_HID_EP_INTOUT 0
#define USBD_HID_EP_INTOUT_STACK 0
#define USBD_HID_WMAXPACKETSIZE 64
#define USBD_HID_BINTERVAL 1
Expand Down Expand Up @@ -258,9 +296,7 @@
// </e>

#define USBD_MSC_ENABLE MSC_ENDPOINT
#define USBD_MSC_EP_BULKIN 1
#define USBD_MSC_EP_BULKIN_STACK 0
#define USBD_MSC_EP_BULKOUT 2
#define USBD_MSC_EP_BULKOUT_STACK 0
#define USBD_MSC_WMAXPACKETSIZE 64
#define USBD_MSC_HS_ENABLE 1
Expand Down Expand Up @@ -374,16 +410,13 @@
// </e>

#define USBD_CDC_ACM_ENABLE CDC_ENDPOINT
#define USBD_CDC_ACM_EP_INTIN 4
#define USBD_CDC_ACM_EP_INTIN_STACK 0
#define USBD_CDC_ACM_WMAXPACKETSIZE 16
#define USBD_CDC_ACM_BINTERVAL 32
#define USBD_CDC_ACM_HS_ENABLE 1
#define USBD_CDC_ACM_HS_WMAXPACKETSIZE 64
#define USBD_CDC_ACM_HS_BINTERVAL 2
#define USBD_CDC_ACM_EP_BULKIN 6
#define USBD_CDC_ACM_EP_BULKIN_STACK 0
#define USBD_CDC_ACM_EP_BULKOUT 5
#define USBD_CDC_ACM_EP_BULKOUT_STACK 0
#define USBD_CDC_ACM_WMAXPACKETSIZE1 64
#define USBD_CDC_ACM_HS_ENABLE1 1
Expand Down Expand Up @@ -431,20 +464,6 @@
// </e>

#define USBD_BULK_ENABLE BULK_ENDPOINT
// We don't have enough endpoints for BULK unless MSC or CDC are disabled.
// MSC is the best choice, since this is only useful in the fixed target IF config and we can still upload firmware via DAP.
// We'll still want MSC for the BL though, but in that case BULK isn't useful anyway.
#if USBD_MSC_ENABLE == 0
#define USBD_BULK_EP_BULKIN 1 // Use the MSC endpoints for BULK
#define USBD_BULK_EP_BULKOUT 2
#elif USBD_CDC_ACM_ENABLE == 0
#define USBD_BULK_EP_BULKIN 5 // Use the CDC endpoints for BULK
#define USBD_BULK_EP_BULKOUT 6
#else
#define USBD_BULK_EP_BULKIN 7 // Use non-existent endpoints to force an error
#define USBD_BULK_EP_BULKOUT 8 // if BULK is enabled but MSC + CDC are still enabled
#endif

#define USBD_BULK_WMAXPACKETSIZE 64
#define USBD_BULK_HS_ENABLE 1
#define USBD_BULK_HS_WMAXPACKETSIZE 512
Expand Down

0 comments on commit 61a4a8e

Please sign in to comment.