@@ -65,13 +65,16 @@ struct usbd_cdc_acm_desc {
65
65
struct cdc_acm_descriptor if0_acm ;
66
66
struct cdc_union_descriptor if0_union ;
67
67
struct usb_ep_descriptor if0_int_ep ;
68
- struct usb_ep_descriptor if0_hs_int_ep ;
69
68
70
69
struct usb_if_descriptor if1 ;
71
70
struct usb_ep_descriptor if1_in_ep ;
72
71
struct usb_ep_descriptor if1_out_ep ;
72
+
73
+ #if USBD_SUPPORTS_HIGH_SPEED
74
+ struct usb_ep_descriptor if0_hs_int_ep ;
73
75
struct usb_ep_descriptor if1_hs_in_ep ;
74
76
struct usb_ep_descriptor if1_hs_out_ep ;
77
+ #endif
75
78
76
79
struct usb_desc_header nil_desc ;
77
80
};
@@ -197,45 +200,45 @@ static ALWAYS_INLINE int cdc_acm_work_schedule(struct k_work_delayable *work,
197
200
198
201
static uint8_t cdc_acm_get_int_in (struct usbd_class_data * const c_data )
199
202
{
200
- struct usbd_context * uds_ctx = usbd_class_get_ctx (c_data );
201
203
const struct device * dev = usbd_class_get_private (c_data );
202
204
const struct cdc_acm_uart_config * cfg = dev -> config ;
203
205
struct usbd_cdc_acm_desc * desc = cfg -> desc ;
204
206
205
- if ( USBD_SUPPORTS_HIGH_SPEED &&
206
- usbd_bus_speed (uds_ctx ) == USBD_SPEED_HS ) {
207
+ # if USBD_SUPPORTS_HIGH_SPEED
208
+ if ( usbd_bus_speed (usbd_class_get_ctx ( c_data ) ) == USBD_SPEED_HS ) {
207
209
return desc -> if0_hs_int_ep .bEndpointAddress ;
208
210
}
211
+ #endif
209
212
210
213
return desc -> if0_int_ep .bEndpointAddress ;
211
214
}
212
215
213
216
static uint8_t cdc_acm_get_bulk_in (struct usbd_class_data * const c_data )
214
217
{
215
- struct usbd_context * uds_ctx = usbd_class_get_ctx (c_data );
216
218
const struct device * dev = usbd_class_get_private (c_data );
217
219
const struct cdc_acm_uart_config * cfg = dev -> config ;
218
220
struct usbd_cdc_acm_desc * desc = cfg -> desc ;
219
221
220
- if ( USBD_SUPPORTS_HIGH_SPEED &&
221
- usbd_bus_speed (uds_ctx ) == USBD_SPEED_HS ) {
222
+ # if USBD_SUPPORTS_HIGH_SPEED
223
+ if ( usbd_bus_speed (usbd_class_get_ctx ( c_data ) ) == USBD_SPEED_HS ) {
222
224
return desc -> if1_hs_in_ep .bEndpointAddress ;
223
225
}
226
+ #endif
224
227
225
228
return desc -> if1_in_ep .bEndpointAddress ;
226
229
}
227
230
228
231
static uint8_t cdc_acm_get_bulk_out (struct usbd_class_data * const c_data )
229
232
{
230
- struct usbd_context * uds_ctx = usbd_class_get_ctx (c_data );
231
233
const struct device * dev = usbd_class_get_private (c_data );
232
234
const struct cdc_acm_uart_config * cfg = dev -> config ;
233
235
struct usbd_cdc_acm_desc * desc = cfg -> desc ;
234
236
235
- if ( USBD_SUPPORTS_HIGH_SPEED &&
236
- usbd_bus_speed (uds_ctx ) == USBD_SPEED_HS ) {
237
+ # if USBD_SUPPORTS_HIGH_SPEED
238
+ if ( usbd_bus_speed (usbd_class_get_ctx ( c_data ) ) == USBD_SPEED_HS ) {
237
239
return desc -> if1_hs_out_ep .bEndpointAddress ;
238
240
}
241
+ #endif
239
242
240
243
return desc -> if1_out_ep .bEndpointAddress ;
241
244
}
@@ -1148,6 +1151,34 @@ struct usbd_class_api usbd_cdc_acm_api = {
1148
1151
.get_desc = usbd_cdc_acm_get_desc ,
1149
1152
};
1150
1153
1154
+ #define CDC_ACM_DEFINE_DESCRIPTOR_HS (n ) \
1155
+ .if0_hs_int_ep = { \
1156
+ .bLength = sizeof(struct usb_ep_descriptor), \
1157
+ .bDescriptorType = USB_DESC_ENDPOINT, \
1158
+ .bEndpointAddress = 0x81, \
1159
+ .bmAttributes = USB_EP_TYPE_INTERRUPT, \
1160
+ .wMaxPacketSize = sys_cpu_to_le16(CDC_ACM_DEFAULT_INT_EP_MPS), \
1161
+ .bInterval = CDC_ACM_HS_INT_EP_INTERVAL, \
1162
+ }, \
1163
+ \
1164
+ .if1_hs_in_ep = { \
1165
+ .bLength = sizeof(struct usb_ep_descriptor), \
1166
+ .bDescriptorType = USB_DESC_ENDPOINT, \
1167
+ .bEndpointAddress = 0x82, \
1168
+ .bmAttributes = USB_EP_TYPE_BULK, \
1169
+ .wMaxPacketSize = sys_cpu_to_le16(512U), \
1170
+ .bInterval = 0, \
1171
+ }, \
1172
+ \
1173
+ .if1_hs_out_ep = { \
1174
+ .bLength = sizeof(struct usb_ep_descriptor), \
1175
+ .bDescriptorType = USB_DESC_ENDPOINT, \
1176
+ .bEndpointAddress = 0x01, \
1177
+ .bmAttributes = USB_EP_TYPE_BULK, \
1178
+ .wMaxPacketSize = sys_cpu_to_le16(512U), \
1179
+ .bInterval = 0, \
1180
+ },
1181
+
1151
1182
#define CDC_ACM_DEFINE_DESCRIPTOR (n ) \
1152
1183
static struct usbd_cdc_acm_desc cdc_acm_desc_##n = { \
1153
1184
.iad = { \
@@ -1213,15 +1244,6 @@ static struct usbd_cdc_acm_desc cdc_acm_desc_##n = { \
1213
1244
.bInterval = CDC_ACM_FS_INT_EP_INTERVAL, \
1214
1245
}, \
1215
1246
\
1216
- .if0_hs_int_ep = { \
1217
- .bLength = sizeof(struct usb_ep_descriptor), \
1218
- .bDescriptorType = USB_DESC_ENDPOINT, \
1219
- .bEndpointAddress = 0x81, \
1220
- .bmAttributes = USB_EP_TYPE_INTERRUPT, \
1221
- .wMaxPacketSize = sys_cpu_to_le16(CDC_ACM_DEFAULT_INT_EP_MPS), \
1222
- .bInterval = CDC_ACM_HS_INT_EP_INTERVAL, \
1223
- }, \
1224
- \
1225
1247
.if1 = { \
1226
1248
.bLength = sizeof(struct usb_if_descriptor), \
1227
1249
.bDescriptorType = USB_DESC_INTERFACE, \
@@ -1252,23 +1274,9 @@ static struct usbd_cdc_acm_desc cdc_acm_desc_##n = { \
1252
1274
.bInterval = 0, \
1253
1275
}, \
1254
1276
\
1255
- .if1_hs_in_ep = { \
1256
- .bLength = sizeof(struct usb_ep_descriptor), \
1257
- .bDescriptorType = USB_DESC_ENDPOINT, \
1258
- .bEndpointAddress = 0x82, \
1259
- .bmAttributes = USB_EP_TYPE_BULK, \
1260
- .wMaxPacketSize = sys_cpu_to_le16(512U), \
1261
- .bInterval = 0, \
1262
- }, \
1263
- \
1264
- .if1_hs_out_ep = { \
1265
- .bLength = sizeof(struct usb_ep_descriptor), \
1266
- .bDescriptorType = USB_DESC_ENDPOINT, \
1267
- .bEndpointAddress = 0x01, \
1268
- .bmAttributes = USB_EP_TYPE_BULK, \
1269
- .wMaxPacketSize = sys_cpu_to_le16(512U), \
1270
- .bInterval = 0, \
1271
- }, \
1277
+ COND_CODE_1(USBD_SUPPORTS_HIGH_SPEED, \
1278
+ (CDC_ACM_DEFINE_DESCRIPTOR_HS(n)), \
1279
+ ()) \
1272
1280
\
1273
1281
.nil_desc = { \
1274
1282
.bLength = 0, \
@@ -1288,8 +1296,9 @@ const static struct usb_desc_header *cdc_acm_fs_desc_##n[] = { \
1288
1296
(struct usb_desc_header *) &cdc_acm_desc_##n.if1_in_ep, \
1289
1297
(struct usb_desc_header *) &cdc_acm_desc_##n.if1_out_ep, \
1290
1298
(struct usb_desc_header *) &cdc_acm_desc_##n.nil_desc, \
1291
- }; \
1292
- \
1299
+ }
1300
+
1301
+ #define CDC_ACM_DEFINE_HS_DESC_HEADER (n ) \
1293
1302
const static struct usb_desc_header *cdc_acm_hs_desc_##n[] = { \
1294
1303
(struct usb_desc_header *) &cdc_acm_desc_##n.iad, \
1295
1304
(struct usb_desc_header *) &cdc_acm_desc_##n.if0, \
@@ -1302,14 +1311,17 @@ const static struct usb_desc_header *cdc_acm_hs_desc_##n[] = { \
1302
1311
(struct usb_desc_header *) &cdc_acm_desc_##n.if1_hs_in_ep, \
1303
1312
(struct usb_desc_header *) &cdc_acm_desc_##n.if1_hs_out_ep, \
1304
1313
(struct usb_desc_header *) &cdc_acm_desc_##n.nil_desc, \
1305
- }
1314
+ };
1306
1315
1307
1316
#define USBD_CDC_ACM_DT_DEVICE_DEFINE (n ) \
1308
1317
BUILD_ASSERT(DT_INST_ON_BUS(n, usb), \
1309
1318
"node " DT_NODE_PATH(DT_DRV_INST(n)) \
1310
1319
" is not assigned to a USB device controller"); \
1311
1320
\
1312
1321
CDC_ACM_DEFINE_DESCRIPTOR(n); \
1322
+ COND_CODE_1(USBD_SUPPORTS_HIGH_SPEED, \
1323
+ (CDC_ACM_DEFINE_HS_DESC_HEADER(n)), \
1324
+ ()) \
1313
1325
\
1314
1326
USBD_DEFINE_CLASS(cdc_acm_##n, \
1315
1327
&usbd_cdc_acm_api, \
@@ -1331,7 +1343,8 @@ const static struct usb_desc_header *cdc_acm_hs_desc_##n[] = { \
1331
1343
)) \
1332
1344
.desc = &cdc_acm_desc_##n, \
1333
1345
.fs_desc = cdc_acm_fs_desc_##n, \
1334
- .hs_desc = cdc_acm_hs_desc_##n, \
1346
+ .hs_desc = COND_CODE_1(USBD_SUPPORTS_HIGH_SPEED, \
1347
+ (cdc_acm_hs_desc_##n,), (NULL,)) \
1335
1348
}; \
1336
1349
\
1337
1350
static struct cdc_acm_uart_data uart_data_##n = { \
0 commit comments