bluetooth: use k_thread_create()
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
33f80d7c85
commit
899cf94dbd
10 changed files with 50 additions and 34 deletions
|
@ -37,6 +37,7 @@
|
|||
#define H4_EVT 0x04
|
||||
|
||||
static BT_STACK_NOINIT(rx_thread_stack, CONFIG_BLUETOOTH_RX_STACK_SIZE);
|
||||
static struct k_thread rx_thread_data;
|
||||
|
||||
static struct {
|
||||
struct net_buf *buf;
|
||||
|
@ -437,8 +438,9 @@ static int h4_open(void)
|
|||
|
||||
uart_irq_callback_set(h4_dev, bt_uart_isr);
|
||||
|
||||
k_thread_spawn(rx_thread_stack, sizeof(rx_thread_stack), rx_thread,
|
||||
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||
k_thread_create(&rx_thread_data, rx_thread_stack,
|
||||
sizeof(rx_thread_stack), rx_thread,
|
||||
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
static BT_STACK_NOINIT(tx_stack, 256);
|
||||
static BT_STACK_NOINIT(rx_stack, 256);
|
||||
|
||||
static struct k_thread tx_thread_data;
|
||||
static struct k_thread rx_thread_data;
|
||||
|
||||
static struct k_delayed_work ack_work;
|
||||
static struct k_delayed_work retx_work;
|
||||
|
||||
|
@ -713,12 +716,14 @@ static void h5_init(void)
|
|||
|
||||
/* TX thread */
|
||||
k_fifo_init(&h5.tx_queue);
|
||||
k_thread_spawn(tx_stack, sizeof(tx_stack), (k_thread_entry_t)tx_thread,
|
||||
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||
k_thread_create(&tx_thread_data, tx_stack, sizeof(tx_stack),
|
||||
(k_thread_entry_t)tx_thread,
|
||||
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||
|
||||
k_fifo_init(&h5.rx_queue);
|
||||
k_thread_spawn(rx_stack, sizeof(rx_stack), (k_thread_entry_t)rx_thread,
|
||||
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||
k_thread_create(&rx_thread_data, rx_stack, sizeof(rx_stack),
|
||||
(k_thread_entry_t)rx_thread,
|
||||
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||
|
||||
/* Unack queue */
|
||||
k_fifo_init(&h5.unack_queue);
|
||||
|
|
|
@ -74,6 +74,7 @@ static K_SEM_DEFINE(sem_request, 0, 1);
|
|||
static K_SEM_DEFINE(sem_busy, 1, 1);
|
||||
|
||||
static BT_STACK_NOINIT(rx_stack, 448);
|
||||
static struct k_thread rx_thread_data;
|
||||
|
||||
static struct spi_config spi_conf = {
|
||||
.config = SPI_WORD(8),
|
||||
|
@ -323,9 +324,9 @@ static int bt_spi_open(void)
|
|||
}
|
||||
|
||||
/* Start RX thread */
|
||||
k_thread_spawn(rx_stack, sizeof(rx_stack),
|
||||
(k_thread_entry_t)bt_spi_rx_thread,
|
||||
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||
k_thread_create(&rx_thread_data, rx_stack, sizeof(rx_stack),
|
||||
(k_thread_entry_t)bt_spi_rx_thread,
|
||||
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||
|
||||
/* Take BLE out of reset */
|
||||
gpio_pin_write(rst_dev, GPIO_RESET_PIN, 1);
|
||||
|
|
|
@ -48,6 +48,8 @@ NET_BUF_POOL_DEFINE(tx_pool, NBLE_TX_BUF_COUNT, NBLE_BUF_SIZE, 0, NULL);
|
|||
|
||||
static BT_STACK_NOINIT(rx_thread_stack, CONFIG_BLUETOOTH_RX_STACK_SIZE);
|
||||
|
||||
static struct k_thread rx_thread_data;
|
||||
|
||||
static struct device *nble_dev;
|
||||
|
||||
static K_FIFO_DEFINE(rx_queue);
|
||||
|
@ -204,9 +206,9 @@ int nble_open(void)
|
|||
BT_DBG("");
|
||||
|
||||
/* Initialize receive queue and start rx_thread */
|
||||
k_thread_spawn(rx_thread_stack, sizeof(rx_thread_stack),
|
||||
(k_thread_entry_t)rx_thread,
|
||||
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||
k_thread_create(&rx_thread_data, rx_thread_stack,
|
||||
sizeof(rx_thread_stack), (k_thread_entry_t)rx_thread,
|
||||
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||
|
||||
uart_irq_rx_disable(nble_dev);
|
||||
uart_irq_tx_disable(nble_dev);
|
||||
|
|
|
@ -89,11 +89,9 @@ static inline __printf_like(1, 2) void _bt_log_dummy(const char *fmt, ...) {};
|
|||
}
|
||||
|
||||
#define BT_STACK(name, size) \
|
||||
char __stack name[(size) + K_THREAD_SIZEOF + \
|
||||
BT_STACK_DEBUG_EXTRA]
|
||||
char __stack name[(size) + BT_STACK_DEBUG_EXTRA]
|
||||
#define BT_STACK_NOINIT(name, size) \
|
||||
char __noinit __stack name[(size) + K_THREAD_SIZEOF + \
|
||||
BT_STACK_DEBUG_EXTRA]
|
||||
char __noinit __stack name[(size) + BT_STACK_DEBUG_EXTRA]
|
||||
|
||||
/* This helper is only available when BLUETOOTH_DEBUG is enabled */
|
||||
const char *bt_hex(const void *buf, size_t len);
|
||||
|
|
|
@ -95,7 +95,8 @@ struct bt_rfcomm_dlc {
|
|||
u8_t state;
|
||||
u8_t rx_credit;
|
||||
|
||||
/* Stack for TX fiber */
|
||||
/* Stack & kernel data for TX thread */
|
||||
struct k_thread tx_thread;
|
||||
BT_STACK(stack, 256);
|
||||
};
|
||||
|
||||
|
|
|
@ -46,8 +46,10 @@
|
|||
static K_SEM_DEFINE(sem_prio_recv, 0, UINT_MAX);
|
||||
static K_FIFO_DEFINE(recv_fifo);
|
||||
|
||||
struct k_thread prio_recv_thread_data;
|
||||
static BT_STACK_NOINIT(prio_recv_thread_stack,
|
||||
CONFIG_BLUETOOTH_CONTROLLER_RX_PRIO_STACK_SIZE);
|
||||
struct k_thread recv_thread_data;
|
||||
static BT_STACK_NOINIT(recv_thread_stack, CONFIG_BLUETOOTH_RX_STACK_SIZE);
|
||||
|
||||
#if defined(CONFIG_INIT_STACKS)
|
||||
|
@ -399,13 +401,13 @@ static int hci_driver_open(void)
|
|||
hci_init(NULL);
|
||||
#endif
|
||||
|
||||
k_thread_spawn(prio_recv_thread_stack, sizeof(prio_recv_thread_stack),
|
||||
prio_recv_thread, NULL, NULL, NULL, K_PRIO_COOP(6), 0,
|
||||
K_NO_WAIT);
|
||||
k_thread_create(&prio_recv_thread_data, prio_recv_thread_stack,
|
||||
sizeof(prio_recv_thread_stack), prio_recv_thread,
|
||||
NULL, NULL, NULL, K_PRIO_COOP(6), 0, K_NO_WAIT);
|
||||
|
||||
k_thread_spawn(recv_thread_stack, sizeof(recv_thread_stack),
|
||||
recv_thread, NULL, NULL, NULL, K_PRIO_COOP(7), 0,
|
||||
K_NO_WAIT);
|
||||
k_thread_create(&recv_thread_data, recv_thread_stack,
|
||||
sizeof(recv_thread_stack), recv_thread,
|
||||
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||
|
||||
BT_DBG("Success.");
|
||||
|
||||
|
|
|
@ -50,8 +50,10 @@
|
|||
|
||||
/* Stacks for the threads */
|
||||
#if !defined(CONFIG_BLUETOOTH_RECV_IS_RX_THREAD)
|
||||
static struct k_thread rx_thread_data;
|
||||
static BT_STACK_NOINIT(rx_thread_stack, CONFIG_BLUETOOTH_RX_STACK_SIZE);
|
||||
#endif
|
||||
static struct k_thread tx_thread_data;
|
||||
static BT_STACK_NOINIT(tx_thread_stack, CONFIG_BLUETOOTH_HCI_TX_STACK_SIZE);
|
||||
|
||||
static void init_work(struct k_work *work);
|
||||
|
@ -3944,15 +3946,16 @@ int bt_enable(bt_ready_cb_t cb)
|
|||
ready_cb = cb;
|
||||
|
||||
/* TX thread */
|
||||
k_thread_spawn(tx_thread_stack, sizeof(tx_thread_stack),
|
||||
hci_tx_thread, NULL, NULL, NULL, K_PRIO_COOP(7), 0,
|
||||
K_NO_WAIT);
|
||||
k_thread_create(&tx_thread_data, tx_thread_stack,
|
||||
sizeof(tx_thread_stack), hci_tx_thread, NULL, NULL,
|
||||
NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||
|
||||
#if !defined(CONFIG_BLUETOOTH_RECV_IS_RX_THREAD)
|
||||
/* RX thread */
|
||||
k_thread_spawn(rx_thread_stack, sizeof(rx_thread_stack),
|
||||
(k_thread_entry_t)hci_rx_thread, NULL, NULL, NULL,
|
||||
K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||
k_thread_create(&rx_thread_data, rx_thread_stack,
|
||||
sizeof(rx_thread_stack),
|
||||
(k_thread_entry_t)hci_rx_thread, NULL, NULL, NULL,
|
||||
K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||
#endif
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLUETOOTH_TINYCRYPT_ECC)) {
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "hci_core.h"
|
||||
#endif
|
||||
|
||||
static struct k_thread ecc_thread_data;
|
||||
static BT_STACK_NOINIT(ecc_thread_stack, 1060);
|
||||
|
||||
/* based on Core Specification 4.2 Vol 3. Part H 2.3.5.6.1 */
|
||||
|
@ -307,7 +308,7 @@ int bt_hci_ecc_send(struct net_buf *buf)
|
|||
|
||||
void bt_hci_ecc_init(void)
|
||||
{
|
||||
k_thread_spawn(ecc_thread_stack, sizeof(ecc_thread_stack),
|
||||
ecc_thread, NULL, NULL, NULL,
|
||||
K_PRIO_PREEMPT(10), 0, K_NO_WAIT);
|
||||
k_thread_create(&ecc_thread_data, ecc_thread_stack,
|
||||
sizeof(ecc_thread_stack), ecc_thread, NULL, NULL, NULL,
|
||||
K_PRIO_PREEMPT(10), 0, K_NO_WAIT);
|
||||
}
|
||||
|
|
|
@ -750,8 +750,9 @@ static void rfcomm_dlc_connected(struct bt_rfcomm_dlc *dlc)
|
|||
k_delayed_work_cancel(&dlc->rtx_work);
|
||||
|
||||
k_fifo_init(&dlc->tx_queue);
|
||||
k_thread_spawn(dlc->stack, sizeof(dlc->stack), rfcomm_dlc_tx_thread,
|
||||
dlc, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||
k_thread_create(&dlc->tx_thread, dlc->stack, sizeof(dlc->stack),
|
||||
rfcomm_dlc_tx_thread, dlc, NULL, NULL, K_PRIO_COOP(7),
|
||||
0, K_NO_WAIT);
|
||||
|
||||
if (dlc->ops && dlc->ops->connected) {
|
||||
dlc->ops->connected(dlc);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue