ble_mesh: Split mesh os related into a separate file

This commit is contained in:
lly 2020-03-30 19:33:25 +08:00
parent ac51ec11ec
commit 4b21a34675
9 changed files with 74 additions and 45 deletions

View file

@ -334,6 +334,7 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/mesh_common/mesh_atomic.c" "esp_ble_mesh/mesh_common/mesh_atomic.c"
"esp_ble_mesh/mesh_common/mesh_buf.c" "esp_ble_mesh/mesh_common/mesh_buf.c"
"esp_ble_mesh/mesh_common/mesh_common.c" "esp_ble_mesh/mesh_common/mesh_common.c"
"esp_ble_mesh/mesh_common/mesh_kernel.c"
"esp_ble_mesh/mesh_common/mesh_mutex.c" "esp_ble_mesh/mesh_common/mesh_mutex.c"
"esp_ble_mesh/mesh_common/mesh_timer.c" "esp_ble_mesh/mesh_common/mesh_timer.c"
"esp_ble_mesh/mesh_common/mesh_util.c" "esp_ble_mesh/mesh_common/mesh_util.c"

View file

@ -15,10 +15,8 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "adv.h" #include "adv.h"
#include "mesh_kernel.h"
#include "mesh_proxy.h" #include "mesh_proxy.h"
#include "mesh.h" #include "mesh.h"
#include "access.h" #include "access.h"

View file

@ -0,0 +1,54 @@
/*
* Copyright (c) 2016, Wind River Systems, Inc.
* Additional Copyright (c) 2020 Espressif Systems (Shanghai) PTE LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _BLE_MESH_KERNEL_H_
#define _BLE_MESH_KERNEL_H_
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "mesh_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef CONFIG_BT_BLUEDROID_ENABLED
#define BLE_MESH_ADV_TASK_CORE TASK_PINNED_TO_CORE
#endif
#ifdef CONFIG_BT_NIMBLE_ENABLED
#ifdef CONFIG_BT_NIMBLE_PINNED_TO_CORE
#define BLE_MESH_ADV_TASK_CORE (CONFIG_BT_NIMBLE_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BT_NIMBLE_PINNED_TO_CORE : tskNO_AFFINITY)
#else
#define BLE_MESH_ADV_TASK_CORE (0)
#endif
#endif
#define BLE_MESH_ADV_TASK_STACK_SIZE 3072
/**
* @brief Put the current thread to sleep.
*
* This routine puts the current thread to sleep for @a duration
* milliseconds.
*
* @param duration Number of milliseconds to sleep.
*
* @return N/A
*/
void k_sleep(s32_t duration);
#ifdef __cplusplus
}
#endif
#endif /* _BLE_MESH_KERNEL_H_ */

View file

@ -15,12 +15,7 @@
#ifndef _BLE_MESH_MUTEX_H_ #ifndef _BLE_MESH_MUTEX_H_
#define _BLE_MESH_MUTEX_H_ #define _BLE_MESH_MUTEX_H_
#include "freertos/FreeRTOS.h" #include "mesh_kernel.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "mesh_types.h"
#include "mesh_slist.h" #include "mesh_slist.h"
#include "mesh_atomic.h" #include "mesh_atomic.h"

View file

@ -256,18 +256,6 @@ void k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler);
*/ */
s64_t k_uptime_get(void); s64_t k_uptime_get(void);
/**
* @brief Put the current thread to sleep.
*
* This routine puts the current thread to sleep for @a duration
* milliseconds.
*
* @param duration Number of milliseconds to sleep.
*
* @return N/A
*/
void k_sleep(s32_t duration);
void bt_mesh_timer_init(void); void bt_mesh_timer_init(void);
void bt_mesh_timer_deinit(void); void bt_mesh_timer_deinit(void);

View file

@ -0,0 +1,14 @@
/*
* Copyright (c) 2016 Intel Corporation
* Copyright (c) 2016 Wind River Systems, Inc.
* Additional Copyright (c) 2020 Espressif Systems (Shanghai) PTE LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "mesh_kernel.h"
void k_sleep(s32_t duration)
{
vTaskDelay(duration / portTICK_PERIOD_MS);
}

View file

@ -43,12 +43,6 @@ u32_t k_uptime_get_32(void)
return (u32_t)(esp_timer_get_time() / 1000); return (u32_t)(esp_timer_get_time() / 1000);
} }
void k_sleep(s32_t duration)
{
vTaskDelay(duration / portTICK_PERIOD_MS);
return;
}
void bt_mesh_timer_init(void) void bt_mesh_timer_init(void)
{ {
bm_alarm_hash_map = hash_map_new(BLE_MESH_GENERAL_ALARM_HASH_MAP_SIZE, bm_alarm_hash_map = hash_map_new(BLE_MESH_GENERAL_ALARM_HASH_MAP_SIZE,

View file

@ -11,14 +11,11 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include "freertos/FreeRTOS.h" #include "bt_common.h"
#include "freertos/queue.h"
#include "freertos/task.h"
#include "osi/thread.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_ADV) #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_ADV)
#include "mesh_kernel.h"
#include "mesh.h" #include "mesh.h"
#include "mesh_hci.h" #include "mesh_hci.h"
#include "mesh_common.h" #include "mesh_common.h"

View file

@ -21,25 +21,13 @@ extern "C" {
/* BLE Mesh Max Connection Count */ /* BLE Mesh Max Connection Count */
#ifdef CONFIG_BT_BLUEDROID_ENABLED #ifdef CONFIG_BT_BLUEDROID_ENABLED
#define BLE_MESH_MAX_CONN \ #define BLE_MESH_MAX_CONN MIN(CONFIG_BT_ACL_CONNECTIONS, CONFIG_BTDM_CTRL_BLE_MAX_CONN)
MIN(CONFIG_BT_ACL_CONNECTIONS, CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN)
#define BLE_MESH_ADV_TASK_CORE TASK_PINNED_TO_CORE
#endif #endif
#ifdef CONFIG_BT_NIMBLE_ENABLED #ifdef CONFIG_BT_NIMBLE_ENABLED
#define BLE_MESH_MAX_CONN CONFIG_BT_NIMBLE_MAX_CONNECTIONS #define BLE_MESH_MAX_CONN CONFIG_BT_NIMBLE_MAX_CONNECTIONS
#ifdef CONFIG_BT_NIMBLE_PINNED_TO_CORE
#define BLE_MESH_ADV_TASK_CORE (CONFIG_BT_NIMBLE_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BT_NIMBLE_PINNED_TO_CORE : tskNO_AFFINITY)
#else
#define BLE_MESH_ADV_TASK_CORE (0)
#endif #endif
#endif
#define BLE_MESH_ADV_TASK_STACK_SIZE 3072
#define BLE_MESH_GAP_ADV_MAX_LEN 31 #define BLE_MESH_GAP_ADV_MAX_LEN 31
#define BLE_MESH_GATT_DEF_MTU_SIZE 23 #define BLE_MESH_GATT_DEF_MTU_SIZE 23