From be5cf2ddb902bba44eb45944df667db273c7ea45 Mon Sep 17 00:00:00 2001 From: Ali Hozhabri Date: Wed, 30 Aug 2023 08:31:09 +0200 Subject: [PATCH] driver: bluetooth: hci: fix potential "block forever" issue Interrupt is enabled before reset is released to make sure that the first IRQ edge is captured, and rx thread can process it. Remove delay in spi_open as it was redundant due to the "sem_initialised" semaphore. Signed-off-by: Ali Hozhabri --- drivers/bluetooth/hci/spi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/bluetooth/hci/spi.c b/drivers/bluetooth/hci/spi.c index 57ebc0cadf9..ccabab969f2 100644 --- a/drivers/bluetooth/hci/spi.c +++ b/drivers/bluetooth/hci/spi.c @@ -287,8 +287,6 @@ static void bt_spi_rx_thread(void) int len; (void)memset(&txmsg, 0xFF, SPI_MAX_MSG_LEN); - /* Enable the interrupt line */ - gpio_pin_interrupt_configure_dt(&irq_gpio, GPIO_INT_EDGE_TO_ACTIVE); while (true) { /* Wait for interrupt pin to be active */ @@ -497,13 +495,13 @@ static int bt_spi_open(void) return err; } + /* Enable the interrupt line */ + gpio_pin_interrupt_configure_dt(&irq_gpio, GPIO_INT_EDGE_TO_ACTIVE); + /* Take BLE out of reset */ k_sleep(K_MSEC(DT_INST_PROP_OR(0, reset_assert_duration_ms, 0))); gpio_pin_set_dt(&rst_gpio, 0); - /* Give the controller some time to boot */ - k_sleep(K_MSEC(1)); - /* Start RX thread */ k_thread_create(&spi_rx_thread_data, spi_rx_stack, K_KERNEL_STACK_SIZEOF(spi_rx_stack),