|
23 | 23 | #include <stdio.h>
|
24 | 24 | #include <stdint.h>
|
25 | 25 |
|
| 26 | +uint8_t USB_TXLEDticks = 0, USB_RXLEDticks = 0; |
| 27 | + |
26 | 28 | #ifdef CDC_ENABLED
|
27 | 29 |
|
28 | 30 | #define CDC_SERIAL_BUFFER_SIZE 256
|
@@ -98,6 +100,12 @@ bool CDC_Setup(USBSetup& setup)
|
98 | 100 | uint8_t requestType = setup.bmRequestType;
|
99 | 101 | uint8_t r = setup.bRequest;
|
100 | 102 |
|
| 103 | + digitalWrite(PIN_LED_RXL, HIGH); |
| 104 | + digitalWrite(PIN_LED_TXL, HIGH); |
| 105 | + pinMode(PIN_LED_RXL, OUTPUT); |
| 106 | + pinMode(PIN_LED_TXL, OUTPUT); |
| 107 | + USB_TXLEDticks = USB_RXLEDticks = 0; |
| 108 | + |
101 | 109 | if (requestType == REQUEST_DEVICETOHOST_CLASS_INTERFACE)
|
102 | 110 | {
|
103 | 111 | if (r == CDC_GET_LINE_CODING)
|
@@ -209,6 +217,9 @@ int Serial_::read(void)
|
209 | 217 | {
|
210 | 218 | ring_buffer *buffer = &cdc_rx_buffer;
|
211 | 219 |
|
| 220 | + digitalWrite(PIN_LED_RXL, LOW); |
| 221 | + USB_RXLEDticks = 10; // how many ms to keep LED on |
| 222 | + |
212 | 223 | // if the head isn't ahead of the tail, we don't have any characters
|
213 | 224 | if (buffer->head == buffer->tail && !buffer->full)
|
214 | 225 | {
|
@@ -243,6 +254,9 @@ size_t Serial_::write(const uint8_t *buffer, size_t size)
|
243 | 254 | bytes sent before the user opens the connection or after
|
244 | 255 | the connection is closed are lost - just like with a UART. */
|
245 | 256 |
|
| 257 | + digitalWrite(PIN_LED_TXL, LOW); |
| 258 | + USB_TXLEDticks = 10; // how many ms to keep LED on |
| 259 | + |
246 | 260 | // TODO - ZE - check behavior on different OSes and test what happens if an
|
247 | 261 | // open connection isn't broken cleanly (cable is yanked out, host dies
|
248 | 262 | // or locks up, or host virtual serial port hangs)
|
|
0 commit comments