diff options
| author | hathach <[email protected]> | 2013-10-30 12:20:00 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-10-30 12:20:00 +0700 |
| commit | d67a7b7959342e93c6ae63d5dac5149dec76d0e6 (patch) | |
| tree | 2c98b03f52b1b0654d758201958f3af30fa3c84f /tinyusb/class | |
| parent | d9ce879df84f6098e431736a297d4239d6f8eb2a (diff) | |
fix dcd_data declared with TUSB_CFG_ATTR_USBRAM
fix lpc43xx UM: non-control unused endpoint type should be set to different than control in ENDPTCTRL
add hid mouse device
fix mouse descriptor with vertical wheel support
Diffstat (limited to 'tinyusb/class')
| -rw-r--r-- | tinyusb/class/hid_device.c | 54 | ||||
| -rw-r--r-- | tinyusb/class/hid_device.h | 4 |
2 files changed, 41 insertions, 17 deletions
diff --git a/tinyusb/class/hid_device.c b/tinyusb/class/hid_device.c index 20e0d0407..52dc8bdc7 100644 --- a/tinyusb/class/hid_device.c +++ b/tinyusb/class/hid_device.c @@ -59,43 +59,65 @@ typedef struct { uint8_t interface_number; uint8_t idle_rate; // need to be in usb ram - hid_keyboard_report_t report; + hid_keyboard_report_t report; // need to be in usb ram }hidd_interface_t; + +//--------------------------------------------------------------------+ +// KEYBOARD APPLICATION API +//--------------------------------------------------------------------+ #if TUSB_CFG_DEVICE_HID_KEYBOARD STATIC_VAR TUSB_CFG_ATTR_USBRAM hidd_interface_t keyboardd_data = { .p_report_desc = app_tusb_keyboard_desc_report }; + +bool tusbd_hid_keyboard_is_busy(uint8_t coreid) +{ + return dcd_pipe_is_busy(keyboardd_data.ept_handle); +} + +tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const *p_report) +{ + //------------- verify data -------------// + + hidd_interface_t * p_kbd = &keyboardd_data; // TODO &keyboardd_data[coreid]; + + ASSERT_STATUS( dcd_pipe_xfer(p_kbd->ept_handle, p_report, sizeof(hid_keyboard_report_t), false) ) ; + + return TUSB_ERROR_NONE; +} #endif +//--------------------------------------------------------------------+ +// MOUSE APPLICATION API +//--------------------------------------------------------------------+ #if TUSB_CFG_DEVICE_HID_MOUSE STATIC_VAR TUSB_CFG_ATTR_USBRAM hidd_interface_t moused_data = { .p_report_desc = app_tusb_mouse_desc_report }; -#endif - -//--------------------------------------------------------------------+ -// APPLICATION API -//--------------------------------------------------------------------+ -bool tusbd_hid_keyboard_is_busy(uint8_t coreid) +bool tusbd_hid_mouse_is_busy(uint8_t coreid) { - return dcd_pipe_is_busy(keyboardd_data.ept_handle); + return dcd_pipe_is_busy(moused_data.ept_handle); } -tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const *p_kbd_report) + +tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_report) { //------------- verify data -------------// - hidd_interface_t * p_kbd = &keyboardd_data; // TODO &keyboardd_data[coreid]; + hidd_interface_t * p_mouse = &moused_data; // TODO &keyboardd_data[coreid]; - ASSERT_STATUS( dcd_pipe_xfer(p_kbd->ept_handle, p_kbd_report, sizeof(hid_keyboard_report_t), false) ) ; + ASSERT_STATUS( dcd_pipe_xfer(p_mouse->ept_handle, p_report, sizeof(hid_mouse_report_t), false) ) ; return TUSB_ERROR_NONE; } +#endif + + //--------------------------------------------------------------------+ // USBD-CLASS API //--------------------------------------------------------------------+ @@ -105,7 +127,7 @@ tusb_error_t hidd_control_request(uint8_t coreid, tusb_control_request_t const * #if TUSB_CFG_DEVICE_HID_KEYBOARD (p_request->wIndex == keyboardd_data.interface_number) ? &keyboardd_data : #endif - #if TUSB_CFG_DEVICE_HID_KEYBOARD + #if TUSB_CFG_DEVICE_HID_MOUSE (p_request->wIndex == moused_data.interface_number) ? &moused_data : #endif NULL; @@ -183,8 +205,8 @@ tusb_error_t hidd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_int // memclr_(&keyboardd_data, sizeof(hidd_interface_t)); keyboardd_data.interface_number = p_interface_desc->bInterfaceNumber; - keyboardd_data.report_length = p_desc_hid->wReportLength; - keyboardd_data.ept_handle = dcd_pipe_open(coreid, p_desc_endpoint); + keyboardd_data.report_length = p_desc_hid->wReportLength; + keyboardd_data.ept_handle = dcd_pipe_open(coreid, p_desc_endpoint); ASSERT( endpointhandle_is_valid(keyboardd_data.ept_handle), TUSB_ERROR_DCD_FAILED); break; #endif @@ -192,8 +214,8 @@ tusb_error_t hidd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_int #if TUSB_CFG_DEVICE_HID_MOUSE case HID_PROTOCOL_MOUSE: moused_data.interface_number = p_interface_desc->bInterfaceNumber; - moused_data.report_length = p_desc_hid->wReportLength; - moused_data.ept_handle = dcd_pipe_open(coreid, p_desc_endpoint); + moused_data.report_length = p_desc_hid->wReportLength; + moused_data.ept_handle = dcd_pipe_open(coreid, p_desc_endpoint); ASSERT( endpointhandle_is_valid(moused_data.ept_handle), TUSB_ERROR_DCD_FAILED); break; #endif diff --git a/tinyusb/class/hid_device.h b/tinyusb/class/hid_device.h index 9cf65af58..c3b0f041a 100644 --- a/tinyusb/class/hid_device.h +++ b/tinyusb/class/hid_device.h @@ -100,7 +100,9 @@ void tusbd_hid_keyboard_isr(uint8_t coreid, tusb_event_t event); /** \defgroup Mouse_Device Device * @{ */ -tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_mouse_report); +bool tusbd_hid_mouse_is_busy(uint8_t coreid); + +tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_report); /** @} */ /** @} */ |
