mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-09-15 13:40:01 +00:00
[wip] fix initialization stuff
This commit is contained in:
@@ -24,9 +24,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void nimble_init(void);
|
||||
|
||||
void nimble_run(void);
|
||||
void nimble_port_sysinit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "controller/ble_ll.h"
|
||||
|
||||
void
|
||||
nimble_init(void)
|
||||
nimble_port_sysinit(void)
|
||||
{
|
||||
void os_msys_init(void);
|
||||
void ble_hci_ram_pkg_init(void);
|
||||
@@ -50,16 +50,3 @@ nimble_init(void)
|
||||
ble_store_ram_init();
|
||||
sysinit_end();
|
||||
}
|
||||
|
||||
void
|
||||
nimble_run(void)
|
||||
{
|
||||
while (1) {
|
||||
struct os_event *ev;
|
||||
|
||||
ev = os_eventq_get(os_eventq_dflt_get());
|
||||
assert(ev->ev_cb != NULL);
|
||||
|
||||
ev->ev_cb(ev);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
#define configUSE_TICKLESS_IDLE_SIMPLE_DEBUG 1 /* See into vPortSuppressTicksAndSleep source code for explanation */
|
||||
#define configCPU_CLOCK_HZ ( SystemCoreClock )
|
||||
#define configTICK_RATE_HZ 1000
|
||||
#define configMAX_PRIORITIES ( 3 )
|
||||
#define configMAX_PRIORITIES ( 4 )
|
||||
#define configMINIMAL_STACK_SIZE ( 60 )
|
||||
#define configTOTAL_HEAP_SIZE ( 6144 )
|
||||
#define configMAX_TASK_NAME_LEN ( 4 )
|
||||
@@ -130,7 +130,7 @@
|
||||
|
||||
/* Software timer definitions. */
|
||||
#define configUSE_TIMERS 1
|
||||
#define configTIMER_TASK_PRIORITY ( 2 )
|
||||
#define configTIMER_TASK_PRIORITY ( 3 )
|
||||
#define configTIMER_QUEUE_LENGTH 32
|
||||
#define configTIMER_TASK_STACK_DEPTH ( 80 )
|
||||
|
||||
|
||||
@@ -132,25 +132,11 @@ on_sync_cb(void)
|
||||
}
|
||||
|
||||
static void
|
||||
task_func(void *param)
|
||||
dftl_task(void *param)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = hal_timer_init(0, NULL);
|
||||
assert(rc == 0);
|
||||
rc = hal_timer_init(5, NULL);
|
||||
assert(rc == 0);
|
||||
rc = os_cputime_init(MYNEWT_VAL(OS_CPUTIME_FREQ));
|
||||
assert(rc == 0);
|
||||
|
||||
nimble_init();
|
||||
|
||||
ble_hs_cfg.sync_cb = on_sync_cb;
|
||||
|
||||
ble_svc_gap_device_name_set(gap_name);
|
||||
ble_svc_ias_set_cb(ias_event_cb);
|
||||
|
||||
nimble_run();
|
||||
while (1) {
|
||||
os_eventq_run(os_eventq_dflt_get());
|
||||
}
|
||||
}
|
||||
|
||||
static void led_tmr_func(void *param)
|
||||
@@ -163,13 +149,40 @@ static void led_tmr_func(void *param)
|
||||
|
||||
void start_nimble(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
void ble_ll_task(void *arg);
|
||||
|
||||
led_tmr_h = xTimerCreate("led", 500, pdTRUE, NULL, led_tmr_func);
|
||||
/*
|
||||
* XXX initialize some stuff required by controller; we need to move this
|
||||
* somewhere later
|
||||
*/
|
||||
rc = hal_timer_init(0, NULL);
|
||||
assert(rc == 0);
|
||||
rc = hal_timer_init(5, NULL);
|
||||
assert(rc == 0);
|
||||
rc = os_cputime_init(MYNEWT_VAL(OS_CPUTIME_FREQ));
|
||||
assert(rc == 0);
|
||||
|
||||
xTaskCreate(task_func, "nimble", configMINIMAL_STACK_SIZE + 400,
|
||||
/* Execute sysinit port */
|
||||
nimble_port_sysinit();
|
||||
|
||||
/* Configure Nimble host */
|
||||
ble_hs_cfg.sync_cb = on_sync_cb;
|
||||
|
||||
ble_svc_gap_device_name_set(gap_name);
|
||||
ble_svc_ias_set_cb(ias_event_cb);
|
||||
|
||||
/* Create task which handles default event queue */
|
||||
xTaskCreate(dftl_task, "dflt", configMINIMAL_STACK_SIZE + 400,
|
||||
NULL, 1, &task_h);
|
||||
|
||||
/*
|
||||
* XXX create LL task; in Mynewt this is done in sysinit but for now this
|
||||
* is commented out there due to missing porting layer for task creation
|
||||
*/
|
||||
xTaskCreate(ble_ll_task, "ll", configMINIMAL_STACK_SIZE + 100,
|
||||
NULL, 2, &task_h);
|
||||
|
||||
xTaskCreate(ble_ll_task, "ll", configMINIMAL_STACK_SIZE + 100,
|
||||
NULL, 0, &task_h);
|
||||
led_tmr_h = xTimerCreate("led", 500, pdTRUE, NULL, led_tmr_func);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user