Skip to content

Commit f00cc1e

Browse files
authored
fix(tx16s): turn on aux2 power when used for BT (#5363)
2.10 version of #5353
1 parent 534d17a commit f00cc1e

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

radio/src/bluetooth.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,15 @@ void Bluetooth::wakeup()
413413
return;
414414
}
415415

416+
#if defined(BT_PWR_GPIO)
417+
if (g_eeGeneral.bluetoothMode == BLUETOOTH_OFF) {
418+
bluetoothDisable();
419+
state = BLUETOOTH_STATE_OFF;
420+
wakeupTime = now + 10; /* 100ms */
421+
return;
422+
}
423+
#endif
424+
416425
if (g_eeGeneral.bluetoothMode == BLUETOOTH_OFF ||
417426
(g_eeGeneral.bluetoothMode == BLUETOOTH_TRAINER &&
418427
!IS_BLUETOOTH_TRAINER())) {

radio/src/targets/common/arm/stm32/bluetooth_driver.cpp

+16-3
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,25 @@ void* _bt_usart_ctx = nullptr;
5757

5858
void bluetoothInit(uint32_t baudrate, bool enable)
5959
{
60-
#if defined(BT_EN_GPIO_PIN)
6160
LL_GPIO_InitTypeDef pinInit;
62-
LL_GPIO_StructInit(&pinInit);
6361

62+
#if defined(BT_EN_GPIO_PIN)
63+
LL_GPIO_StructInit(&pinInit);
6464
pinInit.Pin = BT_EN_GPIO_PIN;
6565
pinInit.Mode = LL_GPIO_MODE_OUTPUT;
6666
pinInit.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
6767
pinInit.Pull = LL_GPIO_PULL_NO;
68-
6968
LL_GPIO_Init(BT_EN_GPIO, &pinInit);
7069
#endif
7170

71+
#if defined(BT_PWR_GPIO)
72+
LL_GPIO_StructInit(&pinInit);
73+
pinInit.Pin = BT_PWR_GPIO_PIN;
74+
pinInit.Mode = LL_GPIO_MODE_OUTPUT;
75+
pinInit.Pull = LL_GPIO_PULL_UP;
76+
LL_GPIO_Init(BT_PWR_GPIO, &pinInit);
77+
#endif
78+
7279
#if !defined(BOOT)
7380
etx_serial_init cfg = {
7481
.baudrate = baudrate,
@@ -92,6 +99,9 @@ void bluetoothInit(uint32_t baudrate, bool enable)
9299
LL_GPIO_SetOutputPin(BT_EN_GPIO, BT_EN_GPIO_PIN);
93100
}
94101
#endif
102+
#if defined(BT_PWR_GPIO)
103+
LL_GPIO_SetOutputPin(BT_PWR_GPIO, BT_PWR_GPIO_PIN);
104+
#endif
95105
}
96106

97107
#if !defined(BOOT)
@@ -100,6 +110,9 @@ void bluetoothDisable()
100110
#if defined(BT_EN_GPIO_PIN)
101111
// close bluetooth (recent modules will go to bootloader mode)
102112
LL_GPIO_SetOutputPin(BT_EN_GPIO, BT_EN_GPIO_PIN);
113+
#endif
114+
#if defined(BT_PWR_GPIO)
115+
LL_GPIO_ResetOutputPin(BT_PWR_GPIO, BT_PWR_GPIO_PIN);
103116
#endif
104117
if (_bt_usart_ctx) {
105118
STM32SerialDriver.deinit(_bt_usart_ctx);

radio/src/targets/horus/hal.h

+4
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,10 @@
12481248
#define BT_TX_GPIO_PIN LL_GPIO_PIN_14 // PG.14
12491249
#define BT_RX_GPIO_PIN LL_GPIO_PIN_9 // PG.09
12501250
#define BT_USART_IRQHandler USART6_IRQHandler
1251+
#if defined(RADIO_TX16S)
1252+
#define BT_PWR_GPIO GPIOB
1253+
#define BT_PWR_GPIO_PIN LL_GPIO_PIN_0 // PB.00
1254+
#endif
12511255
#else
12521256
#define BT_RCC_APB2Periph 0
12531257
#endif

0 commit comments

Comments
 (0)