mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
clean up device main.c demo code
This commit is contained in:
parent
ed64401e61
commit
376482558a
@ -16,6 +16,9 @@
|
||||
|
||||
void print_greeting(void);
|
||||
|
||||
void led_blinking_task(void * p_para);
|
||||
void keyboard_device_app_task(void * p_para);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uint32_t current_tick = system_ticks;
|
||||
@ -28,29 +31,20 @@ int main(void)
|
||||
{
|
||||
if (current_tick + 1000 < system_ticks)
|
||||
{
|
||||
static uint32_t led_on_mask = 0;
|
||||
|
||||
current_tick += 1000;
|
||||
|
||||
board_leds(led_on_mask, 1 - led_on_mask);
|
||||
led_on_mask = 1 - led_on_mask; // toggle
|
||||
led_blinking_task(NULL);
|
||||
|
||||
#if TUSB_CFG_DEVICE_HID_KEYBOARD
|
||||
keyboard_device_app_task(NULL);
|
||||
#endif
|
||||
|
||||
#if TUSB_CFG_DEVICE_HID_MOUSE
|
||||
if (usb_isConfigured())
|
||||
{
|
||||
#if TUSB_CFG_DEVICE_HID_KEYBOARD
|
||||
static uint32_t count =0;
|
||||
if (count < 4)
|
||||
{
|
||||
uint8_t keys[6] = {0x04}; // A character
|
||||
tusbd_hid_keyboard_send_report(0x00, keys, 1);
|
||||
count++;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TUSB_CFG_DEVICE_HID_MOUSE
|
||||
tusb_hid_mouse_send(0, 10, 10);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined TUSB_CFG_DEVICE_CDC && 0
|
||||
@ -90,6 +84,30 @@ int main(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void led_blinking_task(void * p_para)
|
||||
{
|
||||
static uint32_t led_on_mask = 0;
|
||||
|
||||
board_leds(led_on_mask, 1 - led_on_mask);
|
||||
led_on_mask = 1 - led_on_mask; // toggle
|
||||
}
|
||||
|
||||
#if TUSB_CFG_DEVICE_HID_KEYBOARD
|
||||
void keyboard_device_app_task(void * p_para)
|
||||
{
|
||||
if (usb_isConfigured())
|
||||
{
|
||||
static uint32_t count =0;
|
||||
if (count < 4)
|
||||
{
|
||||
uint8_t keys[6] = {0x04}; // A character
|
||||
tusbd_hid_keyboard_send_report(0x00, keys, 1);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// HELPER FUNCTION
|
||||
//--------------------------------------------------------------------+
|
||||
|
Loading…
x
Reference in New Issue
Block a user