summaryrefslogtreecommitdiff
path: root/tinyusb
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-11-21 13:54:29 +0700
committerhathach <[email protected]>2013-11-21 13:54:29 +0700
commitc303154b7a2af8e934308d9115e7b6da23c66419 (patch)
treeed00100b5b0f6b71789702f8f1eee404b8639aed /tinyusb
parentc461c72ac2ddf6f89ba533e98f34bba72f8c1470 (diff)
add class mounted callback for hid mouse/keyboard & refractor mouse/keyboard app
Diffstat (limited to 'tinyusb')
-rw-r--r--tinyusb/class/hid_device.c17
-rw-r--r--tinyusb/device/usbd.c2
-rw-r--r--tinyusb/osal/osal_none.h2
3 files changed, 15 insertions, 6 deletions
diff --git a/tinyusb/class/hid_device.c b/tinyusb/class/hid_device.c
index 4b184c9ad..8872f042b 100644
--- a/tinyusb/class/hid_device.c
+++ b/tinyusb/class/hid_device.c
@@ -78,7 +78,7 @@ bool tusbd_hid_keyboard_is_busy(uint8_t coreid)
tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const *p_report)
{
- //------------- verify data -------------//
+ ASSERT(tusbd_is_configured(coreid), TUSB_ERROR_USBD_DEVICE_NOT_CONFIGURED);
hidd_interface_t * p_kbd = &keyboardd_data; // TODO &keyboardd_data[coreid];
@@ -104,7 +104,7 @@ 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)
{
- //------------- verify data -------------//
+ ASSERT(tusbd_is_configured(coreid), TUSB_ERROR_USBD_DEVICE_NOT_CONFIGURED);
hidd_interface_t * p_mouse = &moused_data; // TODO &keyboardd_data[coreid];
@@ -226,10 +226,19 @@ tusb_error_t hidd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_int
ASSERT_PTR(p_hid, TUSB_ERROR_FAILED);
- p_hid->interface_number = p_interface_desc->bInterfaceNumber;
- p_hid->report_length = p_desc_hid->wReportLength;
p_hid->ept_handle = dcd_pipe_open(coreid, p_desc_endpoint, p_interface_desc->bInterfaceClass);
ASSERT( endpointhandle_is_valid(p_hid->ept_handle), TUSB_ERROR_DCD_FAILED);
+
+ p_hid->interface_number = p_interface_desc->bInterfaceNumber;
+ p_hid->report_length = p_desc_hid->wReportLength;
+
+ if (p_interface_desc->bInterfaceProtocol == HID_PROTOCOL_KEYBOARD)
+ {
+ tusbd_hid_keyboard_mounted_cb(coreid);
+ }else
+ {
+ tusbd_hid_mouse_mounted_cb(coreid);
+ }
}
break;
diff --git a/tinyusb/device/usbd.c b/tinyusb/device/usbd.c
index aefdb78e1..fd62874b3 100644
--- a/tinyusb/device/usbd.c
+++ b/tinyusb/device/usbd.c
@@ -163,7 +163,7 @@ tusb_error_t usbd_body_subtask(void)
{
if ( TUSB_REQUEST_GET_DESCRIPTOR == control_request.bRequest )
{
- static uint8_t const * p_buffer = NULL;
+ static uint8_t* p_buffer = NULL;
static uint16_t length = 0;
error = get_descriptor_subtask(coreid, &control_request, &p_buffer, &length);
diff --git a/tinyusb/osal/osal_none.h b/tinyusb/osal/osal_none.h
index 0e82b8aa9..db11da605 100644
--- a/tinyusb/osal/osal_none.h
+++ b/tinyusb/osal/osal_none.h
@@ -105,7 +105,7 @@ static inline uint32_t osal_tick_get(void)
ATTR_UNUSED static uint32_t timeout = 0;\
static uint16_t state = 0;\
switch(state) {\
- case 0:{\
+ case 0: { \
#define OSAL_TASK_LOOP_END \
default:\