2025-06-27 8:20 PM - last edited on 2025-06-28 2:15 AM by Andrew Neil
Hi all!
On an STM32 project I'm working on, I want my USB port (USB C in that case) to work either in Host Mode or in Device Mode, depending on a menu change from the user. For added context, this is for a MIDI project in which the MC will either use USB Host or USB Device as a means of communication.
It appears the mode is determined by the state of Pin PA13 (SYS_JTMS_SWDIO), but I would rather do everything in software, as the USB connection will be the same (the implementation will differ between the two).
Also, when I set the USB mode to OTH/Dual_Role_Device, all of the USB files are being deleted. Should I just save the files used in Host_Only and in Device_Only in another folder, or is there a cleaner way to have both implementations at the same time? If I need to code everything from scratch, I would love to have some pointers on where to begin.
Thanks in advance!