Преглед на файлове

Fix for DUE - no host support on native USB if SD card not enabled (#10148)

Eduardo José Tagle преди 6 години
родител
ревизия
bbfbf90797

+ 1
- 5
Marlin/src/HAL/HAL_DUE/usb/conf_access.h Целия файл

@@ -54,11 +54,7 @@
54 54
  */
55 55
 //! @{
56 56
 
57
-#ifdef SDSUPPORT
58
-  #define LUN_0              ENABLE    //!< SD/MMC Card over MCI Slot 0.
59
-#else
60
-  #define LUN_0              DISABLE
61
-#endif
57
+#define LUN_0                ENABLE    //!< SD/MMC Card over MCI Slot 0.
62 58
 #define LUN_1                DISABLE
63 59
 #define LUN_2                DISABLE
64 60
 #define LUN_3                DISABLE

+ 147
- 139
Marlin/src/HAL/HAL_DUE/usb/conf_usb.h Целия файл

@@ -114,48 +114,51 @@
114 114
 #define  USB_DEVICE_SPECIFIC_REQUEST()  usb_task_other_requests()
115 115
 //@}
116 116
 
117
-/**
118
- * USB Device low level configuration
119
- * When only one interface is used, these configurations are defined by the class module.
120
- * For composite device, these configuration must be defined here
121
- * @{
122
- */
123
-//! Control endpoint size
124
-#define  USB_DEVICE_EP_CTRL_SIZE       64
125
-
126
-//! Two interfaces for this device (CDC COM + CDC DATA + MSC)
127
-#define  USB_DEVICE_NB_INTERFACE       3
128
-
129
-//! 5 endpoints used by CDC and MSC interfaces
130
-#if SAM3U
131
-// (3 | USB_EP_DIR_IN)  // CDC Notify endpoint
132
-// (6 | USB_EP_DIR_IN)  // CDC TX
133
-// (5 | USB_EP_DIR_OUT) // CDC RX
134
-// (1 | USB_EP_DIR_IN)  // MSC IN
135
-// (2 | USB_EP_DIR_OUT) // MSC OUT
136
-#  define  USB_DEVICE_MAX_EP           6
137
-#  if defined(USB_DEVICE_HS_SUPPORT)
138
-// In HS mode, size of bulk endpoints are 512
139
-// If CDC and MSC endpoints all uses 2 banks, DPRAM is not enough: 4 bulk
140
-// endpoints requires 4K bytes. So reduce the number of banks of CDC bulk
141
-// endpoints to use less DPRAM. Keep MSC setting to keep MSC performance.
142
-#     define  UDD_BULK_NB_BANK(ep) ((ep == 5 || ep== 6) ? 1 : 2)
143
-#endif
144
-#else
145
-// (3 | USB_EP_DIR_IN)  // CDC Notify endpoint
146
-// (4 | USB_EP_DIR_IN)  // CDC TX
147
-// (5 | USB_EP_DIR_OUT) // CDC RX
148
-// (1 | USB_EP_DIR_IN)  // MSC IN
149
-// (2 | USB_EP_DIR_OUT) // MSC OUT
150
-#  define  USB_DEVICE_MAX_EP           5
151
-#  if SAM3XA && defined(USB_DEVICE_HS_SUPPORT)
152
-// In HS mode, size of bulk endpoints are 512
153
-// If CDC and MSC endpoints all uses 2 banks, DPRAM is not enough: 4 bulk
154
-// endpoints requires 4K bytes. So reduce the number of banks of CDC bulk
155
-// endpoints to use less DPRAM. Keep MSC setting to keep MSC performance.
156
-#     define  UDD_BULK_NB_BANK(ep) ((ep == 4 || ep== 5) ? 1 : 2)
157
-#  endif
117
+#if ENABLED(SDSUPPORT)
118
+  /**
119
+   * USB Device low level configuration
120
+   * When only one interface is used, these configurations are defined by the class module.
121
+   * For composite device, these configuration must be defined here
122
+   * @{
123
+   */
124
+  //! Control endpoint size
125
+  #define  USB_DEVICE_EP_CTRL_SIZE       64
126
+
127
+  //! Two interfaces for this device (CDC COM + CDC DATA + MSC)
128
+  #define  USB_DEVICE_NB_INTERFACE       3
129
+
130
+  //! 5 endpoints used by CDC and MSC interfaces
131
+  #if SAM3U
132
+  // (3 | USB_EP_DIR_IN)  // CDC Notify endpoint
133
+  // (6 | USB_EP_DIR_IN)  // CDC TX
134
+  // (5 | USB_EP_DIR_OUT) // CDC RX
135
+  // (1 | USB_EP_DIR_IN)  // MSC IN
136
+  // (2 | USB_EP_DIR_OUT) // MSC OUT
137
+  #  define  USB_DEVICE_MAX_EP           6
138
+  #  if defined(USB_DEVICE_HS_SUPPORT)
139
+  // In HS mode, size of bulk endpoints are 512
140
+  // If CDC and MSC endpoints all uses 2 banks, DPRAM is not enough: 4 bulk
141
+  // endpoints requires 4K bytes. So reduce the number of banks of CDC bulk
142
+  // endpoints to use less DPRAM. Keep MSC setting to keep MSC performance.
143
+  #     define  UDD_BULK_NB_BANK(ep) ((ep == 5 || ep== 6) ? 1 : 2)
144
+  #endif
145
+  #else
146
+  // (3 | USB_EP_DIR_IN)  // CDC Notify endpoint
147
+  // (4 | USB_EP_DIR_IN)  // CDC TX
148
+  // (5 | USB_EP_DIR_OUT) // CDC RX
149
+  // (1 | USB_EP_DIR_IN)  // MSC IN
150
+  // (2 | USB_EP_DIR_OUT) // MSC OUT
151
+  #  define  USB_DEVICE_MAX_EP           5
152
+  #  if SAM3XA && defined(USB_DEVICE_HS_SUPPORT)
153
+  // In HS mode, size of bulk endpoints are 512
154
+  // If CDC and MSC endpoints all uses 2 banks, DPRAM is not enough: 4 bulk
155
+  // endpoints requires 4K bytes. So reduce the number of banks of CDC bulk
156
+  // endpoints to use less DPRAM. Keep MSC setting to keep MSC performance.
157
+  #     define  UDD_BULK_NB_BANK(ep) ((ep == 4 || ep== 5) ? 1 : 2)
158
+  #  endif
159
+  #endif
158 160
 #endif
161
+
159 162
 //@}
160 163
 
161 164
 //@}
@@ -195,107 +198,112 @@
195 198
 //! Enable id string of interface to add an extra USB string
196 199
 #define  UDI_CDC_IAD_STRING_ID            4
197 200
 
198
-/**
199
- * USB CDC low level configuration
200
- * In standalone these configurations are defined by the CDC module.
201
- * For composite device, these configuration must be defined here
202
- * @{
203
- */
204
-//! Endpoint numbers definition
205
-#if SAM3U
206
-#  define  UDI_CDC_COMM_EP_0             (3 | USB_EP_DIR_IN) // Notify endpoint
207
-#  define  UDI_CDC_DATA_EP_IN_0          (6 | USB_EP_DIR_IN) // TX
208
-#  define  UDI_CDC_DATA_EP_OUT_0         (5 | USB_EP_DIR_OUT)// RX
201
+#if ENABLED(SDSUPPORT)
202
+  /**
203
+   * USB CDC low level configuration
204
+   * In standalone these configurations are defined by the CDC module.
205
+   * For composite device, these configuration must be defined here
206
+   * @{
207
+   */
208
+  //! Endpoint numbers definition
209
+  #if SAM3U
210
+  #  define  UDI_CDC_COMM_EP_0             (3 | USB_EP_DIR_IN) // Notify endpoint
211
+  #  define  UDI_CDC_DATA_EP_IN_0          (6 | USB_EP_DIR_IN) // TX
212
+  #  define  UDI_CDC_DATA_EP_OUT_0         (5 | USB_EP_DIR_OUT)// RX
213
+  #else
214
+  #  define  UDI_CDC_COMM_EP_0             (3 | USB_EP_DIR_IN) // Notify endpoint
215
+  #  define  UDI_CDC_DATA_EP_IN_0          (4 | USB_EP_DIR_IN) // TX
216
+  #  define  UDI_CDC_DATA_EP_OUT_0         (5 | USB_EP_DIR_OUT)// RX
217
+  #endif
218
+
219
+  //! Interface numbers
220
+  #define  UDI_CDC_COMM_IFACE_NUMBER_0   0
221
+  #define  UDI_CDC_DATA_IFACE_NUMBER_0   1
222
+
223
+  //@}
224
+  //@}
225
+
226
+
227
+  /**
228
+   * Configuration of MSC interface
229
+   * @{
230
+   */
231
+  //! Vendor name and Product version of MSC interface
232
+  #define UDI_MSC_GLOBAL_VENDOR_ID            \
233
+     'M', 'A', 'R', 'L', 'I', 'N', '3', 'D'
234
+  #define UDI_MSC_GLOBAL_PRODUCT_VERSION            \
235
+     '1', '.', '0', '0'
236
+
237
+  //! Interface callback definition
238
+  #define  UDI_MSC_ENABLE_EXT()          usb_task_msc_enable()
239
+  #define  UDI_MSC_DISABLE_EXT()         usb_task_msc_disable()
240
+
241
+  //! Enable id string of interface to add an extra USB string
242
+  #define  UDI_MSC_STRING_ID             5
243
+
244
+  /**
245
+   * USB MSC low level configuration
246
+   * In standalone these configurations are defined by the MSC module.
247
+   * For composite device, these configuration must be defined here
248
+   * @{
249
+   */
250
+  //! Endpoint numbers definition
251
+  #define  UDI_MSC_EP_IN                 (1 | USB_EP_DIR_IN)
252
+  #define  UDI_MSC_EP_OUT                (2 | USB_EP_DIR_OUT)
253
+
254
+  //! Interface number
255
+  #define  UDI_MSC_IFACE_NUMBER          2
256
+  //@}
257
+  //@}
258
+
259
+  //@}
260
+
261
+
262
+  /**
263
+   * Description of Composite Device
264
+   * @{
265
+   */
266
+  //! USB Interfaces descriptor structure
267
+  #define UDI_COMPOSITE_DESC_T \
268
+    usb_iad_desc_t       udi_cdc_iad; \
269
+    udi_cdc_comm_desc_t  udi_cdc_comm; \
270
+    udi_cdc_data_desc_t  udi_cdc_data; \
271
+    udi_msc_desc_t       udi_msc
272
+
273
+  //! USB Interfaces descriptor value for Full Speed
274
+  #define UDI_COMPOSITE_DESC_FS \
275
+    .udi_cdc_iad   = UDI_CDC_IAD_DESC_0, \
276
+    .udi_cdc_comm  = UDI_CDC_COMM_DESC_0, \
277
+    .udi_cdc_data  = UDI_CDC_DATA_DESC_0_FS, \
278
+    .udi_msc       = UDI_MSC_DESC_FS
279
+
280
+  //! USB Interfaces descriptor value for High Speed
281
+  #define UDI_COMPOSITE_DESC_HS \
282
+    .udi_cdc_iad   = UDI_CDC_IAD_DESC_0, \
283
+    .udi_cdc_comm  = UDI_CDC_COMM_DESC_0, \
284
+    .udi_cdc_data  = UDI_CDC_DATA_DESC_0_HS, \
285
+    .udi_msc       = UDI_MSC_DESC_HS
286
+
287
+  //! USB Interface APIs
288
+  #define UDI_COMPOSITE_API \
289
+    &udi_api_cdc_comm, \
290
+    &udi_api_cdc_data, \
291
+    &udi_api_msc
292
+  //@}
293
+
294
+  /**
295
+   * USB Device Driver Configuration
296
+   * @{
297
+   */
298
+  //@}
299
+
300
+  //! The includes of classes and other headers must be done at the end of this file to avoid compile error
301
+  #include "udi_cdc.h"
302
+  #include "udi_msc.h"
209 303
 #else
210
-#  define  UDI_CDC_COMM_EP_0             (3 | USB_EP_DIR_IN) // Notify endpoint
211
-#  define  UDI_CDC_DATA_EP_IN_0          (4 | USB_EP_DIR_IN) // TX
212
-#  define  UDI_CDC_DATA_EP_OUT_0         (5 | USB_EP_DIR_OUT)// RX
304
+  #include "udi_cdc_conf.h"
213 305
 #endif
214 306
 
215
-//! Interface numbers
216
-#define  UDI_CDC_COMM_IFACE_NUMBER_0   0
217
-#define  UDI_CDC_DATA_IFACE_NUMBER_0   1
218
-//@}
219
-//@}
220
-
221
-
222
-/**
223
- * Configuration of MSC interface
224
- * @{
225
- */
226
-//! Vendor name and Product version of MSC interface
227
-#define UDI_MSC_GLOBAL_VENDOR_ID            \
228
-   'M', 'A', 'R', 'L', 'I', 'N', '3', 'D'
229
-#define UDI_MSC_GLOBAL_PRODUCT_VERSION            \
230
-   '1', '.', '0', '0'
231
-
232
-//! Interface callback definition
233
-#define  UDI_MSC_ENABLE_EXT()          usb_task_msc_enable()
234
-#define  UDI_MSC_DISABLE_EXT()         usb_task_msc_disable()
235
-
236
-//! Enable id string of interface to add an extra USB string
237
-#define  UDI_MSC_STRING_ID                5
238
-
239
-/**
240
- * USB MSC low level configuration
241
- * In standalone these configurations are defined by the MSC module.
242
- * For composite device, these configuration must be defined here
243
- * @{
244
- */
245
-//! Endpoint numbers definition
246
-#define  UDI_MSC_EP_IN                 (1 | USB_EP_DIR_IN)
247
-#define  UDI_MSC_EP_OUT                (2 | USB_EP_DIR_OUT)
248
-
249
-//! Interface number
250
-#define  UDI_MSC_IFACE_NUMBER          2
251
-//@}
252
-//@}
253
-
254
-//@}
255
-
256
-
257
-/**
258
- * Description of Composite Device
259
- * @{
260
- */
261
-//! USB Interfaces descriptor structure
262
-#define UDI_COMPOSITE_DESC_T \
263
-  usb_iad_desc_t       udi_cdc_iad; \
264
-  udi_cdc_comm_desc_t  udi_cdc_comm; \
265
-  udi_cdc_data_desc_t  udi_cdc_data; \
266
-  udi_msc_desc_t       udi_msc
267
-
268
-//! USB Interfaces descriptor value for Full Speed
269
-#define UDI_COMPOSITE_DESC_FS \
270
-  .udi_cdc_iad   = UDI_CDC_IAD_DESC_0, \
271
-  .udi_cdc_comm  = UDI_CDC_COMM_DESC_0, \
272
-  .udi_cdc_data  = UDI_CDC_DATA_DESC_0_FS, \
273
-  .udi_msc       = UDI_MSC_DESC_FS
274
-
275
-//! USB Interfaces descriptor value for High Speed
276
-#define UDI_COMPOSITE_DESC_HS \
277
-  .udi_cdc_iad   = UDI_CDC_IAD_DESC_0, \
278
-  .udi_cdc_comm  = UDI_CDC_COMM_DESC_0, \
279
-  .udi_cdc_data  = UDI_CDC_DATA_DESC_0_HS, \
280
-  .udi_msc       = UDI_MSC_DESC_HS
281
-
282
-//! USB Interface APIs
283
-#define UDI_COMPOSITE_API \
284
-  &udi_api_cdc_comm, \
285
-  &udi_api_cdc_data, \
286
-  &udi_api_msc
287
-//@}
288
-
289
-
290
-/**
291
- * USB Device Driver Configuration
292
- * @{
293
- */
294
-//@}
295
-
296
-//! The includes of classes and other headers must be done at the end of this file to avoid compile error
297
-#include "udi_cdc.h"
298
-#include "udi_msc.h"
299 307
 #include "usb_task.h"
300 308
 
301 309
 #endif // _CONF_USB_H_

+ 156
- 0
Marlin/src/HAL/HAL_DUE/usb/udi_cdc_conf.h Целия файл

@@ -0,0 +1,156 @@
1
+/**
2
+ * \file
3
+ *
4
+ * \brief Default CDC configuration for a USB Device with a single interface
5
+ *
6
+ * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
7
+ *
8
+ * \asf_license_start
9
+ *
10
+ * \page License
11
+ *
12
+ * Redistribution and use in source and binary forms, with or without
13
+ * modification, are permitted provided that the following conditions are met:
14
+ *
15
+ * 1. Redistributions of source code must retain the above copyright notice,
16
+ *    this list of conditions and the following disclaimer.
17
+ *
18
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
19
+ *    this list of conditions and the following disclaimer in the documentation
20
+ *    and/or other materials provided with the distribution.
21
+ *
22
+ * 3. The name of Atmel may not be used to endorse or promote products derived
23
+ *    from this software without specific prior written permission.
24
+ *
25
+ * 4. This software may only be redistributed and used in connection with an
26
+ *    Atmel microcontroller product.
27
+ *
28
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
29
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
31
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
32
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
+ * POSSIBILITY OF SUCH DAMAGE.
39
+ *
40
+ * \asf_license_stop
41
+ *
42
+ */
43
+/*
44
+ * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
45
+ */
46
+
47
+#ifndef _UDI_CDC_CONF_H_
48
+#define _UDI_CDC_CONF_H_
49
+
50
+#include "usb_protocol_cdc.h"
51
+#include "conf_usb.h"
52
+
53
+#ifndef  UDI_CDC_PORT_NB
54
+# define  UDI_CDC_PORT_NB 1
55
+#endif
56
+
57
+#ifdef __cplusplus
58
+extern "C" {
59
+#endif
60
+
61
+/**
62
+ * \addtogroup udi_cdc_group_single_desc
63
+ * @{
64
+ */
65
+
66
+//! Control endpoint size (Endpoint 0)
67
+#define  USB_DEVICE_EP_CTRL_SIZE       64
68
+
69
+#if XMEGA
70
+/**
71
+ * \name Endpoint configuration on XMEGA
72
+ * The XMEGA supports a IN and OUT endpoint with the same number endpoint,
73
+ * thus XMEGA can support up to 7 CDC interfaces.
74
+ */
75
+//@{
76
+#define  UDI_CDC_DATA_EP_IN_0          ( 1 | USB_EP_DIR_IN)  // TX
77
+#define  UDI_CDC_DATA_EP_OUT_0         ( 2 | USB_EP_DIR_OUT) // RX
78
+#define  UDI_CDC_COMM_EP_0             ( 2 | USB_EP_DIR_IN)  // Notify endpoint
79
+#define  UDI_CDC_DATA_EP_IN_1          ( 3 | USB_EP_DIR_IN)  // TX
80
+#define  UDI_CDC_DATA_EP_OUT_1         ( 4 | USB_EP_DIR_OUT) // RX
81
+#define  UDI_CDC_COMM_EP_1             ( 4 | USB_EP_DIR_IN)  // Notify endpoint
82
+#define  UDI_CDC_DATA_EP_IN_2          ( 5 | USB_EP_DIR_IN)  // TX
83
+#define  UDI_CDC_DATA_EP_OUT_2         ( 6 | USB_EP_DIR_OUT) // RX
84
+#define  UDI_CDC_COMM_EP_2             ( 6 | USB_EP_DIR_IN)  // Notify endpoint
85
+#define  UDI_CDC_DATA_EP_IN_3          ( 7 | USB_EP_DIR_IN)  // TX
86
+#define  UDI_CDC_DATA_EP_OUT_3         ( 8 | USB_EP_DIR_OUT) // RX
87
+#define  UDI_CDC_COMM_EP_3             ( 8 | USB_EP_DIR_IN)  // Notify endpoint
88
+#define  UDI_CDC_DATA_EP_IN_4          ( 9 | USB_EP_DIR_IN)  // TX
89
+#define  UDI_CDC_DATA_EP_OUT_4         (10 | USB_EP_DIR_OUT) // RX
90
+#define  UDI_CDC_COMM_EP_4             (10 | USB_EP_DIR_IN)  // Notify endpoint
91
+#define  UDI_CDC_DATA_EP_IN_5          (11 | USB_EP_DIR_IN)  // TX
92
+#define  UDI_CDC_DATA_EP_OUT_5         (12 | USB_EP_DIR_OUT) // RX
93
+#define  UDI_CDC_COMM_EP_5             (12 | USB_EP_DIR_IN)  // Notify endpoint
94
+#define  UDI_CDC_DATA_EP_IN_6          (13 | USB_EP_DIR_IN)  // TX
95
+#define  UDI_CDC_DATA_EP_OUT_6         (14 | USB_EP_DIR_OUT) // RX
96
+#define  UDI_CDC_COMM_EP_6             (14 | USB_EP_DIR_IN)  // Notify endpoint
97
+//! 2 endpoints numbers used per CDC interface
98
+#define  USB_DEVICE_MAX_EP             (2*UDI_CDC_PORT_NB)
99
+//@}
100
+
101
+#else
102
+
103
+/**
104
+ * \name Default endpoint configuration
105
+ * The USBB, UDP, UDPHS and UOTGHS interfaces can support up to 2 CDC interfaces.
106
+ */
107
+//@{
108
+#  if UDI_CDC_PORT_NB > 2
109
+#    error USBB, UDP, UDPHS and UOTGHS interfaces have not enought endpoints.
110
+#  endif
111
+#define  UDI_CDC_DATA_EP_IN_0          (1 | USB_EP_DIR_IN)  // TX
112
+#define  UDI_CDC_DATA_EP_OUT_0         (2 | USB_EP_DIR_OUT) // RX
113
+#define  UDI_CDC_COMM_EP_0             (3 | USB_EP_DIR_IN)  // Notify endpoint
114
+#  if SAM3U
115
+     /* For 3U max endpoint size of 4 is 64, use 5 and 6 as bulk tx and rx */
116
+#    define  UDI_CDC_DATA_EP_IN_1          (6 | USB_EP_DIR_IN)  // TX
117
+#    define  UDI_CDC_DATA_EP_OUT_1         (5 | USB_EP_DIR_OUT) // RX
118
+#    define  UDI_CDC_COMM_EP_1             (4 | USB_EP_DIR_IN)  // Notify
119
+#  else
120
+#    define  UDI_CDC_DATA_EP_IN_1          (4 | USB_EP_DIR_IN)  // TX
121
+#    define  UDI_CDC_DATA_EP_OUT_1         (5 | USB_EP_DIR_OUT) // RX
122
+#    define  UDI_CDC_COMM_EP_1             (6 | USB_EP_DIR_IN)  // Notify
123
+#  endif
124
+//! 3 endpoints used per CDC interface
125
+#undef USB_DEVICE_MAX_EP   // undefine this definition in header file
126
+#define  USB_DEVICE_MAX_EP             (3*UDI_CDC_PORT_NB)
127
+//@}
128
+
129
+#endif
130
+
131
+/**
132
+ * \name Default Interface numbers
133
+ */
134
+//@{
135
+#define  UDI_CDC_COMM_IFACE_NUMBER_0   0
136
+#define  UDI_CDC_DATA_IFACE_NUMBER_0   1
137
+#define  UDI_CDC_COMM_IFACE_NUMBER_1   2
138
+#define  UDI_CDC_DATA_IFACE_NUMBER_1   3
139
+#define  UDI_CDC_COMM_IFACE_NUMBER_2   4
140
+#define  UDI_CDC_DATA_IFACE_NUMBER_2   5
141
+#define  UDI_CDC_COMM_IFACE_NUMBER_3   6
142
+#define  UDI_CDC_DATA_IFACE_NUMBER_3   7
143
+#define  UDI_CDC_COMM_IFACE_NUMBER_4   8
144
+#define  UDI_CDC_DATA_IFACE_NUMBER_4   9
145
+#define  UDI_CDC_COMM_IFACE_NUMBER_5   10
146
+#define  UDI_CDC_DATA_IFACE_NUMBER_5   11
147
+#define  UDI_CDC_COMM_IFACE_NUMBER_6   12
148
+#define  UDI_CDC_DATA_IFACE_NUMBER_6   13
149
+//@}
150
+
151
+//@}
152
+
153
+#ifdef __cplusplus
154
+}
155
+#endif
156
+#endif // _UDI_CDC_CONF_H_

+ 259
- 0
Marlin/src/HAL/HAL_DUE/usb/udi_cdc_desc.c Целия файл

@@ -0,0 +1,259 @@
1
+/**
2
+ * \file
3
+ *
4
+ * \brief Default descriptors for a USB Device with a single interface CDC
5
+ *
6
+ * Copyright (c) 2009-2016 Atmel Corporation. All rights reserved.
7
+ *
8
+ * \asf_license_start
9
+ *
10
+ * \page License
11
+ *
12
+ * Redistribution and use in source and binary forms, with or without
13
+ * modification, are permitted provided that the following conditions are met:
14
+ *
15
+ * 1. Redistributions of source code must retain the above copyright notice,
16
+ *    this list of conditions and the following disclaimer.
17
+ *
18
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
19
+ *    this list of conditions and the following disclaimer in the documentation
20
+ *    and/or other materials provided with the distribution.
21
+ *
22
+ * 3. The name of Atmel may not be used to endorse or promote products derived
23
+ *    from this software without specific prior written permission.
24
+ *
25
+ * 4. This software may only be redistributed and used in connection with an
26
+ *    Atmel microcontroller product.
27
+ *
28
+ * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
29
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
31
+ * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
32
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
+ * POSSIBILITY OF SUCH DAMAGE.
39
+ *
40
+ * \asf_license_stop
41
+ *
42
+ */
43
+/*
44
+ * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
45
+ */
46
+
47
+#ifdef ARDUINO_ARCH_SAM
48
+
49
+#include "conf_usb.h"
50
+#include "udd.h"
51
+#include "udc_desc.h"
52
+#include "udi_cdc.h"
53
+
54
+#if DISABLED(SDSUPPORT)
55
+
56
+/**
57
+ * \defgroup udi_cdc_group_single_desc USB device descriptors for a single interface
58
+ *
59
+ * The following structures provide the USB device descriptors required for
60
+ * USB Device with a single interface CDC.
61
+ *
62
+ * It is ready to use and do not require more definition.
63
+ *
64
+ * @{
65
+ */
66
+
67
+//! Two interfaces for a CDC device
68
+#define  USB_DEVICE_NB_INTERFACE       (2*UDI_CDC_PORT_NB)
69
+
70
+#ifdef USB_DEVICE_LPM_SUPPORT
71
+# define USB_VERSION   USB_V2_1
72
+#else
73
+# define USB_VERSION   USB_V2_0
74
+#endif
75
+
76
+//! USB Device Descriptor
77
+COMPILER_WORD_ALIGNED
78
+UDC_DESC_STORAGE usb_dev_desc_t udc_device_desc = {
79
+  .bLength                   = sizeof(usb_dev_desc_t),
80
+  .bDescriptorType           = USB_DT_DEVICE,
81
+  .bcdUSB                    = LE16(USB_VERSION),
82
+#if UDI_CDC_PORT_NB > 1
83
+  .bDeviceClass              = 0,
84
+#else
85
+  .bDeviceClass              = CDC_CLASS_DEVICE,
86
+#endif
87
+  .bDeviceSubClass           = 0,
88
+  .bDeviceProtocol           = 0,
89
+  .bMaxPacketSize0           = USB_DEVICE_EP_CTRL_SIZE,
90
+  .idVendor                  = LE16(USB_DEVICE_VENDOR_ID),
91
+  .idProduct                 = LE16(USB_DEVICE_PRODUCT_ID),
92
+  .bcdDevice                 = LE16((USB_DEVICE_MAJOR_VERSION << 8)
93
+      | USB_DEVICE_MINOR_VERSION),
94
+#ifdef USB_DEVICE_MANUFACTURE_NAME
95
+  .iManufacturer = 1,
96
+#else
97
+  .iManufacturer             = 0,  // No manufacture string
98
+#endif
99
+#ifdef USB_DEVICE_PRODUCT_NAME
100
+  .iProduct = 2,
101
+#else
102
+  .iProduct                  = 0,  // No product string
103
+#endif
104
+#if (defined USB_DEVICE_SERIAL_NAME || defined USB_DEVICE_GET_SERIAL_NAME_POINTER)
105
+  .iSerialNumber = 3,
106
+#else
107
+  .iSerialNumber             = 0,  // No serial string
108
+#endif
109
+  .bNumConfigurations = 1
110
+};
111
+
112
+
113
+#ifdef USB_DEVICE_HS_SUPPORT
114
+//! USB Device Qualifier Descriptor for HS
115
+COMPILER_WORD_ALIGNED
116
+UDC_DESC_STORAGE usb_dev_qual_desc_t udc_device_qual = {
117
+  .bLength                   = sizeof(usb_dev_qual_desc_t),
118
+  .bDescriptorType           = USB_DT_DEVICE_QUALIFIER,
119
+  .bcdUSB                    = LE16(USB_VERSION),
120
+#if UDI_CDC_PORT_NB > 1
121
+  .bDeviceClass              = 0,
122
+#else
123
+  .bDeviceClass              = CDC_CLASS_DEVICE,
124
+#endif
125
+  .bDeviceSubClass           = 0,
126
+  .bDeviceProtocol           = 0,
127
+  .bMaxPacketSize0           = USB_DEVICE_EP_CTRL_SIZE,
128
+  .bNumConfigurations        = 1
129
+};
130
+#endif
131
+
132
+#ifdef USB_DEVICE_LPM_SUPPORT
133
+//! USB Device Qualifier Descriptor
134
+COMPILER_WORD_ALIGNED
135
+UDC_DESC_STORAGE usb_dev_lpm_desc_t udc_device_lpm = {
136
+  .bos.bLength               = sizeof(usb_dev_bos_desc_t),
137
+  .bos.bDescriptorType       = USB_DT_BOS,
138
+  .bos.wTotalLength          = LE16(sizeof(usb_dev_bos_desc_t) + sizeof(usb_dev_capa_ext_desc_t)),
139
+  .bos.bNumDeviceCaps        = 1,
140
+  .capa_ext.bLength          = sizeof(usb_dev_capa_ext_desc_t),
141
+  .capa_ext.bDescriptorType  = USB_DT_DEVICE_CAPABILITY,
142
+  .capa_ext.bDevCapabilityType = USB_DC_USB20_EXTENSION,
143
+  .capa_ext.bmAttributes     = USB_DC_EXT_LPM,
144
+};
145
+#endif
146
+
147
+//! Structure for USB Device Configuration Descriptor
148
+COMPILER_PACK_SET(1)
149
+typedef struct {
150
+  usb_conf_desc_t conf;
151
+#if UDI_CDC_PORT_NB == 1
152
+  udi_cdc_comm_desc_t udi_cdc_comm_0;
153
+  udi_cdc_data_desc_t udi_cdc_data_0;
154
+#else
155
+#  define UDI_CDC_DESC_STRUCTURE(index, unused) \
156
+  usb_iad_desc_t      udi_cdc_iad_##index; \
157
+  udi_cdc_comm_desc_t udi_cdc_comm_##index; \
158
+  udi_cdc_data_desc_t udi_cdc_data_##index;
159
+  MREPEAT(UDI_CDC_PORT_NB, UDI_CDC_DESC_STRUCTURE, ~)
160
+#  undef UDI_CDC_DESC_STRUCTURE
161
+#endif
162
+} udc_desc_t;
163
+COMPILER_PACK_RESET()
164
+
165
+//! USB Device Configuration Descriptor filled for full and high speed
166
+COMPILER_WORD_ALIGNED
167
+UDC_DESC_STORAGE udc_desc_t udc_desc_fs = {
168
+  .conf.bLength              = sizeof(usb_conf_desc_t),
169
+  .conf.bDescriptorType      = USB_DT_CONFIGURATION,
170
+  .conf.wTotalLength         = LE16(sizeof(udc_desc_t)),
171
+  .conf.bNumInterfaces       = USB_DEVICE_NB_INTERFACE,
172
+  .conf.bConfigurationValue  = 1,
173
+  .conf.iConfiguration       = 0,
174
+  .conf.bmAttributes         = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR,
175
+  .conf.bMaxPower            = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER),
176
+#if UDI_CDC_PORT_NB == 1
177
+  .udi_cdc_comm_0            = UDI_CDC_COMM_DESC_0,
178
+  .udi_cdc_data_0            = UDI_CDC_DATA_DESC_0_FS,
179
+#else
180
+#  define UDI_CDC_DESC_FS(index, unused) \
181
+  .udi_cdc_iad_##index             = UDI_CDC_IAD_DESC_##index,\
182
+  .udi_cdc_comm_##index            = UDI_CDC_COMM_DESC_##index,\
183
+  .udi_cdc_data_##index            = UDI_CDC_DATA_DESC_##index##_FS,
184
+  MREPEAT(UDI_CDC_PORT_NB, UDI_CDC_DESC_FS, ~)
185
+#  undef UDI_CDC_DESC_FS
186
+#endif
187
+};
188
+
189
+#ifdef USB_DEVICE_HS_SUPPORT
190
+COMPILER_WORD_ALIGNED
191
+UDC_DESC_STORAGE udc_desc_t udc_desc_hs = {
192
+  .conf.bLength              = sizeof(usb_conf_desc_t),
193
+  .conf.bDescriptorType      = USB_DT_CONFIGURATION,
194
+  .conf.wTotalLength         = LE16(sizeof(udc_desc_t)),
195
+  .conf.bNumInterfaces       = USB_DEVICE_NB_INTERFACE,
196
+  .conf.bConfigurationValue  = 1,
197
+  .conf.iConfiguration       = 0,
198
+  .conf.bmAttributes         = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR,
199
+  .conf.bMaxPower            = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER),
200
+#if UDI_CDC_PORT_NB == 1
201
+  .udi_cdc_comm_0            = UDI_CDC_COMM_DESC_0,
202
+  .udi_cdc_data_0            = UDI_CDC_DATA_DESC_0_HS,
203
+#else
204
+#  define UDI_CDC_DESC_HS(index, unused) \
205
+  .udi_cdc_iad_##index             = UDI_CDC_IAD_DESC_##index, \
206
+  .udi_cdc_comm_##index            = UDI_CDC_COMM_DESC_##index, \
207
+  .udi_cdc_data_##index            = UDI_CDC_DATA_DESC_##index##_HS,
208
+  MREPEAT(UDI_CDC_PORT_NB, UDI_CDC_DESC_HS, ~)
209
+#  undef UDI_CDC_DESC_HS
210
+#endif
211
+};
212
+#endif
213
+
214
+/**
215
+ * \name UDC structures which content all USB Device definitions
216
+ */
217
+//@{
218
+
219
+//! Associate an UDI for each USB interface
220
+UDC_DESC_STORAGE udi_api_t *udi_apis[USB_DEVICE_NB_INTERFACE] = {
221
+#  define UDI_CDC_API(index, unused) \
222
+  &udi_api_cdc_comm, \
223
+  &udi_api_cdc_data,
224
+  MREPEAT(UDI_CDC_PORT_NB, UDI_CDC_API, ~)
225
+#  undef UDI_CDC_API
226
+};
227
+
228
+//! Add UDI with USB Descriptors FS & HS
229
+UDC_DESC_STORAGE udc_config_speed_t udc_config_fs[1] = { {
230
+  .desc          = (usb_conf_desc_t UDC_DESC_STORAGE*)&udc_desc_fs,
231
+  .udi_apis = udi_apis,
232
+}};
233
+#ifdef USB_DEVICE_HS_SUPPORT
234
+UDC_DESC_STORAGE udc_config_speed_t udc_config_hs[1] = { {
235
+  .desc          = (usb_conf_desc_t UDC_DESC_STORAGE*)&udc_desc_hs,
236
+  .udi_apis = udi_apis,
237
+}};
238
+#endif
239
+
240
+//! Add all information about USB Device in global structure for UDC
241
+UDC_DESC_STORAGE udc_config_t udc_config = {
242
+  .confdev_lsfs = &udc_device_desc,
243
+  .conf_lsfs = udc_config_fs,
244
+#ifdef USB_DEVICE_HS_SUPPORT
245
+  .confdev_hs = &udc_device_desc,
246
+  .qualifier = &udc_device_qual,
247
+  .conf_hs = udc_config_hs,
248
+#endif
249
+#ifdef USB_DEVICE_LPM_SUPPORT
250
+  .conf_bos = &udc_device_lpm.bos,
251
+#else
252
+  .conf_bos = NULL,
253
+#endif
254
+};
255
+
256
+//@}
257
+//@}
258
+#endif
259
+#endif

