Closed ita1024 closed 1 year ago
this is a great idea, give me a bit time, I will do some test, and add an example based on your code and maybe add a helper/class driver to tinyusb core for this as well. That would be useful for others
Thank you for your suggestion, I have made an example and make an seperated WireUSB class to make it easier to re-use by other. #264 includes other fixes and get it working flawless with i2cdetect
$ i2cdetect -l
i2c-8 i2c i2c-tiny-usb at bus 003 device 041 I2C adapter
$ i2cdetect -y 8
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- 39 -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
The snippets provided under the examples folder show a limited amount of supported devices. Would not it be amazing to show how to extend support to new USB gadgets?
I am not sure if this is the correct way (suggestions welcome), but it took me some time to create an i2c bridge using an Adafruit Trinket M0. This example shows in particular how to use "TinyUSBDevice.setID"; the device is autodetected on Linux using the
i2c_tiny_usb
module and is ready to use:The
tud_control_xfer
function shares the buffer implicitly from the SETUP to the DATA stage. Let me know if there is a better way, and feel free to adapt the snippet above to add a proper example to the documentation!