|
45 | 45 | #if MICROPY_BLUETOOTH_NIMBLE
|
46 | 46 | // For mp_bluetooth_nimble_hci_uart_wfi
|
47 | 47 | #include "nimble/nimble_npl.h"
|
| 48 | +// For mp_bluetooth_nimble_ble_state |
| 49 | +#include "modbluetooth_nimble.h" |
48 | 50 | #else
|
49 | 51 | #error "STM32WB must use NimBLE."
|
50 | 52 | #endif
|
|
98 | 100 |
|
99 | 101 | volatile bool hci_acl_cmd_pending = false;
|
100 | 102 |
|
| 103 | + |
101 | 104 | typedef struct _tl_list_node_t {
|
102 | 105 | volatile struct _tl_list_node_t *next;
|
103 | 106 | volatile struct _tl_list_node_t *prev;
|
@@ -261,9 +264,7 @@ void ipcc_init(uint32_t irq_pri) {
|
261 | 264 | // Enable receive IRQ on the BLE channel.
|
262 | 265 | LL_C1_IPCC_EnableIT_RXO(IPCC);
|
263 | 266 | 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 |
265 | 267 | LL_C1_IPCC_EnableReceiveChannel(IPCC, IPCC_CH_BLE);
|
266 |
| - #endif |
267 | 268 | NVIC_SetPriority(IPCC_C1_RX_IRQn, irq_pri);
|
268 | 269 | HAL_NVIC_EnableIRQ(IPCC_C1_RX_IRQn);
|
269 | 270 |
|
@@ -449,12 +450,10 @@ STATIC void tl_check_msg(volatile tl_list_node_t *head, unsigned int ch, parse_h
|
449 | 450 | // Clear receive channel (allows RF core to send more data to us).
|
450 | 451 | LL_C1_IPCC_ClearFlag_CHx(IPCC, ch);
|
451 | 452 |
|
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)) { |
454 | 454 | // Renable IRQs for BLE now that we've cleared the flag.
|
455 | 455 | LL_C1_IPCC_EnableReceiveChannel(IPCC, IPCC_CH_BLE);
|
456 | 456 | }
|
457 |
| - #endif |
458 | 457 | }
|
459 | 458 | }
|
460 | 459 |
|
@@ -528,7 +527,7 @@ STATIC void tl_ble_hci_cmd_resp(uint16_t opcode, const uint8_t *buf, size_t len)
|
528 | 527 | /******************************************************************************/
|
529 | 528 | // RF core interface
|
530 | 529 |
|
531 |
| -void rfcore_init(void) { |
| 530 | +void rfcore_init() { |
532 | 531 | DEBUG_printf("rfcore_init\n");
|
533 | 532 |
|
534 | 533 | // Ensure LSE is running
|
@@ -589,6 +588,7 @@ static const struct {
|
589 | 588 | void rfcore_ble_init(void) {
|
590 | 589 | DEBUG_printf("rfcore_ble_init\n");
|
591 | 590 |
|
| 591 | + |
592 | 592 | // Clear any outstanding messages from ipcc_init.
|
593 | 593 | tl_check_msg(&ipcc_mem_sys_queue, IPCC_CH_SYS, NULL);
|
594 | 594 |
|
@@ -646,7 +646,7 @@ void rfcore_ble_hci_cmd(size_t len, const uint8_t *src) {
|
646 | 646 | break;
|
647 | 647 | }
|
648 | 648 | #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) { |
650 | 650 | mp_bluetooth_nimble_hci_uart_wfi();
|
651 | 651 | }
|
652 | 652 | #endif
|
|
0 commit comments