35 lines
957 B
C
35 lines
957 B
C
|
#include "usb_device.h"
|
||
|
|
||
|
#include "stm32wbxx.h"
|
||
|
#include "stm32wbxx_hal.h"
|
||
|
|
||
|
#include "usbd_def.h"
|
||
|
#include "usbd_core.h"
|
||
|
#include "usbd_desc.h"
|
||
|
#include "usbd_cdc.h"
|
||
|
#include "usbd_cdc_if.h"
|
||
|
|
||
|
extern void Error_Handler(void);
|
||
|
|
||
|
/* USB Device Core handle declaration. */
|
||
|
USBD_HandleTypeDef hUsbDeviceFS;
|
||
|
|
||
|
extern USBD_DescriptorsTypeDef CDC_Desc;
|
||
|
|
||
|
/** Init USB device Library, add supported class and start the library */
|
||
|
void MX_USB_Device_Init(void) {
|
||
|
/* Init Device Library, add supported class and start the library. */
|
||
|
if (USBD_Init(&hUsbDeviceFS, &CDC_Desc, DEVICE_FS) != USBD_OK) {
|
||
|
Error_Handler();
|
||
|
}
|
||
|
if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) {
|
||
|
Error_Handler();
|
||
|
}
|
||
|
if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) {
|
||
|
Error_Handler();
|
||
|
}
|
||
|
if (USBD_Start(&hUsbDeviceFS) != USBD_OK) {
|
||
|
Error_Handler();
|
||
|
}
|
||
|
}
|