Replies: 1 comment 2 replies
-
Currently all the examples seems to indicate that the device was previously mounted which can't be taken for granted. I think these should rather look like this:
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
@hathach
I'm confused about the meaning of the
tud_umount_cb()
andtud_mount_cb()
function. Without my suggested changes (#2171) the unmount can basically only be set for a self powered device because it's not triggered by a reset. The mounted state is set every time the configuration is set (see here).Right now that seems to be even the case when the host resets the configuration for some reason to be unconfigured (zero).Correction, so while the mounted callback is executed correctly there the callback for the unmounting event is missing. Also the application needs to take care of the previous state. Like to know to resume to which power state when a suspend is abrogated. If there is only one configurationtud_mounted()
can be used to determine to which previous power state it should return. If there are more, the last configuration is needed too if the device is mounted. I'm not aware that this is mentioned somewhere.To me that seems counterintuitive and that it's used in a kind of mixed way. If the mounted and unmounted state seems to be referring to the physical attachment of a self powered device to the USB bus then it would not make much sense to me to let TinyUSB handle the mounting state. For example the configuration descriptor tells the host if a device is self powered or not and how much current that can consume from USB. So if a self powered device wants to draw power so it maybe can recharge its batteries, the mounted state should be only called if a corresponding configuration descriptor is set. But TinyUSB has no knowledge of the exact configuration so that needs to be done in the custom code of the
tud_descriptor_configuration_cb()
function. This of course depends on the view point.But even if that behavior is intended this way,Correction, this is already granted. Only the callback for the unmounting event is missing.tud_mount_cb()
should only be invoked when the current configuration is non-zero. So that if it's zerotud_umount_cb()
should be called instead.Edit:
I think it should rather look like this:
Edit 2:
An example code is shown here #2202.
Edit 3:
The function
tud_mounted()
to check if the device is mounted or not also indicate that the device should be handled as unmounted if the current configuration is zero and so that the callback should be invoked if the configuration is reset.Beta Was this translation helpful? Give feedback.
All reactions