From 413518e0c8e733b3ae0bf8cdefdc32aa48a37530 Mon Sep 17 00:00:00 2001 From: Luis Ubieda Date: Mon, 29 Apr 2024 21:45:06 -0400 Subject: [PATCH] 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 --- drivers/serial/Kconfig.bt | 16 ++++++++++++++++ drivers/serial/uart_bt.c | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/serial/Kconfig.bt b/drivers/serial/Kconfig.bt index 500613d6208..214109759ae 100644 --- a/drivers/serial/Kconfig.bt +++ b/drivers/serial/Kconfig.bt @@ -11,3 +11,19 @@ config UART_BT help Enable the UART over NUS Bluetooth driver, which can be used to pipe serial data over Bluetooth LE GATT using NUS (Nordic UART Service). + +if UART_BT + +config UART_BT_WORKQUEUE_PRIORITY + int "UART NUS Work-queue Priority" + default MAIN_THREAD_PRIORITY + help + Select UART NUS Work-queue priority based on the application context. + +config UART_BT_WORKQUEUE_STACK_SIZE + int "UART NUS Work-queue Stack Size" + default 1024 + help + Set UART NUS Work-queue Stack-size based on the application context. + +endif diff --git a/drivers/serial/uart_bt.c b/drivers/serial/uart_bt.c index a68f747f69f..9e4a4de5930 100644 --- a/drivers/serial/uart_bt.c +++ b/drivers/serial/uart_bt.c @@ -15,7 +15,7 @@ #include LOG_MODULE_REGISTER(uart_nus, CONFIG_UART_LOG_LEVEL); -K_THREAD_STACK_DEFINE(nus_work_queue_stack, 2048); +K_THREAD_STACK_DEFINE(nus_work_queue_stack, CONFIG_UART_BT_WORKQUEUE_STACK_SIZE); static struct k_work_q nus_work_queue; struct uart_bt_data { @@ -276,7 +276,7 @@ static int uart_bt_workqueue_init(void) k_work_queue_init(&nus_work_queue); k_work_queue_start(&nus_work_queue, nus_work_queue_stack, K_THREAD_STACK_SIZEOF(nus_work_queue_stack), - K_LOWEST_APPLICATION_THREAD_PRIO, NULL); + CONFIG_UART_BT_WORKQUEUE_PRIORITY, NULL); return 0; }