+ 59
- 56
Marlin/src/HAL/HAL_DUE/usb/udi_composite_desc.c Целия файл

@@ -50,6 +50,8 @@
50 50
 #include "udd.h"
51 51
 #include "udc_desc.h"
52 52
 
53
+#if ENABLED(SDSUPPORT)
54
+
53 55
 /**
54 56
  * \defgroup udi_group_desc Descriptors for a USB Device
55 57
  * composite
@@ -62,33 +64,33 @@
62 64
 //! USB Device Descriptor
63 65
 COMPILER_WORD_ALIGNED
64 66
 UDC_DESC_STORAGE usb_dev_desc_t udc_device_desc = {
65
-	.bLength                   = sizeof(usb_dev_desc_t),
66
-	.bDescriptorType           = USB_DT_DEVICE,
67
-	.bcdUSB                    = LE16(USB_V2_0),
68
-	.bDeviceClass              = 0,
69
-	.bDeviceSubClass           = 0,
70
-	.bDeviceProtocol           = 0,
71
-	.bMaxPacketSize0           = USB_DEVICE_EP_CTRL_SIZE,
72
-	.idVendor                  = LE16(USB_DEVICE_VENDOR_ID),
73
-	.idProduct                 = LE16(USB_DEVICE_PRODUCT_ID),
74
-	.bcdDevice                 = LE16((USB_DEVICE_MAJOR_VERSION << 8)
75
-		| USB_DEVICE_MINOR_VERSION),
67
+  .bLength                   = sizeof(usb_dev_desc_t),
68
+  .bDescriptorType           = USB_DT_DEVICE,
69
+  .bcdUSB                    = LE16(USB_V2_0),
70
+  .bDeviceClass              = 0,
71
+  .bDeviceSubClass           = 0,
72
+  .bDeviceProtocol           = 0,
73
+  .bMaxPacketSize0           = USB_DEVICE_EP_CTRL_SIZE,
74
+  .idVendor                  = LE16(USB_DEVICE_VENDOR_ID),
75
+  .idProduct                 = LE16(USB_DEVICE_PRODUCT_ID),
76
+  .bcdDevice                 = LE16((USB_DEVICE_MAJOR_VERSION << 8)
77
+    | USB_DEVICE_MINOR_VERSION),
76 78
 #ifdef USB_DEVICE_MANUFACTURE_NAME
77
-	.iManufacturer             = 1,
79
+  .iManufacturer             = 1,
78 80
 #else
79
-	.iManufacturer             = 0,  // No manufacture string
81
+  .iManufacturer             = 0,  // No manufacture string
80 82
 #endif
81 83
 #ifdef USB_DEVICE_PRODUCT_NAME
82
-	.iProduct                  = 2,
84
+  .iProduct                  = 2,
83 85
 #else
84
-	.iProduct                  = 0,  // No product string
86
+  .iProduct                  = 0,  // No product string
85 87
 #endif
86 88
 #if (defined USB_DEVICE_SERIAL_NAME || defined USB_DEVICE_GET_SERIAL_NAME_POINTER)
87
-	.iSerialNumber             = 3,
89
+  .iSerialNumber             = 3,
88 90
 #else
89
-	.iSerialNumber             = 0,  // No serial string
91
+  .iSerialNumber             = 0,  // No serial string
90 92
 #endif
91
-	.bNumConfigurations        = 1
93
+  .bNumConfigurations        = 1
92 94
 };
93 95
 
94 96
 
@@ -96,52 +98,52 @@ UDC_DESC_STORAGE usb_dev_desc_t udc_device_desc = {
96 98
 //! USB Device Qualifier Descriptor for HS
97 99
 COMPILER_WORD_ALIGNED
98 100
 UDC_DESC_STORAGE usb_dev_qual_desc_t udc_device_qual = {
99
-	.bLength                   = sizeof(usb_dev_qual_desc_t),
100
-	.bDescriptorType           = USB_DT_DEVICE_QUALIFIER,
101
-	.bcdUSB                    = LE16(USB_V2_0),
102
-	.bDeviceClass              = 0,
103
-	.bDeviceSubClass           = 0,
104
-	.bDeviceProtocol           = 0,
105
-	.bMaxPacketSize0           = USB_DEVICE_EP_CTRL_SIZE,
106
-	.bNumConfigurations        = 1
101
+  .bLength                   = sizeof(usb_dev_qual_desc_t),
102
+  .bDescriptorType           = USB_DT_DEVICE_QUALIFIER,
103
+  .bcdUSB                    = LE16(USB_V2_0),
104
+  .bDeviceClass              = 0,
105
+  .bDeviceSubClass           = 0,
106
+  .bDeviceProtocol           = 0,
107
+  .bMaxPacketSize0           = USB_DEVICE_EP_CTRL_SIZE,
108
+  .bNumConfigurations        = 1
107 109
 };
108 110
 #endif
109 111
 
110 112
 //! Structure for USB Device Configuration Descriptor
111 113
 COMPILER_PACK_SET(1)
112 114
 typedef struct {
113
-	usb_conf_desc_t conf;
114
-	UDI_COMPOSITE_DESC_T;
115
+  usb_conf_desc_t conf;
116
+  UDI_COMPOSITE_DESC_T;
115 117
 } udc_desc_t;
116 118
 COMPILER_PACK_RESET()
117 119
 
118 120
 //! USB Device Configuration Descriptor filled for FS
119 121
 COMPILER_WORD_ALIGNED
120 122
 UDC_DESC_STORAGE udc_desc_t udc_desc_fs = {
121
-	.conf.bLength              = sizeof(usb_conf_desc_t),
122
-	.conf.bDescriptorType      = USB_DT_CONFIGURATION,
123
-	.conf.wTotalLength         = LE16(sizeof(udc_desc_t)),
124
-	.conf.bNumInterfaces       = USB_DEVICE_NB_INTERFACE,
125
-	.conf.bConfigurationValue  = 1,
126
-	.conf.iConfiguration       = 0,
127
-	.conf.bmAttributes         = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR,
128
-	.conf.bMaxPower            = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER),
129
-	UDI_COMPOSITE_DESC_FS
123
+  .conf.bLength              = sizeof(usb_conf_desc_t),
124
+  .conf.bDescriptorType      = USB_DT_CONFIGURATION,
125
+  .conf.wTotalLength         = LE16(sizeof(udc_desc_t)),
126
+  .conf.bNumInterfaces       = USB_DEVICE_NB_INTERFACE,
127
+  .conf.bConfigurationValue  = 1,
128
+  .conf.iConfiguration       = 0,
129
+  .conf.bmAttributes         = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR,
130
+  .conf.bMaxPower            = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER),
131
+  UDI_COMPOSITE_DESC_FS
130 132
 };
131 133
 
132 134
 #ifdef USB_DEVICE_HS_SUPPORT
133 135
 //! USB Device Configuration Descriptor filled for HS
134 136
 COMPILER_WORD_ALIGNED
135 137
 UDC_DESC_STORAGE udc_desc_t udc_desc_hs = {
136
-	.conf.bLength              = sizeof(usb_conf_desc_t),
137
-	.conf.bDescriptorType      = USB_DT_CONFIGURATION,
138
-	.conf.wTotalLength         = LE16(sizeof(udc_desc_t)),
139
-	.conf.bNumInterfaces       = USB_DEVICE_NB_INTERFACE,
140
-	.conf.bConfigurationValue  = 1,
141
-	.conf.iConfiguration       = 0,
142
-	.conf.bmAttributes         = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR,
143
-	.conf.bMaxPower            = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER),
144
-	UDI_COMPOSITE_DESC_HS
138
+  .conf.bLength              = sizeof(usb_conf_desc_t),
139
+  .conf.bDescriptorType      = USB_DT_CONFIGURATION,
140
+  .conf.wTotalLength         = LE16(sizeof(udc_desc_t)),
141
+  .conf.bNumInterfaces       = USB_DEVICE_NB_INTERFACE,
142
+  .conf.bConfigurationValue  = 1,
143
+  .conf.iConfiguration       = 0,
144
+  .conf.bmAttributes         = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR,
145
+  .conf.bMaxPower            = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER),
146
+  UDI_COMPOSITE_DESC_HS
145 147
 };
146 148
 #endif
147 149
 
@@ -153,31 +155,31 @@ UDC_DESC_STORAGE udc_desc_t udc_desc_hs = {
153 155
 
154 156
 //! Associate an UDI for each USB interface
155 157
 UDC_DESC_STORAGE udi_api_t *udi_apis[USB_DEVICE_NB_INTERFACE] = {
156
-	UDI_COMPOSITE_API
158
+  UDI_COMPOSITE_API
157 159
 };
158 160
 
159 161
 //! Add UDI with USB Descriptors FS
160 162
 UDC_DESC_STORAGE udc_config_speed_t   udc_config_lsfs[1] = {{
161
-	.desc          = (usb_conf_desc_t UDC_DESC_STORAGE*)&udc_desc_fs,
162
-	.udi_apis      = udi_apis,
163
+  .desc          = (usb_conf_desc_t UDC_DESC_STORAGE*)&udc_desc_fs,
164
+  .udi_apis      = udi_apis,
163 165
 }};
164 166
 
165 167
 #ifdef USB_DEVICE_HS_SUPPORT
166 168
 //! Add UDI with USB Descriptors HS
167 169
 UDC_DESC_STORAGE udc_config_speed_t   udc_config_hs[1] = {{
168
-	.desc          = (usb_conf_desc_t UDC_DESC_STORAGE*)&udc_desc_hs,
169
-	.udi_apis      = udi_apis,
170
+  .desc          = (usb_conf_desc_t UDC_DESC_STORAGE*)&udc_desc_hs,
171
+  .udi_apis      = udi_apis,
170 172
 }};
171 173
 #endif
172 174
 
173 175
 //! Add all information about USB Device in global structure for UDC
174 176
 UDC_DESC_STORAGE udc_config_t udc_config = {
175
-	.confdev_lsfs = &udc_device_desc,
176
-	.conf_lsfs = udc_config_lsfs,
177
+  .confdev_lsfs = &udc_device_desc,
178
+  .conf_lsfs = udc_config_lsfs,
177 179
 #ifdef USB_DEVICE_HS_SUPPORT
178
-	.confdev_hs = &udc_device_desc,
179
-	.qualifier = &udc_device_qual,
180
-	.conf_hs = udc_config_hs,
180
+  .confdev_hs = &udc_device_desc,
181
+  .qualifier = &udc_device_qual,
182
+  .conf_hs = udc_config_hs,
181 183
 #endif
182 184
 };
183 185
 
@@ -185,4 +187,5 @@ UDC_DESC_STORAGE udc_config_t udc_config = {
185 187
 /**INDENT-ON**/
