USB CDC: use new USBDeviceClass from SerialUSB
This commit is contained in:
parent
324c3df773
commit
caf6d0063e
|
@ -29,6 +29,10 @@
|
||||||
#include <SerialUSB.h>
|
#include <SerialUSB.h>
|
||||||
#include "variant.h"
|
#include "variant.h"
|
||||||
|
|
||||||
|
#include "USBDevice.h"
|
||||||
|
|
||||||
|
USBD_HandleTypeDef hUsbDeviceFS;
|
||||||
|
|
||||||
// Constructors ////////////////////////////////////////////////////////////////
|
// Constructors ////////////////////////////////////////////////////////////////
|
||||||
SerialUSBClass::SerialUSBClass(){
|
SerialUSBClass::SerialUSBClass(){
|
||||||
// Make sure Rx ring buffer is initialized back to empty.
|
// Make sure Rx ring buffer is initialized back to empty.
|
||||||
|
@ -36,31 +40,8 @@ SerialUSBClass::SerialUSBClass(){
|
||||||
//tx_buffer.iHead = tx_buffer.iTail = 0;
|
//tx_buffer.iHead = tx_buffer.iTail = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SerialUSBClass::init(void){
|
void SerialUSBClass::init(void) {
|
||||||
/* Re-enumerate the USB */
|
USBDeviceFS.beginCDC();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,21 +41,8 @@
|
||||||
#include "cdc/usbd_cdc_if.h"
|
#include "cdc/usbd_cdc_if.h"
|
||||||
|
|
||||||
/* USB Device Core handle declaration */
|
/* USB Device Core handle declaration */
|
||||||
USBD_HandleTypeDef hUsbDeviceFS;
|
|
||||||
|
|
||||||
/* init function */
|
/* 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