Skip to content

Commit

Permalink
Unrelated STM32 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CapnBry committed Jan 24, 2024
1 parent eeca2ca commit 5c2451a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
7 changes: 2 additions & 5 deletions src/lib/BUTTON/devButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
typedef void (*ButtonAction_fn)();

#if defined(GPIO_PIN_BUTTON)
#if defined(TARGET_TX) || \
(defined(TARGET_RX) && (defined(PLATFORM_ESP32) || defined(PLATFORM_ESP8266)))
extern device_t Button_device;
#define HAS_BUTTON
#endif
extern device_t Button_device;
#define HAS_BUTTON

#include <list>
#include <map>
Expand Down
18 changes: 11 additions & 7 deletions src/src/rx_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ static void cycleRfMode(unsigned long now)

static void updateBindingMode()
{
// Exit binding mode if the config has been modigied, indicating UID has been set
// Exit binding mode if the config has been modified, indicating UID has been set
if (InBindingMode && config.IsModified())
{
ExitBindingMode();
Expand Down Expand Up @@ -1505,6 +1505,7 @@ static void updateBindingMode()
}
}

#if defined(HAS_BUTTON)
static void EnterBindingModeSafely()
{
// Will not enter Binding mode if in the process of a passthrough update
Expand All @@ -1515,21 +1516,17 @@ static void EnterBindingModeSafely()
#if defined(PLATFORM_ESP32) || defined(PLATFORM_ESP8266)
// Never enter wifi mode after requesting to enter binding mode
webserverPreventAutoStart = true;
#endif

// If the radio and everything is shut down, better to reboot and boot to binding mode
if (connectionState == wifiUpdate || connectionState == bleJoystick)
{
// Force 3-plug binding mode
config.SetPowerOnCounter(3);
config.Commit();
#if defined(PLATFORM_STM32)
HAL_NVIC_SystemReset();
#else
ESP.restart();
#endif
// Unreachable
}
#endif

// If connected, handle that in updateBindingMode()
if (connectionState == connected)
Expand All @@ -1540,6 +1537,7 @@ static void EnterBindingModeSafely()

EnterBindingMode();
}
#endif /* HAS_BUTTON */

static void checkSendLinkStatsToFc(uint32_t now)
{
Expand Down Expand Up @@ -1719,10 +1717,16 @@ void setup()
SerialLogger = new NullStream();
#endif

// External EEPROM needs I2C setup so it can load config
// but configurable I2C pins for PWM RX needs config loaded first
#if (defined(TARGET_USE_EEPROM) && defined(USE_I2C))
setupTarget();
#endif
// Init EEPROM and load config, checking powerup count
setupConfigAndPocCheck();

#if !(defined(TARGET_USE_EEPROM) && defined(USE_I2C))
setupTarget();
#endif

#if defined(OPT_HAS_SERVO_OUTPUT)
// If serial is not already defined, then see if there is serial pin configured in the PWM configuration
Expand Down

0 comments on commit 5c2451a

Please sign in to comment.