186 188
 //@}
187 189
 
190
+#endif
188 191
 #endif

+ 584
- 581
Marlin/src/HAL/HAL_DUE/usb/udi_msc.c
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 32
- 18
Marlin/src/HAL/HAL_DUE/usb/usb_task.c Целия файл

@@ -50,24 +50,30 @@
50 50
 #include <Arduino.h>
51 51
 #include <Reset.h>
52 52
 
53
-static volatile bool main_b_msc_enable = false;
53
+#if ENABLED(SDSUPPORT)
54
+  static volatile bool main_b_msc_enable = false;
55
+#endif
54 56
 static volatile bool main_b_cdc_enable = false;
55 57
 static volatile bool main_b_dtr_active = false;
56 58
 
57 59
 void HAL_idletask(void) {
58
-  // Attend SD card access from the USB MSD -- Prioritize access to improve speed
59
-  int delay = 2;
60
-  while (main_b_msc_enable && --delay > 0) {
61
-    if (udi_msc_process_trans()) delay = 10000;
62
-
63
-    // Reset the watchdog, just to be sure
64
-    REG_WDT_CR = WDT_CR_WDRSTT | WDT_CR_KEY(0xA5);
65
-  }
60
+  #if ENABLED(SDSUPPORT)
61
+    // Attend SD card access from the USB MSD -- Prioritize access to improve speed
62
+    int delay = 2;
63
+    while (main_b_msc_enable && --delay > 0) {
64
+      if (udi_msc_process_trans()) delay = 10000;
65
+
66
+      // Reset the watchdog, just to be sure
67
+      REG_WDT_CR = WDT_CR_WDRSTT | WDT_CR_KEY(0xA5);
68
+    }
69
+  #endif
66 70
 }
