Skip to content

Commit 413518e

Browse files
ubiedanashif
authored andcommitted
serial: bt: Set configurable options for the NUS Work-queue
Default priority set to Main Thread's and Stack-size set to 1KiB. This should still allow for the System work-queue, considering this Work-queue could be temporarily blocked on BT TX commands. Signed-off-by: Luis Ubieda <luisf@croxel.com>
1 parent b1913fb commit 413518e

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

drivers/serial/Kconfig.bt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,19 @@ config UART_BT
1111
help
1212
Enable the UART over NUS Bluetooth driver, which can be used to pipe
1313
serial data over Bluetooth LE GATT using NUS (Nordic UART Service).
14+
15+
if UART_BT
16+
17+
config UART_BT_WORKQUEUE_PRIORITY
18+
int "UART NUS Work-queue Priority"
19+
default MAIN_THREAD_PRIORITY
20+
help
21+
Select UART NUS Work-queue priority based on the application context.
22+
23+
config UART_BT_WORKQUEUE_STACK_SIZE
24+
int "UART NUS Work-queue Stack Size"
25+
default 1024
26+
help
27+
Set UART NUS Work-queue Stack-size based on the application context.
28+
29+
endif

drivers/serial/uart_bt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <zephyr/logging/log.h>
1616
LOG_MODULE_REGISTER(uart_nus, CONFIG_UART_LOG_LEVEL);
1717

18-
K_THREAD_STACK_DEFINE(nus_work_queue_stack, 2048);
18+
K_THREAD_STACK_DEFINE(nus_work_queue_stack, CONFIG_UART_BT_WORKQUEUE_STACK_SIZE);
1919
static struct k_work_q nus_work_queue;
2020

2121
struct uart_bt_data {
@@ -276,7 +276,7 @@ static int uart_bt_workqueue_init(void)
276276
k_work_queue_init(&nus_work_queue);
277277
k_work_queue_start(&nus_work_queue, nus_work_queue_stack,
278278
K_THREAD_STACK_SIZEOF(nus_work_queue_stack),
279-
K_LOWEST_APPLICATION_THREAD_PRIO, NULL);
279+
CONFIG_UART_BT_WORKQUEUE_PRIORITY, NULL);
280280

281281
return 0;
282282
}

0 commit comments

Comments
 (0)