Skip to content

Commit

Permalink
stm32f1/platform: Added a short delay after bringing up the GPIOB con…
Browse files Browse the repository at this point in the history
…troller to get the pin state read to be reliable
  • Loading branch information
dragonmux committed Aug 2, 2023
1 parent 6b376dd commit 9f9b9c3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions firmware/stm32f1/platform.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <cstring>
#include <usb/core.hxx>
#include <substrate/indexed_iterator>
#include <substrate/index_sequence>
#include "platform.hxx"
#include "stm32f1.hxx"

Expand Down Expand Up @@ -87,6 +88,9 @@ bool mustEnterBootloader() noexcept
{
#if BOOTLOADER_TARGET == BMP
rcc.apb2PeriphClockEn |= vals::rcc::apb2PeriphClockEnGPIOPortB;
// Delay a little after powering up the GPIO controller to allow the pin value to stabilise
for ([[maybe_unused]] volatile size_t i : substrate::indexSequence_t{10})
continue;
// If PB12 is low, then either the button is pressed, or the firmware set it low
if (!vals::gpio::value(gpioB, vals::gpio_t::pin12))
return true;
Expand Down

0 comments on commit 9f9b9c3

Please sign in to comment.