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>
This commit is contained in:
Luis Ubieda 2024-04-29 21:45:06 -04:00 committed by Anas Nashif
commit 413518e0c8
2 changed files with 18 additions and 2 deletions

View file

@ -11,3 +11,19 @@ config UART_BT
help help
Enable the UART over NUS Bluetooth driver, which can be used to pipe Enable the UART over NUS Bluetooth driver, which can be used to pipe
serial data over Bluetooth LE GATT using NUS (Nordic UART Service). 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

View file

@ -15,7 +15,7 @@
#include <zephyr/logging/log.h> #include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(uart_nus, CONFIG_UART_LOG_LEVEL); 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; static struct k_work_q nus_work_queue;
struct uart_bt_data { 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_init(&nus_work_queue);
k_work_queue_start(&nus_work_queue, nus_work_queue_stack, k_work_queue_start(&nus_work_queue, nus_work_queue_stack,
K_THREAD_STACK_SIZEOF(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; return 0;
} }