Skip to content

Commit a98713a

Browse files
mbrossardmathias-arm
authored andcommitted
sam3u2c: Add support for interface project configuration of endpoints
1 parent a01286a commit a98713a

File tree

1 file changed

+68
-33
lines changed

1 file changed

+68
-33
lines changed

source/hic_hal/atmel/sam3u2c/usb_config.c

Lines changed: 68 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,72 @@
2121

2222
#include "util.h"
2323

24+
#ifdef HID_ENDPOINT_DISABLE
25+
#undef HID_ENDPOINT
26+
#define HID_ENDPOINT 0
27+
#else
28+
#ifndef HID_ENDPOINT
29+
#define HID_ENDPOINT 0
30+
#else
31+
#define HID_ENDPOINT 1
32+
#endif
33+
#endif
34+
35+
#ifdef MSC_ENDPOINT_DISABLE
36+
#undef MSC_ENDPOINT
37+
#define MSC_ENDPOINT 0
38+
#else
39+
#ifndef MSC_ENDPOINT
40+
#define MSC_ENDPOINT 0
41+
#else
42+
#define MSC_ENDPOINT 1
43+
#endif
44+
#endif
45+
46+
#ifdef CDC_ENDPOINT_DISABLE
47+
#undef CDC_ENDPOINT
48+
#define CDC_ENDPOINT 0
49+
#else
50+
#ifndef CDC_ENDPOINT
51+
#define CDC_ENDPOINT 0
52+
#else
53+
#define CDC_ENDPOINT 1
54+
#endif
55+
#endif
56+
57+
#ifdef BULK_ENDPOINT_DISABLE
58+
#undef BULK_ENDPOINT
59+
#define BULK_ENDPOINT 0
60+
#else
61+
#ifndef BULK_ENDPOINT
62+
#define BULK_ENDPOINT 0
63+
#else
64+
#define BULK_ENDPOINT 1
65+
#endif
66+
#endif
67+
68+
#ifdef WEBUSB_INTERFACE_DISABLE
69+
#undef WEBUSB_INTERFACE
70+
#define WEBUSB_INTERFACE 0
71+
#else
72+
#ifndef WEBUSB_INTERFACE
73+
#define WEBUSB_INTERFACE 0
74+
#else
75+
#define WEBUSB_INTERFACE 1
76+
#endif
77+
#endif
78+
79+
#ifdef WINUSB_INTERFACE_DISABLE
80+
#undef WINUSB_INTERFACE
81+
#define WINUSB_INTERFACE 0
82+
#else
83+
#ifndef WINUSB_INTERFACE
84+
#define WINUSB_INTERFACE 0
85+
#else
86+
#define WINUSB_INTERFACE 1
87+
#endif
88+
#endif
89+
2490
// <e> USB Device
2591
// <i> Enable the USB Device functionality
2692
#define USBD_ENABLE 1
@@ -141,23 +207,6 @@
141207
// <o12.0..15> Maximum Feature Report Size (in bytes) <1-65535>
142208
// </h>
143209
// </e>
144-
#ifndef HID_ENDPOINT
145-
#define HID_ENDPOINT 0
146-
#else
147-
#define HID_ENDPOINT 1
148-
#endif
149-
150-
#ifndef WEBUSB_INTERFACE
151-
#define WEBUSB_INTERFACE 0
152-
#else
153-
#define WEBUSB_INTERFACE 1
154-
#endif
155-
156-
#ifndef WINUSB_INTERFACE
157-
#define WINUSB_INTERFACE 0
158-
#else
159-
#define WINUSB_INTERFACE 1
160-
#endif
161210

162211
#define USBD_HID_ENABLE HID_ENDPOINT
163212
#define USBD_HID_EP_INTIN 3
@@ -207,11 +256,7 @@
207256
// </h>
208257
// </h>
209258
// </e>
210-
#ifndef MSC_ENDPOINT
211-
#define MSC_ENDPOINT 0
212-
#else
213-
#define MSC_ENDPOINT 1
214-
#endif
259+
215260
#define USBD_MSC_ENABLE MSC_ENDPOINT
216261
#define USBD_MSC_EP_BULKIN 1
217262
#define USBD_MSC_EP_BULKIN_STACK 0
@@ -328,11 +373,6 @@
328373
// </h>
329374
// </e>
330375

331-
#ifndef CDC_ENDPOINT
332-
#define CDC_ENDPOINT 0
333-
#else
334-
#define CDC_ENDPOINT 1
335-
#endif
336376
#define USBD_CDC_ACM_ENABLE CDC_ENDPOINT
337377
#define USBD_CDC_ACM_EP_INTIN 4
338378
#define USBD_CDC_ACM_EP_INTIN_STACK 0
@@ -390,11 +430,6 @@
390430
// </e>
391431
// </e>
392432

393-
#ifndef BULK_ENDPOINT
394-
#define BULK_ENDPOINT 0
395-
#else
396-
#define BULK_ENDPOINT 1
397-
#endif
398433
#define USBD_BULK_ENABLE BULK_ENDPOINT //no endpts left
399434
#define USBD_BULK_EP_BULKIN 7
400435
#define USBD_BULK_EP_BULKOUT 8
@@ -418,7 +453,7 @@
418453
#define USBD_EP_NUM_CALC6 MAX(USBD_EP_NUM_CALC4, USBD_EP_NUM_CALC5)
419454
#define USBD_EP_NUM_CALC7 MAX((USBD_BULK_ENABLE*(USBD_BULK_EP_BULKIN)), (USBD_BULK_ENABLE*(USBD_BULK_EP_BULKOUT)))
420455
#define USBD_EP_NUM MAX(USBD_EP_NUM_CALC6, USBD_EP_NUM_CALC7)
421-
456+
422457
#if (USBD_EP_NUM > 6)
423458
#error "SAM3U only have 7 endpoints including EP0!"
424459
#endif

0 commit comments

Comments
 (0)