Skip to content

Commit 12055c7

Browse files
committed
stm32/wb55: Allow normal BLE to work on builds with transparent mode enabled.
1 parent 3754c38 commit 12055c7

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

ports/stm32/rfcore.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
#if MICROPY_BLUETOOTH_NIMBLE
4646
// For mp_bluetooth_nimble_hci_uart_wfi
4747
#include "nimble/nimble_npl.h"
48+
// For mp_bluetooth_nimble_ble_state
49+
#include "modbluetooth_nimble.h"
4850
#else
4951
#error "STM32WB must use NimBLE."
5052
#endif
@@ -98,6 +100,7 @@
98100

99101
volatile bool hci_acl_cmd_pending = false;
100102

103+
101104
typedef struct _tl_list_node_t {
102105
volatile struct _tl_list_node_t *next;
103106
volatile struct _tl_list_node_t *prev;
@@ -261,9 +264,7 @@ void ipcc_init(uint32_t irq_pri) {
261264
// Enable receive IRQ on the BLE channel.
262265
LL_C1_IPCC_EnableIT_RXO(IPCC);
263266
LL_C1_IPCC_DisableReceiveChannel(IPCC, LL_IPCC_CHANNEL_1 | LL_IPCC_CHANNEL_2 | LL_IPCC_CHANNEL_3 | LL_IPCC_CHANNEL_4 | LL_IPCC_CHANNEL_5 | LL_IPCC_CHANNEL_6);
264-
#if !MICROPY_HW_STM32WB_TRANSPARENT_MODE
265267
LL_C1_IPCC_EnableReceiveChannel(IPCC, IPCC_CH_BLE);
266-
#endif
267268
NVIC_SetPriority(IPCC_C1_RX_IRQn, irq_pri);
268269
HAL_NVIC_EnableIRQ(IPCC_C1_RX_IRQn);
269270

@@ -449,12 +450,10 @@ STATIC void tl_check_msg(volatile tl_list_node_t *head, unsigned int ch, parse_h
449450
// Clear receive channel (allows RF core to send more data to us).
450451
LL_C1_IPCC_ClearFlag_CHx(IPCC, ch);
451452

452-
#if !MICROPY_HW_STM32WB_TRANSPARENT_MODE
453-
if (ch == IPCC_CH_BLE) {
453+
if (ch == IPCC_CH_BLE && (mp_bluetooth_nimble_ble_state != MP_BLUETOOTH_NIMBLE_BLE_STATE_OFF)) {
454454
// Renable IRQs for BLE now that we've cleared the flag.
455455
LL_C1_IPCC_EnableReceiveChannel(IPCC, IPCC_CH_BLE);
456456
}
457-
#endif
458457
}
459458
}
460459

@@ -528,7 +527,7 @@ STATIC void tl_ble_hci_cmd_resp(uint16_t opcode, const uint8_t *buf, size_t len)
528527
/******************************************************************************/
529528
// RF core interface
530529

531-
void rfcore_init(void) {
530+
void rfcore_init() {
532531
DEBUG_printf("rfcore_init\n");
533532

534533
// Ensure LSE is running
@@ -589,6 +588,7 @@ static const struct {
589588
void rfcore_ble_init(void) {
590589
DEBUG_printf("rfcore_ble_init\n");
591590

591+
592592
// Clear any outstanding messages from ipcc_init.
593593
tl_check_msg(&ipcc_mem_sys_queue, IPCC_CH_SYS, NULL);
594594

@@ -646,7 +646,7 @@ void rfcore_ble_hci_cmd(size_t len, const uint8_t *src) {
646646
break;
647647
}
648648
#if MICROPY_PY_BLUETOOTH && MICROPY_BLUETOOTH_NIMBLE
649-
if (LL_C1_IPCC_IsEnabledReceiveChannel(IPCC, IPCC_CH_BLE)) {
649+
if (mp_bluetooth_nimble_ble_state != MP_BLUETOOTH_NIMBLE_BLE_STATE_OFF) {
650650
mp_bluetooth_nimble_hci_uart_wfi();
651651
}
652652
#endif

ports/stm32/rfcore.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ void rfcore_ble_init(void);
3434
void rfcore_ble_hci_cmd(size_t len, const uint8_t *src);
3535
void rfcore_ble_check_msg(int (*cb)(void *, const uint8_t *, size_t), void *env);
3636
void rfcore_ble_set_txpower(uint8_t level);
37+
#if MICROPY_HW_STM32WB_TRANSPARENT_MODE
38+
void rfcore_ble_disable_ble_rx_interrupt(void);
39+
#endif
3740

3841
void rfcore_start_flash_erase(void);
3942
void rfcore_end_flash_erase(void);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy