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
This commit is contained in:
hathach
2013-12-09 11:15:13 +07:00
parent 1ad78f104e
commit e320659f8a
17 changed files with 263 additions and 159 deletions
@@ -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
//--------------------------------------------------------------------+
+8 -2
View File
@@ -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
+13
View File
@@ -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
//--------------------------------------------------------------------+
+1 -1
View File
@@ -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