USB CDC: use new USBDeviceClass from SerialUSB
This commit is contained in:
parent
324c3df773
commit
caf6d0063e
|
@ -29,6 +29,10 @@
|
|||
#include <SerialUSB.h>
|
||||
#include "variant.h"
|
||||
|
||||
#include "USBDevice.h"
|
||||
|
||||
USBD_HandleTypeDef hUsbDeviceFS;
|
||||
|
||||
// Constructors ////////////////////////////////////////////////////////////////
|
||||
SerialUSBClass::SerialUSBClass(){
|
||||
// Make sure Rx ring buffer is initialized back to empty.
|
||||
|
@ -37,30 +41,7 @@ SerialUSBClass::SerialUSBClass(){
|
|||
}
|
||||
|
||||
void SerialUSBClass::init(void) {
|
||||
/* Re-enumerate the USB */
|
||||
volatile unsigned int i;
|
||||
|
||||
#ifdef USB_DISC_PIN
|
||||
pinMode(USB_DISC_PIN, OUTPUT);
|
||||
digitalWrite(USB_DISC_PIN, HIGH);
|
||||
for(i=0;i<512;i++);
|
||||
digitalWrite(USB_DISC_PIN, LOW);
|
||||
#else
|
||||
//pinMode(USBDP_PIN, OUTPUT);
|
||||
//digitalWrite(USBDP_PIN, LOW);
|
||||
//for(i=0;i<512;i++);
|
||||
//digitalWrite(USBDP_PIN, HIGH);
|
||||
|
||||
|
||||
pinMode(PA12, OUTPUT);
|
||||
digitalWrite(PA12, LOW);
|
||||
//HAL_Delay(1000);
|
||||
for(i=0;i<512;i++){};
|
||||
digitalWrite(PA12, HIGH);
|
||||
//HAL_Delay(1000);
|
||||
for(i=0;i<512;i++){};
|
||||
#endif
|
||||
MX_USB_DEVICE_Init();
|
||||
USBDeviceFS.beginCDC();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,21 +41,8 @@
|
|||
#include "cdc/usbd_cdc_if.h"
|
||||
|
||||
/* USB Device Core handle declaration */
|
||||
USBD_HandleTypeDef hUsbDeviceFS;
|
||||
|
||||
/* init function */
|
||||
void MX_USB_DEVICE_Init(void)
|
||||
{
|
||||
/* Init Device Library,Add Supported Class and Start the library*/
|
||||
USBD_Init(&hUsbDeviceFS, &CDC_Desc, DEVICE_FS);
|
||||
|
||||
USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC);
|
||||
|
||||
USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS);
|
||||
|
||||
USBD_Start(&hUsbDeviceFS);
|
||||
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue