Replies: 7 comments
-
@PTS93 there is an callback for tud_mount_cb/tud_umount_cb in the stack. Are you looking for an Arduino callback function ? You can just use the callback directly, though, as convention, Arduino callback should be passed to USBDevice with something like setMountedCallback() or something. Sorry for the late response, hope this answer your question. |
Beta Was this translation helpful? Give feedback.
-
Yes ultimately I will need it in Arduino. Where would you suggest that I add that setMountedCallback() wrapper for tud_mount_cb/tud_umount_cb? The arduino library itself does not seem to implement any global USB functions but only the specific USB classes. Are those things being done in the Arduino core side? |
Beta Was this translation helpful? Give feedback.
-
Ah I think I finally understood the setup. So there are 2 Arduino libs essentially. One setting up the general USB and the other is for implementing specific devices like HID or MSD? |
Beta Was this translation helpful? Give feedback.
-
@PTS93 right, the core lib implement device + CDC, since cdc is required for Arduino core to perform DFU touch1200 and Serial. The MSC + HID and other higher layers are implemented as wrapper for higher class, which is subject to be changed more frequent. It is kind of complicated, but I don't any better way. an setMountedCallback() with an function pointer should be fine, you should also add the setUmountedCallback() as well. |
Beta Was this translation helpful? Give feedback.
-
API is implemented https://github.com/adafruit/Adafruit_TinyUSB_ArduinoCore/blob/master/Adafruit_USBD_Device.h#L75 |
Beta Was this translation helpful? Give feedback.
-
but that is not a callback or did you link to the wrong place? |
Beta Was this translation helpful? Give feedback.
-
right, I forgot what I have said, and thought it is merely for polling, will add one callback later on |
Beta Was this translation helpful? Give feedback.
-
I was wondering if there is a callback for USBDevice.mounted() or something equivalent that informs me when the device was connected to or disconnected from the host.
I'm writing a library that depends on checking this periodically, would be nice if I can do this without modifying the core. I want to avoid the user having to manually call an update function of the library.
I sifted through the code a bit but couldn't find something obvious.
Beta Was this translation helpful? Give feedback.
All reactions