flipperzero-firmware/firmware/targets/f6/usb-glue/usb_device.c
SG 153666f73f
F6: USB glue cleanup and fixes (#666)
* USB-CDC: accepting the next data packet only if we process previous data
* USB-CDC: use USB FS packet size
* HAL-console: puts method
* Check: print assertion data
* FuriHal: rx stream free space aware CDC confirmation.
* Bootloader: pull down USB lines, leave the rest to the firmware or bootloader
* F6: cleanup and move USB code to usb-glue folder, add USB suspend/resume events to VCP, cleanup target.mk, fix missing motd message in cli when using minicom.
* F5: cleanup the rest of USB glue code, adjust LPM and Power info data in descriptor.

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-22 13:43:45 +03:00

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();
}
}