reworking device hid class driver

This commit is contained in:
hathach
2018-07-23 15:25:45 +07:00
parent 141ac25e3b
commit 4342325ee1
31 changed files with 583 additions and 501 deletions

View File

@@ -77,21 +77,21 @@ void tud_hid_keyboard_cb(uint8_t rhport, tusb_event_t event, uint32_t xferred_by
}
}
uint16_t tud_hid_keyboard_get_report_cb(uint8_t rhport, hid_request_report_type_t report_type, void** pp_report, uint16_t requested_length)
uint16_t tud_hid_keyboard_get_report_cb(hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen)
{
// get other than input report is not supported by this keyboard demo
if ( report_type != HID_REQUEST_REPORT_INPUT ) return 0;
if ( report_type != HID_REPORT_TYPE_INPUT ) return 0;
(*pp_report) = &keyboard_report;
return requested_length;
memcpy(buffer, &keyboard_report, reqlen);
return reqlen;
}
void tud_hid_keyboard_set_report_cb(uint8_t rhport, hid_request_report_type_t report_type, uint8_t p_report_data[], uint16_t length)
void tud_hid_keyboard_set_report_cb(hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen)
{
// set other than output report is not supported by this keyboard demo
if ( report_type != HID_REQUEST_REPORT_OUTPUT ) return;
if ( report_type != HID_REPORT_TYPE_OUTPUT ) return;
uint8_t kbd_led = p_report_data[0];
uint8_t kbd_led = buffer[0];
uint32_t interval_divider = 1; // each LED will reduce blinking interval by a half
if (kbd_led & KEYBOARD_LED_NUMLOCK ) interval_divider *= 2;

View File

@@ -77,17 +77,12 @@ void tud_hid_mouse_cb(uint8_t rhport, tusb_event_t event, uint32_t xferred_bytes
}
}
uint16_t tud_hid_mouse_get_report_cb(uint8_t rhport, hid_request_report_type_t report_type, void** pp_report, uint16_t requested_length)
uint16_t tud_hid_mouse_get_report_cb(hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen)
{
if ( report_type != HID_REQUEST_REPORT_INPUT ) return 0; // not support other report type for this mouse demo
if ( report_type != HID_REPORT_TYPE_INPUT ) return 0; // not support other report type for this mouse demo
(*pp_report) = &mouse_report;
return requested_length;
}
void tud_hid_mouse_set_report_cb(uint8_t rhport, hid_request_report_type_t report_type, uint8_t report_data[], uint16_t length)
{
// mouse demo does not support set report --> do nothing
memcpy(buffer, &mouse_report, reqlen);
return reqlen;
}
//--------------------------------------------------------------------+

View File

@@ -72,11 +72,10 @@
#define CFG_TUD_ENDOINT0_SIZE 64
//------------- CLASS -------------//
#define CFG_TUD_HID_KEYBOARD 0
#define CFG_TUD_HID_MOUSE 0
#define CFG_TUD_HID_GENERIC 0 // not supported yet
#define CFG_TUD_MSC 1
#define CFG_TUD_CDC 1
#define CFG_TUD_HID_KEYBOARD 0
#define CFG_TUD_HID_MOUSE 0
/*------------------------------------------------------------------*/
/* CLASS DRIVER