Skip to content

Commit 6940986

Browse files
committed
pbio/drv/bluetooth: Exit SPI process on main thread exit.
Otherwise the main thread would keep pushing along after completion, re-entering at the last step. In this thread, that would keep calling pbio_busy_count_down, so the shutdown procedure would not work right.
1 parent b975d5d commit 6940986

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

lib/pbio/drv/bluetooth/bluetooth_stm32_bluenrg.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,9 +1308,13 @@ static pbio_error_t pbdrv_bluetooth_spi_process_thread(pbio_os_state_t *state, v
13081308
for (;;) {
13091309
PBIO_OS_AWAIT_UNTIL(state, {
13101310
// Iterate the main Bluetooth thread once when some data is
1311-
// available or new data can be sent. It runs forever, so we don't
1312-
// check the busy state or returned error.
1313-
pbdrv_bluetooth_process_thread(&main_thread_state, NULL);
1311+
// available or new data can be sent.
1312+
pbio_error_t err = pbdrv_bluetooth_process_thread(&main_thread_state, NULL);
1313+
1314+
// Exit this spi process once the high level Bluetooth process completes.
1315+
if (err != PBIO_ERROR_AGAIN) {
1316+
return err;
1317+
}
13141318

13151319
// - spi_irq is set by the interrupt handler when there is new
13161320
// data to be processed, which also polls this process in order

lib/pbio/drv/bluetooth/bluetooth_stm32_cc2640.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,9 +1919,13 @@ static pbio_error_t pbdrv_bluetooth_spi_process_thread(pbio_os_state_t *state, v
19191919
for (;;) {
19201920
PBIO_OS_AWAIT_UNTIL(state, {
19211921
// Iterate the main Bluetooth thread once when some data is
1922-
// available or new data can be sent. It runs forever, so we don't
1923-
// check the busy state or returned error.
1924-
pbdrv_bluetooth_process_thread(&main_thread_state, NULL);
1922+
// available or new data can be sent.
1923+
pbio_error_t err = pbdrv_bluetooth_process_thread(&main_thread_state, NULL);
1924+
1925+
// Exit this spi process once the high level Bluetooth process completes.
1926+
if (err != PBIO_ERROR_AGAIN) {
1927+
return err;
1928+
}
19251929

19261930
// - spi_srdy is set by the interrupt handler when there is new
19271931
// data to be processed, which also polls this process in order

0 commit comments

Comments
 (0)