mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-09-07 01:30:05 +00:00
porting: Move default event queue management to common porting code
OS specific code should not care about default event queue thus it will be created by nimble_port_init() function internally. We'll just add simple getter in case someone wants to use it.
This commit is contained in:
@@ -27,6 +27,9 @@
|
||||
#include "ble_hs_priv.h"
|
||||
#include "ble_monitor_priv.h"
|
||||
#include "nimble/nimble_npl.h"
|
||||
#ifndef MYNEWT
|
||||
#include "nimble/nimble_port.h"
|
||||
#endif
|
||||
|
||||
#define BLE_HS_HCI_EVT_COUNT \
|
||||
(MYNEWT_VAL(BLE_HCI_EVT_HI_BUF_COUNT) + \
|
||||
@@ -674,13 +677,20 @@ ble_hs_init(void)
|
||||
/* Configure the HCI transport to communicate with a host. */
|
||||
ble_hci_trans_cfg_hs(ble_hs_hci_rx_evt, NULL, ble_hs_rx_data, NULL);
|
||||
|
||||
ble_hs_evq_set(ble_npl_eventq_dflt_get());
|
||||
|
||||
#ifdef MYNEWT
|
||||
ble_hs_evq_set((struct ble_npl_eventq *)os_eventq_dflt_get());
|
||||
#else
|
||||
ble_hs_evq_set(nimble_port_get_dflt_eventq());
|
||||
#endif
|
||||
/* Enqueue the start event to the default event queue. Using the default
|
||||
* queue ensures the event won't run until the end of main(). This allows
|
||||
* the application to configure this package in the meantime.
|
||||
*/
|
||||
ble_npl_eventq_put(ble_npl_eventq_dflt_get(), &ble_hs_ev_start);
|
||||
#ifdef MYNEWT
|
||||
ble_npl_eventq_put((struct ble_npl_eventq *)os_eventq_dflt_get(), &ble_hs_ev_start);
|
||||
#else
|
||||
ble_npl_eventq_put(nimble_port_get_dflt_eventq(), &ble_hs_ev_start);
|
||||
#endif
|
||||
|
||||
#if BLE_MONITOR
|
||||
ble_monitor_new_index(0, (uint8_t[6]){ }, "nimble0");
|
||||
|
||||
@@ -64,8 +64,6 @@ void *ble_npl_get_current_task_id(void);
|
||||
* Event queue
|
||||
*/
|
||||
|
||||
struct ble_npl_eventq *ble_npl_eventq_dflt_get(void);
|
||||
|
||||
void ble_npl_eventq_init(struct ble_npl_eventq *evq);
|
||||
|
||||
struct ble_npl_event *ble_npl_eventq_get(struct ble_npl_eventq *evq,
|
||||
|
||||
@@ -20,12 +20,16 @@
|
||||
#ifndef _NIMBLE_PORT_H
|
||||
#define _NIMBLE_PORT_H
|
||||
|
||||
#include "nimble/nimble_npl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void nimble_port_init(void);
|
||||
|
||||
struct ble_npl_eventq *nimble_port_get_dflt_eventq(void);
|
||||
|
||||
#if NIMBLE_CFG_CONTROLLER
|
||||
void nimble_port_ll_task_func(void *arg);
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "controller/ble_ll.h"
|
||||
#endif
|
||||
|
||||
static struct ble_npl_eventq g_eventq_dflt;
|
||||
|
||||
void
|
||||
nimble_port_init(void)
|
||||
{
|
||||
@@ -34,6 +36,9 @@ nimble_port_init(void)
|
||||
void ble_hci_ram_init(void);
|
||||
#endif
|
||||
|
||||
/* Initialize default event queue */
|
||||
ble_npl_eventq_init(&g_eventq_dflt);
|
||||
|
||||
os_msys_init();
|
||||
|
||||
ble_hs_init();
|
||||
@@ -49,6 +54,12 @@ nimble_port_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
struct ble_npl_eventq *
|
||||
nimble_port_get_dflt_eventq(void)
|
||||
{
|
||||
return &g_eventq_dflt;
|
||||
}
|
||||
|
||||
#if NIMBLE_CFG_CONTROLLER
|
||||
void
|
||||
nimble_port_ll_task_func(void *arg)
|
||||
|
||||
@@ -32,12 +32,6 @@ ble_npl_get_current_task_id(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct ble_npl_eventq *
|
||||
ble_npl_eventq_dflt_get(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
ble_npl_eventq_init(struct ble_npl_eventq *evq)
|
||||
{
|
||||
|
||||
@@ -85,14 +85,6 @@ ble_npl_get_current_task_id(void)
|
||||
return xTaskGetCurrentTaskHandle();
|
||||
}
|
||||
|
||||
struct ble_npl_eventq *npl_freertos_eventq_dflt_get(void);
|
||||
|
||||
static inline struct ble_npl_eventq *
|
||||
ble_npl_eventq_dflt_get(void)
|
||||
{
|
||||
return npl_freertos_eventq_dflt_get();
|
||||
}
|
||||
|
||||
static inline void
|
||||
ble_npl_eventq_init(struct ble_npl_eventq *evq)
|
||||
{
|
||||
|
||||
@@ -29,18 +29,6 @@ in_isr(void)
|
||||
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
|
||||
}
|
||||
|
||||
static struct ble_npl_eventq dflt_evq;
|
||||
|
||||
struct ble_npl_eventq *
|
||||
npl_freertos_eventq_dflt_get(void)
|
||||
{
|
||||
if (!dflt_evq.q) {
|
||||
dflt_evq.q = xQueueCreate(32, sizeof(struct ble_npl_eventq *));
|
||||
}
|
||||
|
||||
return &dflt_evq;
|
||||
}
|
||||
|
||||
struct ble_npl_event *
|
||||
npl_freertos_eventq_get(struct ble_npl_eventq *evq, ble_npl_time_t tmo)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user