67 71
 
68
-bool usb_task_msc_enable(void)                { return ((main_b_msc_enable = true)); }
69
-void usb_task_msc_disable(void)               { main_b_msc_enable = false; }
70
-bool usb_task_msc_isenabled(void)             { return main_b_msc_enable; }
72
+#if ENABLED(SDSUPPORT)
73
+  bool usb_task_msc_enable(void)                { return ((main_b_msc_enable = true)); }
74
+  void usb_task_msc_disable(void)               { main_b_msc_enable = false; }
75
+  bool usb_task_msc_isenabled(void)             { return main_b_msc_enable; }
76
+#endif
71 77
 
72 78
 bool usb_task_cdc_enable(const uint8_t port)  { return ((main_b_cdc_enable = true)); }
73 79
 void usb_task_cdc_disable(const uint8_t port) { main_b_cdc_enable = false; main_b_dtr_active = false; }
@@ -192,11 +198,17 @@ static USB_MicrosoftExtendedPropertiesDescriptor microsoft_extended_properties_d
192 198
 bool usb_task_extra_string(void) {
193 199
   static uint8_t udi_msft_magic[] = "MSFT100\xEE";
194 200
   static uint8_t udi_cdc_name[] = "CDC interface";
195
-  static uint8_t udi_msc_name[] = "MSC interface";
201
+  #if ENABLED(SDSUPPORT)
202
+    static uint8_t udi_msc_name[] = "MSC interface";
203
+  #endif
196 204
 
197 205
   struct extra_strings_desc_t {
198 206
     usb_str_desc_t header;
199
-    le16_t string[Max(Max(sizeof(udi_cdc_name) - 1, sizeof(udi_msc_name) - 1), sizeof(udi_msft_magic) - 1)];
207
+    #if ENABLED(SDSUPPORT)
208
+      le16_t string[Max(Max(sizeof(udi_cdc_name) - 1, sizeof(udi_msc_name) - 1), sizeof(udi_msft_magic) - 1)];
209
+    #else
210
+      le16_t string[Max(sizeof(udi_cdc_name) - 1, sizeof(udi_msft_magic) - 1)];
211
+    #endif
200 212
   };
201 213
   static UDC_DESC_STORAGE struct extra_strings_desc_t extra_strings_desc = {
202 214
     .header.bDescriptorType = USB_DT_STRING
@@ -211,10 +223,12 @@ bool usb_task_extra_string(void) {
211 223
     str_lgt = sizeof(udi_cdc_name) - 1;
212 224
     str = udi_cdc_name;
213 225
     break;
214
-  case UDI_MSC_STRING_ID:
215
-    str_lgt = sizeof(udi_msc_name) - 1;
216
-    str = udi_msc_name;
217
-    break;
226
+  #if ENABLED(SDSUPPORT)
227
+    case UDI_MSC_STRING_ID:
228
+      str_lgt = sizeof(udi_msc_name) - 1;
229
+      str = udi_msc_name;
230
+      break;
231
+  #endif
218 232
   case 0xEE:
219 233
     str_lgt = sizeof(udi_msft_magic) - 1;
220 234
     str = udi_msft_magic;

Loading…
Отказ
Запис