Skip to content

Commit ecc259f

Browse files
committed
[USB] Add CDC to USBD interface
Signed-off-by: Frederic.Pillon <[email protected]>
1 parent 91d5830 commit ecc259f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

cores/arduino/stm32/usbd_interface.c

+21
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
#ifdef USBD_USE_HID_COMPOSITE
3939
#include "usbd_hid_composite.h"
4040
#endif
41+
#ifdef USBD_USE_CDC
42+
#include "usbd_cdc_if.h"
43+
#endif
4144

4245
#ifdef __cplusplus
4346
extern "C" {
@@ -47,6 +50,9 @@
4750
#ifdef USBD_USE_HID_COMPOSITE
4851
USBD_HandleTypeDef hUSBD_Device_HID;
4952
#endif /* USBD_USE_HID_COMPOSITE*/
53+
#ifdef USBD_USE_CDC
54+
USBD_HandleTypeDef hUSBD_Device_CDC;
55+
#endif /* USBD_USE_CDC */
5056

5157
/**
5258
* @brief initialize USB devices
@@ -65,6 +71,21 @@ void usbd_interface_init(void)
6571
/* Start Device Process */
6672
USBD_Start(&hUSBD_Device_HID);
6773
#endif /* USBD_USE_HID_COMPOSITE */
74+
#ifdef USBD_USE_CDC
75+
/* Init Device Library */
76+
if (USBD_Init(&hUSBD_Device_CDC, &CDC_Desc, 0) == USBD_OK) {
77+
78+
/* Add Supported Class */
79+
if (USBD_RegisterClass(&hUSBD_Device_CDC, USBD_CDC_CLASS) == USBD_OK) {
80+
81+
/* Add CDC Interface Class */
82+
if (USBD_CDC_RegisterInterface(&hUSBD_Device_CDC, &USBD_CDC_fops) == USBD_OK) {
83+
/* Start Device Process */
84+
USBD_Start(&hUSBD_Device_CDC);
85+
}
86+
}
87+
}
88+
#endif /* USBD_USE_CDC */
6889
}
6990

7091
#ifdef USBD_USE_HID_COMPOSITE

0 commit comments

Comments
 (0)