-
Notifications
You must be signed in to change notification settings - Fork 2.1k
cpu/stm32/usbdev_fs: allow inverted disconnect GPIO #21718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
cpu/stm32/usbdev_fs: allow inverted disconnect GPIO #21718
Conversation
Did you also test it with a board where the pin is not inverted? One of the upstream boards? I think I have a board with USB peripheral somewhere to test this. |
No, I "tested" this by "staring hard at the diff". But I'm having a Bluepill somewhere in reach, I'll give it a spin in a sec. |
Tested just now:
So even re-enumeration after reboot (the important part) does still work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the file should rather be in the cpu_stm32_usbdev
subgroup [3], because currently the entries are not added to that group and the cpu_stm32
page also does not show the content explicitly [1]. You have to nagivate to the file [2], which is not easy to find IMO.
[1] https://ci.riot-os.org/results/76a1ab86808d47e8ba3d70c69f14fcec/doc-preview/group__cpu__stm32.html
[2] https://ci.riot-os.org/results/76a1ab86808d47e8ba3d70c69f14fcec/doc-preview/cpu__usbdev_8h.html
[3] https://ci.riot-os.org/results/76a1ab86808d47e8ba3d70c69f14fcec/doc-preview/group__cpu__stm32__usbdev.html
#define USBDEV_CPU_DMA_REQUIREMENTS __attribute__((aligned(USBDEV_CPU_DMA_ALIGNMENT))) | ||
|
||
/** | ||
* @name Flags used in @ref stm32_usbdev_fs_config_t |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't appear to work so great: https://ci.riot-os.org/results/76a1ab86808d47e8ba3d70c69f14fcec/doc-preview/cpu__usbdev_8h.html

2e0f128
to
3b8fef7
Compare
Ah, we could do better having the different two flavors of the USB peripheral more prominently appear in the doc. I'll rework it here soonish |
The STM32F3 requires a dedicated digital signal to emulate a disconnect event by pulling D+ down via a 1.5 kOhm resistor. Some boards, such as the OLIMEXINO-STM32F3, do not directly connect a GPIO but place a transistor in between. Depending on the exact implementation, the logic level may end up being inverted compared to directly connecting a GPIO. This adds a flag member to the `stm32_usbdev_fs_config_t` and a new flag to indicate inverted logic. In addition the members in the struct are sorted by alignment, as this is a foolproof algorithm to prevent wasting memory on unneeded padding. Finally, the USB driver is adapted to honor the flag.
3b8fef7
to
3e6e965
Compare
Contribution description
The STM32F3 requires a dedicated digital signal to emulate a disconnect event by pulling D+ down via a 1.5 kOhm resistor. Some boards, such as the OLIMEXINO-STM32F3, do not directly connect a GPIO but place a transistor in between. Depending on the exact implementation, the logic level may end up being inverted compared to directly connecting a GPIO.
This adds a flag member to the
stm32_usbdev_fs_config_t
and a new flag to indicate inverted logic. In addition the members in the struct are sorted by alignment, as this is a foolproof algorithm to prevent wasting memory on unneeded padding.Finally, the USB driver is adapted to honor the flag.
Testing procedure
No regressions on STM32 boards with the
usbdev_fs
USB peripheral (e.g. Nucleo-F303Ze, Bluepill with STM32F1, p-Nucleo-WB55).We do not have a board upstream that has an inverted disconnect pin yet, but I pinky-promise I tested this with one downstream for which this fixed an issue of USB not re-enumerating on reboot.
Issues/PRs references
None