summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-07-26 11:43:34 +0700
committerhathach <[email protected]>2019-07-26 11:43:34 +0700
commit4ed1a96311f0a6d97c381b020c4c60dcc49cccbf (patch)
tree2a1495a23cb7677465a420e9b26bc2e36327dd67 /examples
parentd2b60b67559e290e874797c55a34905ae8c620cc (diff)
webusb Always lit LED if connected
Diffstat (limited to 'examples')
-rw-r--r--examples/device/webusb/src/main.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/examples/device/webusb/src/main.c b/examples/device/webusb/src/main.c
index bf5598b18..e6bfe3802 100644
--- a/examples/device/webusb/src/main.c
+++ b/examples/device/webusb/src/main.c
@@ -42,8 +42,11 @@
*/
enum {
BLINK_NOT_MOUNTED = 250,
- BLINK_MOUNTED = 1000,
- BLINK_SUSPENDED = 2500,
+ BLINK_MOUNTED = 1000,
+ BLINK_SUSPENDED = 2500,
+
+ BLINK_ALWAYS_ON = UINT32_MAX,
+ BLINK_ALWAYS_OFF = 0
};
static uint32_t blink_interval_ms = BLINK_NOT_MOUNTED;
@@ -153,9 +156,18 @@ bool tud_vendor_control_request_cb(uint8_t rhport, tusb_control_request_t const
case 0x22:
// Webserial simulate the CDC_REQUEST_SET_CONTROL_LINE_STATE (0x22) to
// connect and disconnect.
-
web_serial_connected = (request->wValue != 0);
+ // Always lit LED if connected
+ if ( web_serial_connected )
+ {
+ board_led_write(true);
+ blink_interval_ms = BLINK_ALWAYS_ON;
+ }else
+ {
+ blink_interval_ms = BLINK_MOUNTED;
+ }
+
// response with status OK
return tud_control_status(rhport, request);