summaryrefslogtreecommitdiff
path: root/examples/device/cdc_msc_hid/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-03-27 08:52:25 -0700
committerGitHub <[email protected]>2019-03-27 08:52:25 -0700
commit86c24b310509a368cc6a9dfbec43ce531e71d598 (patch)
tree81fec0b3724083a3515ef09e0b7d601ce01ec621 /examples/device/cdc_msc_hid/src
parent547cc045fa1d8862e7e00c1d7b4a0026531d0098 (diff)
parent38f7d281d44c69593f1de3885a292ee7c5c39355 (diff)
Merge pull request #49 from hathach/develop
clean up porting API
Diffstat (limited to 'examples/device/cdc_msc_hid/src')
-rw-r--r--examples/device/cdc_msc_hid/src/main.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/examples/device/cdc_msc_hid/src/main.c b/examples/device/cdc_msc_hid/src/main.c
index b2a902835..75d9a31dc 100644
--- a/examples/device/cdc_msc_hid/src/main.c
+++ b/examples/device/cdc_msc_hid/src/main.c
@@ -121,10 +121,11 @@ void tud_cdc_rx_cb(uint8_t itf)
void usb_hid_task(void)
{
// Poll every 10ms
- static tu_timeout_t tm = { .start = 0, .interval = 10 };
+ const uint32_t interval_ms = 10;
+ static uint32_t start_ms = 0;
- if ( !tu_timeout_expired(&tm) ) return; // not enough time
- tu_timeout_reset(&tm);
+ if ( board_millis() < start_ms + interval_ms) return; // not enough time
+ start_ms += interval_ms;
uint32_t const btn = board_buttons();
@@ -193,11 +194,14 @@ void tud_umount_cb(void)
//--------------------------------------------------------------------+
void led_blinking_task(void)
{
- static tu_timeout_t tm = { .start = 0, .interval = 1000 }; // Blink every 1000 ms
+ const uint32_t interval_ms = 1000;
+ static uint32_t start_ms = 0;
+
static bool led_state = false;
- if ( !tu_timeout_expired(&tm) ) return; // not enough time
- tu_timeout_reset(&tm);
+ // Blink every 1000 ms
+ if ( board_millis() < start_ms + interval_ms) return; // not enough time
+ start_ms += interval_ms;
board_led_control(led_state);
led_state = 1 - led_state; // toggle