Refactor serial_usb_vcp.c for clarity
This commit is contained in:
parent
1edb5411d9
commit
b47a95d478
|
@ -30,14 +30,14 @@
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
|
|
||||||
#include "drivers/io.h"
|
#include "drivers/io.h"
|
||||||
|
#include "pg/pg.h"
|
||||||
|
#include "pg/usb.h"
|
||||||
|
|
||||||
#if defined(STM32F4)
|
#if defined(STM32F4)
|
||||||
#include "usb_core.h"
|
#include "usb_core.h"
|
||||||
#include "usbd_cdc_vcp.h"
|
#include "usbd_cdc_vcp.h"
|
||||||
#ifdef USE_USB_CDC_HID
|
#ifdef USE_USB_CDC_HID
|
||||||
#include "usbd_hid_cdc_wrapper.h"
|
#include "usbd_hid_cdc_wrapper.h"
|
||||||
#include "pg/pg.h"
|
|
||||||
#include "pg/usb.h"
|
|
||||||
#endif
|
#endif
|
||||||
#include "usb_io.h"
|
#include "usb_io.h"
|
||||||
#elif defined(STM32F7)
|
#elif defined(STM32F7)
|
||||||
|
@ -45,8 +45,6 @@
|
||||||
#include "usb_io.h"
|
#include "usb_io.h"
|
||||||
#ifdef USE_USB_CDC_HID
|
#ifdef USE_USB_CDC_HID
|
||||||
#include "usbd_cdc_hid.h"
|
#include "usbd_cdc_hid.h"
|
||||||
#include "pg/pg.h"
|
|
||||||
#include "pg/usb.h"
|
|
||||||
#endif
|
#endif
|
||||||
USBD_HandleTypeDef USBD_Device;
|
USBD_HandleTypeDef USBD_Device;
|
||||||
#else
|
#else
|
||||||
|
@ -220,36 +218,38 @@ serialPort_t *usbVcpOpen(void)
|
||||||
{
|
{
|
||||||
vcpPort_t *s;
|
vcpPort_t *s;
|
||||||
|
|
||||||
|
IOInit(IOGetByTag(IO_TAG(PA11)), OWNER_USB, 0);
|
||||||
|
IOInit(IOGetByTag(IO_TAG(PA12)), OWNER_USB, 0);
|
||||||
|
|
||||||
#if defined(STM32F4)
|
#if defined(STM32F4)
|
||||||
usbGenerateDisconnectPulse();
|
usbGenerateDisconnectPulse();
|
||||||
|
|
||||||
IOInit(IOGetByTag(IO_TAG(PA11)), OWNER_USB, 0);
|
switch (usbDevConfig()->type) {
|
||||||
IOInit(IOGetByTag(IO_TAG(PA12)), OWNER_USB, 0);
|
|
||||||
#ifdef USE_USB_CDC_HID
|
#ifdef USE_USB_CDC_HID
|
||||||
if (usbDevConfig()->type == COMPOSITE) {
|
case COMPOSITE:
|
||||||
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_HID_CDC_cb, &USR_cb);
|
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_HID_CDC_cb, &USR_cb);
|
||||||
} else {
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
default:
|
||||||
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb);
|
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb);
|
||||||
#ifdef USE_USB_CDC_HID
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#elif defined(STM32F7)
|
#elif defined(STM32F7)
|
||||||
usbGenerateDisconnectPulse();
|
usbGenerateDisconnectPulse();
|
||||||
|
|
||||||
IOInit(IOGetByTag(IO_TAG(PA11)), OWNER_USB, 0);
|
|
||||||
IOInit(IOGetByTag(IO_TAG(PA12)), OWNER_USB, 0);
|
|
||||||
/* Init Device Library */
|
/* Init Device Library */
|
||||||
USBD_Init(&USBD_Device, &VCP_Desc, 0);
|
USBD_Init(&USBD_Device, &VCP_Desc, 0);
|
||||||
|
|
||||||
/* Add Supported Class */
|
/* Add Supported Class */
|
||||||
|
switch (usbDevConfig()->type) {
|
||||||
#ifdef USE_USB_CDC_HID
|
#ifdef USE_USB_CDC_HID
|
||||||
if (usbDevConfig()->type == COMPOSITE) {
|
case COMPOSITE:
|
||||||
USBD_RegisterClass(&USBD_Device, USBD_HID_CDC_CLASS);
|
USBD_RegisterClass(&USBD_Device, USBD_HID_CDC_CLASS);
|
||||||
} else
|
break;
|
||||||
#endif
|
#endif
|
||||||
{
|
default:
|
||||||
USBD_RegisterClass(&USBD_Device, USBD_CDC_CLASS);
|
USBD_RegisterClass(&USBD_Device, USBD_CDC_CLASS);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* HID Interface doesn't have any callbacks... */
|
/* HID Interface doesn't have any callbacks... */
|
||||||
|
|
Loading…
Reference in New Issue