Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tx16s): turn on aux2 power when used for BT - 2.10 #5363

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions radio/src/bluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,15 @@ void Bluetooth::wakeup()
return;
}

#if defined(BT_PWR_GPIO)
if (g_eeGeneral.bluetoothMode == BLUETOOTH_OFF) {
bluetoothDisable();
state = BLUETOOTH_STATE_OFF;
wakeupTime = now + 10; /* 100ms */
return;
}
#endif

if (g_eeGeneral.bluetoothMode == BLUETOOTH_OFF ||
(g_eeGeneral.bluetoothMode == BLUETOOTH_TRAINER &&
!IS_BLUETOOTH_TRAINER())) {
Expand Down
19 changes: 16 additions & 3 deletions radio/src/targets/common/arm/stm32/bluetooth_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,25 @@ void* _bt_usart_ctx = nullptr;

void bluetoothInit(uint32_t baudrate, bool enable)
{
#if defined(BT_EN_GPIO_PIN)
LL_GPIO_InitTypeDef pinInit;
LL_GPIO_StructInit(&pinInit);

#if defined(BT_EN_GPIO_PIN)
LL_GPIO_StructInit(&pinInit);
pinInit.Pin = BT_EN_GPIO_PIN;
pinInit.Mode = LL_GPIO_MODE_OUTPUT;
pinInit.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
pinInit.Pull = LL_GPIO_PULL_NO;

LL_GPIO_Init(BT_EN_GPIO, &pinInit);
#endif

#if defined(BT_PWR_GPIO)
LL_GPIO_StructInit(&pinInit);
pinInit.Pin = BT_PWR_GPIO_PIN;
pinInit.Mode = LL_GPIO_MODE_OUTPUT;
pinInit.Pull = LL_GPIO_PULL_UP;
LL_GPIO_Init(BT_PWR_GPIO, &pinInit);
#endif

#if !defined(BOOT)
etx_serial_init cfg = {
.baudrate = baudrate,
Expand All @@ -92,6 +99,9 @@ void bluetoothInit(uint32_t baudrate, bool enable)
LL_GPIO_SetOutputPin(BT_EN_GPIO, BT_EN_GPIO_PIN);
}
#endif
#if defined(BT_PWR_GPIO)
LL_GPIO_SetOutputPin(BT_PWR_GPIO, BT_PWR_GPIO_PIN);
#endif
}

#if !defined(BOOT)
Expand All @@ -100,6 +110,9 @@ void bluetoothDisable()
#if defined(BT_EN_GPIO_PIN)
// close bluetooth (recent modules will go to bootloader mode)
LL_GPIO_SetOutputPin(BT_EN_GPIO, BT_EN_GPIO_PIN);
#endif
#if defined(BT_PWR_GPIO)
LL_GPIO_ResetOutputPin(BT_PWR_GPIO, BT_PWR_GPIO_PIN);
#endif
if (_bt_usart_ctx) {
STM32SerialDriver.deinit(_bt_usart_ctx);
Expand Down
4 changes: 4 additions & 0 deletions radio/src/targets/horus/hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,10 @@
#define BT_TX_GPIO_PIN LL_GPIO_PIN_14 // PG.14
#define BT_RX_GPIO_PIN LL_GPIO_PIN_9 // PG.09
#define BT_USART_IRQHandler USART6_IRQHandler
#if defined(RADIO_TX16S)
#define BT_PWR_GPIO GPIOB
#define BT_PWR_GPIO_PIN LL_GPIO_PIN_0 // PB.00
#endif
#else
#define BT_RCC_APB2Periph 0
#endif
Expand Down