Support boards without VBUS pin and with divider on VBUS pin#175
Open
matthijskooijman wants to merge 3 commits intoGrumpyOldPizza:masterfrom
Open
Support boards without VBUS pin and with divider on VBUS pin#175matthijskooijman wants to merge 3 commits intoGrumpyOldPizza:masterfrom
matthijskooijman wants to merge 3 commits intoGrumpyOldPizza:masterfrom
Conversation
Since commit bdd33df (Refresh USB logic; callback for events; hotplug in STOP mode; STOP mode in USB SUSPEND; bunch of race conditions in the USB/CDC code; avoid SOF interrupt; 500mA max power in descriptiors), the USBD code would assume a VBUS pin is available and only initialize the USB stack when a VBUS voltage is present. This commit restores the older behavior of, when `STM32L0_CONFIG_PIN_VBUS` (so indirectly also `usbd_pin_vbus`) is `STM32L0_GPIO_PIN_NONE`, assuming VBUS is always present. USB initialization can still be controlled using `USBDevice.attach()`.
This is already done by usbd_conf.c which is also the place where it is read, so no need to do it again here.
This can be useful to allow measuring the actual USB voltage, rather than just detect presence. Previously the USB code would always enable an internal pulldown on the VBUS, which would skew the reading (and, if the divider is fairly high impedance, can even prevent detecting VBUS presence using a digital read). With this commit, boards can indicate they use an external divider using the STM32L0_CONFIG_PIN_VBUS_HAS_DIVIDER macro in their variant.h. When this is defined, the internal pullup is not enabled to prevent it from causing issues and because it is no longer needed (the external divider functions as a pulldown).
Author
|
Note that some previous discussion starting at #125 (comment) indicates that removing support for boards without a VBUS pin was intentional, apparently because it prevents using a feature called "BCD" (which I'm still not quite sure what that is). Since I needed this support for a few boards I made and thus created the commits already, I figured I'd submit them here just in case this point could be revisited, or in case it is useful for someone else maybe. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for boards:
Note that this just changes the code, it does not include the resulting changes to the precompiled binaries.