Fix initialization of USB HID and PB2 pull down #42
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.
These are fixes to a couple of issues that I found while trying to use the HID bootloader in my custom STM32 board (based on BluePill, but with some customizations). I share them here if it is of interest to other developers.
PB2 Pull Down activation had an issue because the pins_init() function was not clearing the CNF2_0 bit, so the pin was entering a Reserved state (CNF='11'), according to STM32 programming manual.
I am using the HID bootloader to flash a custom application (not created with Arduino-STM32). Since my application does not write the magic word in the backup registers (yet), I set Boo1 (PB2) to high level for reflashing, then press reset. In this scenario, the HID bootloader does not reset the USB connection back to HID mode, so the previous state is preserved and the hid_flash tool cannot find the board.
I think the HID bootloader should not rely on the application to reset the USB connection into HID mode, but always perform reset (this is what my patch does).