USB Device library for the STM32F103 with USB Device Firmware Upgrade (DFU) runtime support.
Dependents: STM32F103C8T6_WebUSBDFU STM32F103C8T6_USBDFU STM32F103C8T6_USBDFU dfu_usb_stm32f103
Fork of USBDevice_STM32F103 by
Diff: USBSerial/USBCDC.cpp
- Revision:
- 65:48fe9050cb4a
- Parent:
- 44:d2638fcd76d9
diff -r c3d0530b6d82 -r 48fe9050cb4a USBSerial/USBCDC.cpp --- a/USBSerial/USBCDC.cpp Thu Jun 25 09:33:51 2015 +0900 +++ b/USBSerial/USBCDC.cpp Fri Jul 08 21:16:25 2016 +0000 @@ -27,15 +27,11 @@ #define CDC_GET_LINE_CODING 0x21 #define CDC_SET_CONTROL_LINE_STATE 0x22 -// Control Line State bits -#define CLS_DTR (1 << 0) -#define CLS_RTS (1 << 1) - #define MAX_CDC_REPORT_SIZE MAX_PACKET_SIZE_EPBULK -USBCDC::USBCDC(uint16_t vendor_id, uint16_t product_id, uint16_t product_release, bool connect_blocking): USBDevice(vendor_id, product_id, product_release) { +USBCDC::USBCDC(uint16_t vendor_id, uint16_t product_id, uint16_t product_release): USBDevice(vendor_id, product_id, product_release) { terminal_connected = false; - USBDevice::connect(connect_blocking); + USBDevice::connect(); } bool USBCDC::USBCallback_request(void) { @@ -56,15 +52,11 @@ break; case CDC_SET_LINE_CODING: transfer->remaining = 7; - transfer->notify = true; success = true; + terminal_connected = true; break; case CDC_SET_CONTROL_LINE_STATE: - if (transfer->setup.wValue & CLS_DTR) { - terminal_connected = true; - } else { - terminal_connected = false; - } + terminal_connected = false; success = true; break; default: @@ -75,31 +67,6 @@ return success; } -void USBCDC::USBCallback_requestCompleted(uint8_t *buf, uint32_t length) { - // Request of setting line coding has 7 bytes - if (length != 7) { - return; - } - - CONTROL_TRANSFER * transfer = getTransferPtr(); - - /* Process class-specific requests */ - if (transfer->setup.bmRequestType.Type == CLASS_TYPE) { - if (transfer->setup.bRequest == CDC_SET_LINE_CODING) { - if (memcmp(cdc_line_coding, buf, 7)) { - memcpy(cdc_line_coding, buf, 7); - - int baud = buf[0] + (buf[1] << 8) - + (buf[2] << 16) + (buf[3] << 24); - int stop = buf[4]; - int bits = buf[6]; - int parity = buf[5]; - - lineCodingChanged(baud, bits, parity, stop); - } - } - } -} // Called in ISR context // Set configuration. Return false if the @@ -149,8 +116,8 @@ 0, // bDeviceSubClass 0, // bDeviceProtocol MAX_PACKET_SIZE_EP0, // bMaxPacketSize0 - (uint8_t)(LSB(VENDOR_ID)), (uint8_t)(MSB(VENDOR_ID)), // idVendor - (uint8_t)(LSB(PRODUCT_ID)), (uint8_t)(MSB(PRODUCT_ID)),// idProduct + LSB(VENDOR_ID), MSB(VENDOR_ID), // idVendor + LSB(PRODUCT_ID), MSB(PRODUCT_ID),// idProduct 0x00, 0x01, // bcdDevice 1, // iManufacturer 2, // iProduct @@ -193,7 +160,7 @@ 0, // iConfiguration 0x80, // bmAttributes 50, // bMaxPower - + // IAD to associate the two CDC interfaces 0x08, // bLength 0x0b, // bDescriptorType