|
47 | 47 | USBD_HandleTypeDefhUSBD_Device_CDC; |
48 | 48 |
|
49 | 49 | staticboolCDC_initialized= false; |
| 50 | +staticboolCDC_DTR_enabled= true; |
50 | 51 |
|
51 | 52 | /* Received Data over USB are stored in this buffer */ |
52 | 53 | CDC_TransmitQueue_TypeDefTransmitQueue; |
53 | 54 | CDC_ReceiveQueue_TypeDefReceiveQueue; |
54 | | -__IOuint32_tlineState=0; |
| 55 | +__IObooldtrState= false;/* lineState */ |
| 56 | +__IOboolrtsState= false; |
55 | 57 | __IOboolreceivePended= true; |
56 | 58 | staticuint32_ttransmitStart=0; |
57 | 59 |
|
@@ -183,11 +185,13 @@ static int8_t USBD_CDC_Control(uint8_t cmd, uint8_t *pbuf, uint16_t length) |
183 | 185 | break; |
184 | 186 |
|
185 | 187 | caseCDC_SET_CONTROL_LINE_STATE: |
186 | | -lineState= |
187 | | - (((USBD_SetupReqTypedef*)pbuf)->wValue&0x01)!=0;// Check DTR state |
188 | | -if (lineState) {// Reset the transmit timeout when the port is connected |
| 188 | +// Check DTR state |
| 189 | +dtrState= (CDC_DTR_enabled) ? (((USBD_SetupReqTypedef*)pbuf)->wValue&CLS_DTR) : true; |
| 190 | + |
| 191 | +if (dtrState) {// Reset the transmit timeout when the port is connected |
189 | 192 | transmitStart=0; |
190 | 193 | } |
| 194 | +rtsState= (((USBD_SetupReqTypedef*)pbuf)->wValue&CLS_RTS); |
191 | 195 | #ifdefDTR_TOGGLING_SEQ |
192 | 196 | dtr_toggling++;/* Count DTR toggling */ |
193 | 197 | #endif |
@@ -301,7 +305,7 @@ bool CDC_connected() |
301 | 305 | } |
302 | 306 | return ((hUSBD_Device_CDC.dev_state==USBD_STATE_CONFIGURED) |
303 | 307 | && (transmitTime<USB_CDC_TRANSMIT_TIMEOUT) |
304 | | -&&lineState); |
| 308 | +&&dtrState); |
305 | 309 | } |
306 | 310 |
|
307 | 311 | voidCDC_continue_transmit(void) |
@@ -350,6 +354,12 @@ bool CDC_resume_receive(void) |
350 | 354 | return false; |
351 | 355 | } |
352 | 356 |
|
| 357 | +voidCDC_enableDTR(boolenable) |
| 358 | +{ |
| 359 | +CDC_DTR_enabled=enable; |
| 360 | +dtrState= true; |
| 361 | +} |
| 362 | + |
353 | 363 | #endif/* USBD_USE_CDC */ |
354 | 364 | #endif/* USBCON */ |
355 | 365 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
|