|
47 | 47 | USBD_HandleTypeDef hUSBD_Device_CDC;
|
48 | 48 |
|
49 | 49 | static bool CDC_initialized = false;
|
| 50 | +static bool CDC_DTR_enabled = true; |
50 | 51 |
|
51 | 52 | /* Received Data over USB are stored in this buffer */
|
52 | 53 | CDC_TransmitQueue_TypeDef TransmitQueue;
|
53 | 54 | CDC_ReceiveQueue_TypeDef ReceiveQueue;
|
54 |
| -__IO uint32_t lineState = 0; |
| 55 | +__IO bool dtrState = false; /* lineState */ |
| 56 | +__IO bool rtsState = false; |
55 | 57 | __IO bool receivePended = true;
|
56 | 58 | static uint32_t transmitStart = 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 | case CDC_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 | #ifdef DTR_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 | void CDC_continue_transmit(void)
|
@@ -350,6 +354,12 @@ bool CDC_resume_receive(void)
|
350 | 354 | return false;
|
351 | 355 | }
|
352 | 356 |
|
| 357 | +void CDC_enableDTR(bool enable) |
| 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****/
|
|
0 commit comments