diff options
| author | hathach <[email protected]> | 2019-04-19 00:23:15 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2019-04-19 00:23:15 +0700 |
| commit | 3e4bb141ce082a1325c7b63002fb29513850a1f8 (patch) | |
| tree | 37d8c133c9d601157ce71e8e5c235c7f2fc94ef0 /examples/device/cdc_msc_hid/src/main.c | |
| parent | 23bcf1cc7a38df4376a27f538604283571773cfc (diff) | |
update device freeRTOS exmaple
Diffstat (limited to 'examples/device/cdc_msc_hid/src/main.c')
| -rw-r--r-- | examples/device/cdc_msc_hid/src/main.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/examples/device/cdc_msc_hid/src/main.c b/examples/device/cdc_msc_hid/src/main.c index 99e9ff690..c5e7a3068 100644 --- a/examples/device/cdc_msc_hid/src/main.c +++ b/examples/device/cdc_msc_hid/src/main.c @@ -40,12 +40,18 @@ * - 1000 ms : device mounted * - 2500 ms : device is suspended */ -static uint32_t blink_interval_ms = 250; +enum { + BLINK_NOT_MOUNTED = 250, + BLINK_MOUNTED = 1000, + BLINK_SUSPENDED = 2500, +}; + +static uint32_t blink_interval_ms = BLINK_NOT_MOUNTED; void led_blinking_task(void); -extern void virtual_com_task(void); -extern void usb_hid_task(void); +extern void cdc_task(void); +extern void hid_task(void); /*------------- MAIN -------------*/ int main(void) @@ -62,11 +68,11 @@ int main(void) led_blinking_task(); #if CFG_TUD_CDC - virtual_com_task(); + cdc_task(); #endif #if CFG_TUD_HID - usb_hid_task(); + hid_task(); #endif } @@ -77,7 +83,7 @@ int main(void) // USB CDC //--------------------------------------------------------------------+ #if CFG_TUD_CDC -void virtual_com_task(void) +void cdc_task(void) { if ( tud_cdc_connected() ) { @@ -134,7 +140,7 @@ enum REPORT_ID_MOUSE }; -void usb_hid_task(void) +void hid_task(void) { // Poll every 10ms const uint32_t interval_ms = 10; @@ -218,13 +224,13 @@ void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uin // Invoked when device is mounted void tud_mount_cb(void) { - blink_interval_ms = 1000; + blink_interval_ms = BLINK_MOUNTED; } // Invoked when device is unmounted void tud_umount_cb(void) { - blink_interval_ms = 250; + blink_interval_ms = BLINK_NOT_MOUNTED; } // Invoked when usb bus is suspended @@ -233,13 +239,13 @@ void tud_umount_cb(void) void tud_suspend_cb(bool remote_wakeup_en) { (void) remote_wakeup_en; - blink_interval_ms = 2500; + blink_interval_ms = BLINK_SUSPENDED; } // Invoked when usb bus is resumed void tud_resume_cb(void) { - blink_interval_ms = 1000; + blink_interval_ms = BLINK_MOUNTED; } //--------------------------------------------------------------------+ |
