31
NXPTM M522XX, KINETIS and i.MX RT / Re: un-enumerate USB Device loader?
« Last post by mark on March 08, 2024, 11:38:41 PM »John
I think I have found a simple way to command disconnecting the USB device (and, if required, reconnecting it again.
USBHS0_USBCMD ^= USBHS_USBCMD_RS;
When USBHS_USBCMD_RS is set to 0 (stop mode) it removes its D+ pull-up and so is no longer detected by the host.
When it is set again it reconnects the D+ pull-up and goes to run mode again (and the host detects it and re-enumerates it).
I added this interface so that the registers don't need to be accessed directly (portable):
fnConfigUSB(USB_DEVICE_REF, 0); // when the parameter is 0 it toggles the RUN mode in order to disconnect/reconnect
but it may not be the best method, so experimental at the moment.
You may be able to prove the suitability for your need by directly controlling it in the register.
Regards
Mark
I think I have found a simple way to command disconnecting the USB device (and, if required, reconnecting it again.
USBHS0_USBCMD ^= USBHS_USBCMD_RS;
When USBHS_USBCMD_RS is set to 0 (stop mode) it removes its D+ pull-up and so is no longer detected by the host.
When it is set again it reconnects the D+ pull-up and goes to run mode again (and the host detects it and re-enumerates it).
I added this interface so that the registers don't need to be accessed directly (portable):
fnConfigUSB(USB_DEVICE_REF, 0); // when the parameter is 0 it toggles the RUN mode in order to disconnect/reconnect
but it may not be the best method, so experimental at the moment.
You may be able to prove the suitability for your need by directly controlling it in the register.
Regards
Mark