GrumpyOldPizza / ArduinoCore-stm32l0

Arduino Core for STM32L0
125 stars 67 forks source link

Support boards without VBUS pin and with divider on VBUS pin #175

Open matthijskooijman opened 3 years ago

matthijskooijman commented 3 years ago

This PR adds support for boards:

  1. That do not have a VBUS pin. For these boards, VBUS is always assumed to be present. This restores the behavior that was removed in bdd33df. Note that not having a VBUS pin is not recommended, since it technically violates the USB spec and might preclude some USB features, but with this changes such boards can at least work.
  2. That have a resistor divider on their VBUS pin (e.g. for measuring VBUS voltage). For these boards, no pulldown is enabled on the pin, to prevent unbalancing the divider.

Note that this just changes the code, it does not include the resulting changes to the precompiled binaries.

matthijskooijman commented 3 years ago

Note that some previous discussion starting at https://github.com/GrumpyOldPizza/ArduinoCore-stm32l0/issues/125#issuecomment-737153911 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.