enhance device hid

- add CFG_TUD_HID_ASCII_TO_KEYCODE_LOOKUP
- add tud_hid_keyboard_send_keycode(), tud_hid_keyboard_send_char(),
tud_hid_keyboard_send_string()
- add timeout_blocking_wait()
This commit is contained in:
hathach
2018-07-23 17:46:07 +07:00
parent 262be103e0
commit 3e209f9c20
6 changed files with 385 additions and 131 deletions

View File

@@ -76,6 +76,9 @@ int main(void)
return 0;
}
//--------------------------------------------------------------------+
// USB CDC
//--------------------------------------------------------------------+
void virtual_com_task(void)
{
// connected and there are data available
@@ -91,6 +94,30 @@ void virtual_com_task(void)
}
}
//--------------------------------------------------------------------+
// USB CDC
//--------------------------------------------------------------------+
void usb_hid_task(void)
{
if ( tud_mounted() )
{
if ( !tud_hid_keyboard_busy() )
{
static bool toggle = false; // send either A or B
tud_hid_keyboard_send_char( toggle ? 'A' : 'B' );
toggle = !toggle;
}
if ( !tud_hid_mouse_busy() )
{
}
}
}
//--------------------------------------------------------------------+
// tinyusb callbacks

View File

@@ -126,6 +126,13 @@
*/
#define CFG_TUD_HID_BOOT_PROTOCOL 1
/* Use the HID_ASCII_TO_KEYCODE lookup if CFG_TUD_HID_KEYBOARD is enabled.
* This will occupies 256 bytes of ROM. It will also enable the use of 2 extra APIs
* - tud_hid_keyboard_send_char()
* - tud_hid_keyboard_send_string()
*/
#define CFG_TUD_HID_ASCII_TO_KEYCODE_LOOKUP 1
//--------------------------------------------------------------------
// USB RAM PLACEMENT
//--------------------------------------------------------------------