adafruit / Adafruit_TinyUSB_Arduino

Arduino library for TinyUSB
MIT License
469 stars 122 forks source link

tuh_hid callback functions trigger compile errors #191

Closed touchgadget closed 2 years ago

touchgadget commented 2 years ago

Looks like PR #190 is the same issue so feel free to close this.

Operating System

Linux

IDE version

Arduino 1.8.19

Board

Raspberry Pi Pico

ArduinoCore version

Raspberry Pi Pico/2040 by Philhower 2.3.3

TinyUSB Library version

github 2ab122c

Sketch (attached txt file)

hid_test.txt

I had to rename the .ino file with .txt to make github happy.

What happened ?

I am porting over TinyUSB examples/dual/host_hid_to_device_cdc/ to Arduino but have run into multiple definitions of tuh_hid_mount_cb.

To fix I propose removing the tuhhid*_cb function declarations from Adafruit_TinyUSB_Arduino.h. The functions will eventually be defined in the sketch.

The next compile error is tuh_hid_report_received_cb is undefined which is not yet defined in the sketch.

To fix this, I propose adding TU_ATTR_WEAK to tuh_hid_mount_cb and tuh_hid_report_received_cb in hid_host.h.

How to reproduce ?

Rename hid_test.txt to hid_test.ino then compile with the IDE to see the compiler errors.

Debug Log

No response

Screenshots

No response

hathach commented 2 years ago

the strong version in lib is temporary, since host support is WIP. It is addressed in #190 , I will review and revise host support when I have time.

hathach commented 2 years ago

should be fixed now

touchgadget commented 2 years ago

Thanks, works fine!