diff options
| author | hathach <[email protected]> | 2018-03-07 23:40:54 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-03-07 23:40:54 +0700 |
| commit | bd5f9ecdec79eef1c7c45647ad16cf566f572148 (patch) | |
| tree | 33f73bf758d353b4c9cad896974ed4d4d66e8774 /examples/device/device_virtual_com/src/main.c | |
| parent | d0312805ba245b71a2089d72c4b6c89a49b2933a (diff) | |
rename tusb_tick_get to hal_tick_get
Diffstat (limited to 'examples/device/device_virtual_com/src/main.c')
| -rw-r--r-- | examples/device/device_virtual_com/src/main.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/examples/device/device_virtual_com/src/main.c b/examples/device/device_virtual_com/src/main.c index c576b2f4f..c512f7c05 100644 --- a/examples/device/device_virtual_com/src/main.c +++ b/examples/device/device_virtual_com/src/main.c @@ -65,7 +65,6 @@ int main(void) tusb_init(); //------------- application task init -------------// - led_blinking_init(); cdc_serial_app_init(); while (1) @@ -93,6 +92,25 @@ void tud_umount_cb(uint8_t coreid) } //--------------------------------------------------------------------+ +// BLINKING TASK +//--------------------------------------------------------------------+ +void led_blinking_task(void) +{ + enum { BLINK_INTEVAL = 1000 }; + + static uint32_t led_on_mask = 0; + static uint32_t last_blink = 0; + + // not enough time + if ( last_blink + BLINK_INTEVAL > hal_tick_get() ) return; + + last_blink += BLINK_INTEVAL; + + board_leds(led_on_mask, 1 - led_on_mask); + led_on_mask = 1 - led_on_mask; // toggle +} + +//--------------------------------------------------------------------+ // HELPER FUNCTION //--------------------------------------------------------------------+ void print_greeting(void) |
