-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
stm32/wb55: Add usb/bluetooth transparent mode to stm32wb55. #7703
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
base: master
Are you sure you want to change the base?
Conversation
#define MICROPY_HW_STM32WB_TRANSPARENT_MODE (1) This will disable normal BLE Stack usage and allow forwarding all HCI from stdin to BLE code.
Codecov Report
@@ Coverage Diff @@
## master #7703 +/- ##
=======================================
Coverage 98.25% 98.26%
=======================================
Files 154 154
Lines 20071 20072 +1
=======================================
+ Hits 19721 19723 +2
+ Misses 350 349 -1
Continue to review full report at Codecov.
|
49ccc27
to
12055c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @andrewleech for putting this together and sorting out the remaining issues!
@dpgeorge I'm not sure if MICROPY_HW_STM32WB_TRANSPARENT_MODE
is the right naming for this config option..wdyt?
Note: Without supporting the vendor HCI payloads it won't work with STM CubeMonitorRF, but that's something we can add in a future PR.
ports/stm32/rfcore.c
Outdated
@@ -261,9 +264,7 @@ void ipcc_init(uint32_t irq_pri) { | |||
// Enable receive IRQ on the BLE channel. | |||
LL_C1_IPCC_EnableIT_RXO(IPCC); | |||
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); | |||
#if !MICROPY_HW_STM32WB_TRANSPARENT_MODE | |||
LL_C1_IPCC_EnableReceiveChannel(IPCC, IPCC_CH_BLE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be only enabled if NimBLE is being used. I think probably the simplest way to do this is to move this call to the start of rfcore_ble_init
(at which point you'll be able to check the state of mp_bluetooth_nimble_ble_state
).
I think down the track I'd probably make it so the caller of rfcore_ble_init
(whcih is currently either transparent mode or hci uart init) pass a use_irqs
bool or something, but what you have seems fine for now.
It would be worth adding a check to stm.rfcore_transparent() to early-fail if NimBLE is started too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was originally going to add an arg to rfcore_ble_init
for this however it'd still need a (new?) global variable to know whether to allow/block the irq re-enable in:
STATIC void tl_check_msg(volatile tl_list_node_t *head, unsigned int ch, parse_hci_info_t *parse) {
...
if (ch == IPCC_CH_BLE && (mp_bluetooth_nimble_ble_state != MP_BLUETOOTH_NIMBLE_BLE_STATE_OFF)) {
// Renable IRQs for BLE now that we've cleared the flag.
LL_C1_IPCC_EnableReceiveChannel(IPCC, IPCC_CH_BLE);
}
}
as such re-using mp_bluetooth_nimble_ble_state
is an efficient one to use, rather than creating something new.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved LL_C1_IPCC_EnableReceiveChannel(IPCC, IPCC_CH_BLE);
as suggested in latest push
@@ -589,6 +588,7 @@ static const struct { | |||
void rfcore_ble_init(void) { | |||
DEBUG_printf("rfcore_ble_init\n"); | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra line added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
12055c7
to
8f85920
Compare
Todo: implement extra interfaces (custom hci commands) to enable compatibility with stm32cubemonitor https://github.com/STMicroelectronics/STM32CubeWB/blob/master/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode/STM32_WPAN/App/tm.c |
Closing in favour of #9046. |
This is an automated heads-up that we've just merged a Pull Request See #13763 A search suggests this PR might apply the STATIC macro to some C code. If it Although this is an automated message, feel free to @-reply to me directly if |
This PR allows the usage of a stm32wb55 board (eg. nucleo or dongle) as a USB/UART Bluetooth HCI Dongle. This allows it to be used to provide bluetooth functionality with the unix micropython port.
This functionality was written by @jimmo, I've sinply debugged to resolve some glitches and submitted it here.
This will disable normal BLE Stack usage and allow forwarding all HCI from stdin to BLE code.
To enable, build with the following define.
#define MICROPY_HW_STM32WB_TRANSPARENT_MODE (1)
Alternatively, it can be built with
When running on the board, it can be started with:
or this can be added to main.py to make it start automatically.