1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20 #include <stddef.h> 21 #include "os/os.h" 22 #include "sysinit/sysinit.h" 23 #include "host/ble_hs.h" 24 #if NIMBLE_CFG_CONTROLLER 25 #include "controller/ble_ll.h" 26 #endif 27 28 static struct ble_npl_eventq g_eventq_dflt; 29 30 void nimble_port_init(void)31nimble_port_init(void) 32 { 33 void os_msys_init(void); 34 void ble_store_ram_init(void); 35 #if NIMBLE_CFG_CONTROLLER 36 void ble_hci_ram_init(void); 37 #endif 38 39 /* Initialize default event queue */ 40 ble_npl_eventq_init(&g_eventq_dflt); 41 42 os_msys_init(); 43 44 ble_hs_init(); 45 46 /* XXX Need to have template for store */ 47 ble_store_ram_init(); 48 49 #if NIMBLE_CFG_CONTROLLER 50 hal_timer_init(5, NULL); 51 os_cputime_init(32768); 52 ble_ll_init(); 53 ble_hci_ram_init(); 54 #endif 55 } 56 57 void nimble_port_run(void)58nimble_port_run(void) 59 { 60 struct ble_npl_event *ev; 61 62 while (1) { 63 ev = ble_npl_eventq_get(&g_eventq_dflt, BLE_NPL_TIME_FOREVER); 64 ble_npl_event_run(ev); 65 } 66 } 67 68 struct ble_npl_eventq * nimble_port_get_dflt_eventq(void)69nimble_port_get_dflt_eventq(void) 70 { 71 return &g_eventq_dflt; 72 } 73 74 #if NIMBLE_CFG_CONTROLLER 75 void nimble_port_ll_task_func(void * arg)76nimble_port_ll_task_func(void *arg) 77 { 78 extern void ble_ll_task(void *); 79 80 ble_ll_task(arg); 81 } 82 #endif 83