summaryrefslogtreecommitdiff
path: root/examples/device/cdc_msc_hid/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-04-19 00:23:15 +0700
committerhathach <[email protected]>2019-04-19 00:23:15 +0700
commit3e4bb141ce082a1325c7b63002fb29513850a1f8 (patch)
tree37d8c133c9d601157ce71e8e5c235c7f2fc94ef0 /examples/device/cdc_msc_hid/src
parent23bcf1cc7a38df4376a27f538604283571773cfc (diff)
update device freeRTOS exmaple
Diffstat (limited to 'examples/device/cdc_msc_hid/src')
-rw-r--r--examples/device/cdc_msc_hid/src/main.c28
-rw-r--r--examples/device/cdc_msc_hid/src/tusb_config.h5
2 files changed, 20 insertions, 13 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;
}
//--------------------------------------------------------------------+
diff --git a/examples/device/cdc_msc_hid/src/tusb_config.h b/examples/device/cdc_msc_hid/src/tusb_config.h
index 13709f5d1..2614bcb6f 100644
--- a/examples/device/cdc_msc_hid/src/tusb_config.h
+++ b/examples/device/cdc_msc_hid/src/tusb_config.h
@@ -46,8 +46,8 @@
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
#endif
-#define CFG_TUSB_DEBUG 2
#define CFG_TUSB_OS OPT_OS_NONE
+#define CFG_TUSB_DEBUG 2
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
* Tinyusb use follows macros to declare transferring memory so that they can be put
@@ -67,6 +67,7 @@
//--------------------------------------------------------------------
// DEVICE CONFIGURATION
//--------------------------------------------------------------------
+
#define CFG_TUD_ENDOINT0_SIZE 64
//------------- CLASS -------------//
@@ -88,6 +89,7 @@
//--------------------------------------------------------------------
// MSC
//--------------------------------------------------------------------
+
// Number of supported Logical Unit Number (At least 1)
#define CFG_TUD_MSC_MAXLUN 1
@@ -113,7 +115,6 @@
*/
#define CFG_TUD_HID_ASCII_TO_KEYCODE_LOOKUP 1
-
#ifdef __cplusplus
}
#endif