diff options
| author | hathach <[email protected]> | 2025-02-12 11:28:16 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2025-02-12 11:28:16 +0700 |
| commit | 87adc63226a59e6c2602b1bc453ced77d44fedba (patch) | |
| tree | 1e47a80bfab09dbac47312b4242939df03ec7796 /examples/device/hid_boot_interface/src/main.c | |
| parent | b41f5eadb3143d0bfaf211d9bc84c95e5d623c29 (diff) | |
| parent | 5afcfb7522c4fd8b50512cfb277d8a3ccdbc5453 (diff) | |
Merge branch 'master' into fork/atoktoto/midihost
# Conflicts:
# hw/bsp/rp2040/family.cmake
# src/class/midi/midi.h
# src/class/midi/midi_device.c
# src/device/usbd_control.c
# src/host/hcd.h
# src/host/usbh.c
# src/host/usbh.h
Diffstat (limited to 'examples/device/hid_boot_interface/src/main.c')
| -rw-r--r-- | examples/device/hid_boot_interface/src/main.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/examples/device/hid_boot_interface/src/main.c b/examples/device/hid_boot_interface/src/main.c index 71afa3f46..570e4e801 100644 --- a/examples/device/hid_boot_interface/src/main.c +++ b/examples/device/hid_boot_interface/src/main.c @@ -1,4 +1,4 @@ -/* +/* * The MIT License (MIT) * * Copyright (c) 2019 Ha Thach (tinyusb.org) @@ -27,7 +27,7 @@ #include <stdio.h> #include <string.h> -#include "bsp/board.h" +#include "bsp/board_api.h" #include "tusb.h" #include "usb_descriptors.h" @@ -57,7 +57,15 @@ int main(void) board_init(); // init device stack on configured roothub port - tud_init(BOARD_TUD_RHPORT); + tusb_rhport_init_t dev_init = { + .role = TUSB_ROLE_DEVICE, + .speed = TUSB_SPEED_AUTO + }; + tusb_init(BOARD_TUD_RHPORT, &dev_init); + + if (board_init_after_tusb) { + board_init_after_tusb(); + } while (1) { @@ -98,7 +106,7 @@ void tud_suspend_cb(bool remote_wakeup_en) // Invoked when usb bus is resumed void tud_resume_cb(void) { - blink_interval_ms = BLINK_MOUNTED; + blink_interval_ms = tud_mounted() ? BLINK_MOUNTED : BLINK_NOT_MOUNTED; } //--------------------------------------------------------------------+ @@ -157,11 +165,11 @@ void hid_task(void) { uint8_t const report_id = 0; uint8_t const button_mask = 0; - uint8_t const veritical = 0; - uint8_t const horizontal = 0; + int8_t const vertical = 0; + int8_t const horizontal = 0; int8_t const delta = 5; - tud_hid_n_mouse_report(ITF_NUM_MOUSE, report_id, button_mask, delta, delta, veritical, horizontal); + tud_hid_n_mouse_report(ITF_NUM_MOUSE, report_id, button_mask, delta, delta, vertical, horizontal); } } } @@ -175,13 +183,13 @@ void tud_hid_set_protocol_cb(uint8_t instance, uint8_t protocol) (void) protocol; // nothing to do since we use the same compatible boot report for both Boot and Report mode. - // TOOD set a indicator for user + // TODO set a indicator for user } // Invoked when sent REPORT successfully to host // Application can use this to send the next report // Note: For composite reports, report[0] is report ID -void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, /*uint16_t*/ uint8_t len) +void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint16_t len) { (void) instance; (void) report; |
