summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-12-09 11:15:13 +0700
committerhathach <[email protected]>2013-12-09 11:15:13 +0700
commite320659f8a4869a81e656285ed1263d8515aa7ee (patch)
treebf355e111ebfc710bf3c30a31919e6f98542bf2b /demos
parent1ad78f104ed87957bd4cf7e15029ab3e4e3cb377 (diff)
add keyboard led mask
make usbd control request to subtask add get/set report via control pipe to hidd enforce soft DMA to control pipe for lpc11u (lpc17xx not yet) temp add led_blinking_set_interval to change led blinking interval refractor dcd_pipe_control_xfer to have interrupt on complete option add get/set report support of moused_app and keyboardd_app, keyboard LED will make LED blink faster
Diffstat (limited to 'demos')
-rw-r--r--demos/device/device_os_none/keyboardd_app.c35
-rw-r--r--demos/device/device_os_none/main.c10
-rw-r--r--demos/device/device_os_none/moused_app.c13
-rw-r--r--demos/device/device_os_none/tusb_config.h2
4 files changed, 57 insertions, 3 deletions
diff --git a/demos/device/device_os_none/keyboardd_app.c b/demos/device/device_os_none/keyboardd_app.c
index 842099eb6..b072d7e12 100644
--- a/demos/device/device_os_none/keyboardd_app.c
+++ b/demos/device/device_os_none/keyboardd_app.c
@@ -80,6 +80,41 @@ void tusbd_hid_keyboard_cb(uint8_t coreid, tusb_event_t event, uint32_t xferred_
}
}
+uint16_t tusbd_hid_keyboard_get_report_cb(uint8_t coreid, hid_request_report_type_t report_type, void** pp_report, uint16_t requested_length)
+{
+ // get other than input report is not supported by this keyboard demo
+ if ( report_type != HID_REQUEST_REPORT_INPUT ) return 0;
+
+ (*pp_report) = &keyboard_report;
+ return requested_length;
+}
+
+void tusbd_hid_keyboard_set_report_cb(uint8_t coreid, hid_request_report_type_t report_type, uint8_t p_report_data[], uint16_t length)
+{
+ // set other than output report is not supported by this keyboard demo
+ if ( report_type != HID_REQUEST_REPORT_OUTPUT ) return;
+
+ uint8_t kbd_led = p_report_data[0];
+ uint32_t interval_divider = 1; // each LED will reduce blinking interval by a half
+
+ if (kbd_led & KEYBOARD_LED_NUMLOCK)
+ {
+ interval_divider *= 2;
+ }
+
+ if (kbd_led & KEYBOARD_LED_CAPSLOCK)
+ {
+ interval_divider *= 2;
+ }
+
+ if (kbd_led & KEYBOARD_LED_SCROLLLOCK)
+ {
+ interval_divider *= 2;
+ }
+
+ led_blinking_set_interval( 1000 / interval_divider);
+}
+
//--------------------------------------------------------------------+
// APPLICATION CODE
//--------------------------------------------------------------------+
diff --git a/demos/device/device_os_none/main.c b/demos/device/device_os_none/main.c
index 897b5f5be..c4e1d785e 100644
--- a/demos/device/device_os_none/main.c
+++ b/demos/device/device_os_none/main.c
@@ -108,7 +108,7 @@ int main(void)
#error need to start RTOS schduler
#endif
- while(1) { } // should not be reached here
+ while(1) { } // should not reach here
return 0;
}
@@ -116,13 +116,19 @@ int main(void)
//--------------------------------------------------------------------+
// BLINKING TASK
//--------------------------------------------------------------------+
+static uint32_t led_blink_interval_ms = 1000; // default is 1 seconda
+void led_blinking_set_interval(uint32_t ms)
+{
+ led_blink_interval_ms = ms;
+}
+
OSAL_TASK_FUNCTION( led_blinking_task ) (void* p_task_para)
{
OSAL_TASK_LOOP_BEGIN
static uint32_t led_on_mask = 0;
- osal_task_delay(1000);
+ osal_task_delay(led_blink_interval_ms);
board_leds(led_on_mask, 1 - led_on_mask);
led_on_mask = 1 - led_on_mask; // toggle
diff --git a/demos/device/device_os_none/moused_app.c b/demos/device/device_os_none/moused_app.c
index e9cc16998..dd6600131 100644
--- a/demos/device/device_os_none/moused_app.c
+++ b/demos/device/device_os_none/moused_app.c
@@ -80,6 +80,19 @@ void tusbd_hid_mouse_cb(uint8_t coreid, tusb_event_t event, uint32_t xferred_byt
}
}
+uint16_t tusbd_hid_mouse_get_report_cb(uint8_t coreid, hid_request_report_type_t report_type, void** pp_report, uint16_t requested_length)
+{
+ if ( report_type != HID_REQUEST_REPORT_INPUT ) return 0; // not support other report type for this mouse demo
+
+ (*pp_report) = &mouse_report;
+ return requested_length;
+}
+
+void tusbd_hid_mouse_set_report_cb(uint8_t coreid, hid_request_report_type_t report_type, uint8_t report_data[], uint16_t length)
+{
+ // mouse demo does not support set report --> return 0 will result in rejecting (STALL) this request
+ return 0;
+}
//--------------------------------------------------------------------+
// APPLICATION CODE
//--------------------------------------------------------------------+
diff --git a/demos/device/device_os_none/tusb_config.h b/demos/device/device_os_none/tusb_config.h
index c04aefcaa..899ee37f1 100644
--- a/demos/device/device_os_none/tusb_config.h
+++ b/demos/device/device_os_none/tusb_config.h
@@ -87,7 +87,7 @@
#define TUSB_CFG_DEVICE_HID_MOUSE 1
#define TUSB_CFG_DEVICE_HID_GENERIC 0
#define TUSB_CFG_DEVICE_MSC 0
-#define TUSB_CFG_DEVICE_CDC 0
+#define TUSB_CFG_DEVICE_CDC 1