mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-22 01:27:11 +08:00
feat(esp8266): Using global functions instead of function table
The Wi-Fi adapter APIs are only used by internal libraires.
This commit is contained in:
@ -65,7 +65,6 @@
|
||||
#include "esp_err.h"
|
||||
#include "esp_wifi_types.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_wifi_os_adapter.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -96,7 +95,7 @@ extern "C" {
|
||||
*/
|
||||
typedef struct {
|
||||
system_event_handler_t event_handler; /**< WiFi event handler */
|
||||
wifi_osi_funcs_t* osi_funcs; /**< WiFi OS functions */
|
||||
void* osi_funcs; /**< WiFi OS functions */
|
||||
int static_rx_buf_num; /**< WiFi static RX buffer number */
|
||||
int dynamic_rx_buf_num; /**< WiFi dynamic RX buffer number */
|
||||
int tx_buf_type; /**< WiFi TX buffer type */
|
||||
@ -114,10 +113,9 @@ typedef struct {
|
||||
|
||||
#define WIFI_INIT_CONFIG_MAGIC 0x1F2F3F4F
|
||||
|
||||
extern wifi_osi_funcs_t s_wifi_osi_funcs;
|
||||
#define WIFI_INIT_CONFIG_DEFAULT() { \
|
||||
.event_handler = &esp_event_send, \
|
||||
.osi_funcs = &s_wifi_osi_funcs, \
|
||||
.osi_funcs = NULL, \
|
||||
.static_rx_buf_num = 5,\
|
||||
.dynamic_rx_buf_num = 0,\
|
||||
.tx_buf_type = 0,\
|
||||
|
@ -1,113 +0,0 @@
|
||||
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef ESP_WIFI_OS_ADAPTER_H_
|
||||
#define ESP_WIFI_OS_ADAPTER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_WIFI_OS_ADAPTER_VERSION 0x00000001
|
||||
#define ESP_WIFI_OS_ADAPTER_MAGIC 0xDEADBEAF
|
||||
|
||||
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
||||
|
||||
#define OSI_QUEUE_SEND_FRONT 0
|
||||
#define OSI_QUEUE_SEND_BACK 1
|
||||
#define OSI_QUEUE_SEND_OVERWRITE 2
|
||||
|
||||
#define OSI_MALLOC_CAP_32BIT (1 << 1)
|
||||
#define OSI_MALLOC_CAP_8BIT (1 << 2)
|
||||
#define OSI_MALLOC_CAP_DMA (1 << 3)
|
||||
|
||||
typedef struct {
|
||||
int32_t version;
|
||||
|
||||
void *(*task_create)(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio);
|
||||
void (*task_delete)(void *task_handle);
|
||||
void (*task_yield)(void);
|
||||
void (*task_yield_from_isr)(void);
|
||||
void (*task_delay)(uint32_t tick);
|
||||
void *(*task_get_current_task)(void);
|
||||
uint32_t (*task_get_max_priority)(void);
|
||||
|
||||
uint32_t (*task_ms_to_tick)(uint32_t ms);
|
||||
|
||||
void (*task_suspend_all)(void);
|
||||
void (*task_resume_all)(void);
|
||||
|
||||
void (*os_init)(void);
|
||||
void (*os_start)(void);
|
||||
|
||||
void *(*semphr_create)(uint32_t max, uint32_t init);
|
||||
void (*semphr_delete)(void *semphr);
|
||||
bool (*semphr_take_from_isr)(void *semphr, int *hptw);
|
||||
bool (*semphr_give_from_isr)(void *semphr, int *hptw);
|
||||
bool (*semphr_take)(void *semphr, uint32_t block_time_tick);
|
||||
bool (*semphr_give)(void *semphr);
|
||||
|
||||
void *(*mutex_create)(void);
|
||||
void (*mutex_delete)(void *mutex);
|
||||
bool (*mutex_lock)(void *mutex);
|
||||
bool (*mutex_unlock)(void *mutex);
|
||||
|
||||
void *(*queue_create)(uint32_t queue_len, uint32_t item_size);
|
||||
void (*queue_delete)(void *queue);
|
||||
bool (*queue_send)(void *queue, void *item, uint32_t block_time_tick, uint32_t pos);
|
||||
bool (*queue_send_from_isr)(void *queue, void *item, int *hptw);
|
||||
bool (*queue_recv)(void *queue, void *item, uint32_t block_time_tick);
|
||||
bool (*queue_recv_from_isr)(void *queue, void *item, int *hptw);
|
||||
uint32_t (*queue_msg_waiting)(void *queue);
|
||||
|
||||
void *(*timer_create)(const char *name, uint32_t period_ticks, bool auto_load, void *arg, void (*cb)(void *timer));
|
||||
void *(*timer_get_arg)(void *timer);
|
||||
bool (*timer_reset)(void *timer, uint32_t ticks);
|
||||
bool (*timer_stop)(void *timer, uint32_t ticks);
|
||||
bool (*timer_delete)(void *timer, uint32_t ticks);
|
||||
|
||||
void *(*malloc)(uint32_t size, uint32_t cap, const char *file, size_t line);
|
||||
void *(*zalloc)(uint32_t size, uint32_t cap, const char *file, size_t line);
|
||||
void *(*realloc)(void *ptr, uint32_t size, uint32_t cap, const char *file, size_t line);
|
||||
void *(*calloc)(uint32_t cnt, uint32_t size, uint32_t cap, const char *file, size_t line);
|
||||
void (*free)(void *p, const char *file, size_t line);
|
||||
uint32_t (*get_free_heap_size)(void);
|
||||
|
||||
void (*srand)(uint32_t seed);
|
||||
int32_t (*rand)(void);
|
||||
|
||||
int32_t (* nvs_set_i8)(uint32_t handle, const char* key, int8_t value);
|
||||
int32_t (* nvs_get_i8)(uint32_t handle, const char* key, int8_t* out_value);
|
||||
int32_t (* nvs_set_u8)(uint32_t handle, const char* key, uint8_t value);
|
||||
int32_t (* nvs_get_u8)(uint32_t handle, const char* key, uint8_t* out_value);
|
||||
int32_t (* nvs_set_u16)(uint32_t handle, const char* key, uint16_t value);
|
||||
int32_t (* nvs_get_u16)(uint32_t handle, const char* key, uint16_t* out_value);
|
||||
int32_t (* nvs_open)(const char* name, uint32_t open_mode, uint32_t *out_handle);
|
||||
void (* nvs_close)(uint32_t handle);
|
||||
int32_t (* nvs_commit)(uint32_t handle);
|
||||
int32_t (* nvs_set_blob)(uint32_t handle, const char* key, const void* value, size_t length);
|
||||
int32_t (* nvs_get_blob)(uint32_t handle, const char* key, void* out_value, size_t* length);
|
||||
int32_t (* nvs_erase_key)(uint32_t handle, const char* key);
|
||||
|
||||
int32_t magic;
|
||||
} wifi_osi_funcs_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ESP_WIFI_OS_ADAPTER_H_ */
|
@ -15,141 +15,18 @@
|
||||
#ifndef ESP_WIFI_OSI_H_
|
||||
#define ESP_WIFI_OSI_H_
|
||||
|
||||
#include "esp_wifi_os_adapter.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern wifi_osi_funcs_t s_wifi_osi_funcs;
|
||||
#define ESP_WIFI_OS_ADAPTER_VERSION 0x00000001
|
||||
#define ESP_WIFI_OS_ADAPTER_MAGIC 0xDEADBEAF
|
||||
|
||||
#define wifi_task_create(func, name, depth, param, pri) \
|
||||
s_wifi_osi_funcs.task_create(func, name, depth, param, pri)
|
||||
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
||||
|
||||
#define wifi_task_delete(h) \
|
||||
s_wifi_osi_funcs.task_delete(h)
|
||||
|
||||
#define wifi_task_yield() \
|
||||
s_wifi_osi_funcs.task_yield()
|
||||
|
||||
#define wifi_task_yield_from_isr() \
|
||||
s_wifi_osi_funcs.task_yield_from_isr()
|
||||
|
||||
#define wifi_task_delay(t) \
|
||||
s_wifi_osi_funcs.task_delay(t)
|
||||
|
||||
#define wifi_task_get_current_task() \
|
||||
s_wifi_osi_funcs.task_get_current_task()
|
||||
|
||||
#define wifi_task_get_max_priority() \
|
||||
s_wifi_osi_funcs.task_get_max_priority()
|
||||
|
||||
#define wifi_task_ms_to_ticks(t) \
|
||||
s_wifi_osi_funcs.task_ms_to_tick(t)
|
||||
|
||||
#define wifi_task_suspend_all() \
|
||||
s_wifi_osi_funcs.task_suspend_all()
|
||||
|
||||
#define wifi_task_resume_all() \
|
||||
s_wifi_osi_funcs.task_resume_all()
|
||||
|
||||
#define wifi_os_init() \
|
||||
s_wifi_osi_funcs.os_init()
|
||||
|
||||
#define wifi_os_start() \
|
||||
s_wifi_osi_funcs.os_start()
|
||||
|
||||
#define wifi_semphr_create(m, i) \
|
||||
s_wifi_osi_funcs.semphr_create(m, i)
|
||||
|
||||
#define wifi_semphr_delete(s) \
|
||||
s_wifi_osi_funcs.semphr_delete(s)
|
||||
|
||||
#define wifi_semphr_take_from_isr(s, r) \
|
||||
s_wifi_osi_funcs.semphr_take_from_isr(s, r)
|
||||
|
||||
#define wifi_semphr_give_from_isr(s, r) \
|
||||
s_wifi_osi_funcs.semphr_give_from_isr(s, r)
|
||||
|
||||
#define wifi_semphr_take(s, t) \
|
||||
s_wifi_osi_funcs.semphr_take(s, t)
|
||||
|
||||
#define wifi_semphr_give(s) \
|
||||
s_wifi_osi_funcs.semphr_give(s)
|
||||
|
||||
#define wifi_mutex_create() \
|
||||
s_wifi_osi_funcs.mutex_create()
|
||||
|
||||
#define wifi_mutex_delete(m) \
|
||||
s_wifi_osi_funcs.mutex_delete(m)
|
||||
|
||||
#define wifi_mutex_lock(m) \
|
||||
s_wifi_osi_funcs.mutex_lock(m)
|
||||
|
||||
#define wifi_mutex_unlock(m) \
|
||||
s_wifi_osi_funcs.mutex_unlock(m)
|
||||
|
||||
#define wifi_queue_create(ql, is) \
|
||||
s_wifi_osi_funcs.queue_create(ql, is)
|
||||
|
||||
#define wifi_queue_delete(q) \
|
||||
s_wifi_osi_funcs.queue_delete(q)
|
||||
|
||||
#define wifi_queue_send(q, i, t, p) \
|
||||
s_wifi_osi_funcs.queue_send(q, i, t, p)
|
||||
|
||||
#define wifi_queue_send_from_isr(q, i, r) \
|
||||
s_wifi_osi_funcs.queue_send_from_isr(q, i, r)
|
||||
|
||||
#define wifi_queue_recv(q, i, t) \
|
||||
s_wifi_osi_funcs.queue_recv(q, i, t)
|
||||
|
||||
#define wifi_queue_recv_from_isr(q, i, r) \
|
||||
s_wifi_osi_funcs.queue_recv_from_isr(q, i, r)
|
||||
|
||||
#define wifi_queue_msg_waiting(q) \
|
||||
s_wifi_osi_funcs.queue_msg_waiting(q)
|
||||
|
||||
#define wifi_timer_create(n, p, al, ag, cb) \
|
||||
s_wifi_osi_funcs.timer_create(n, p, al, ag, cb)
|
||||
|
||||
#define wifi_timer_get_arg(t) \
|
||||
s_wifi_osi_funcs.timer_get_arg(t)
|
||||
|
||||
#define wifi_timer_reset(t, tk) \
|
||||
s_wifi_osi_funcs.timer_reset(t, tk)
|
||||
|
||||
#define wifi_timer_stop(t, tk) \
|
||||
s_wifi_osi_funcs.timer_stop(t, tk)
|
||||
|
||||
#define wifi_timer_delete(t, tk) \
|
||||
s_wifi_osi_funcs.timer_delete(t, tk)
|
||||
|
||||
#define wifi_malloc(s, c) \
|
||||
s_wifi_osi_funcs.malloc(s, c, __ESP_FILE__, __LINE__)
|
||||
|
||||
#define wifi_zalloc(s, c) \
|
||||
s_wifi_osi_funcs.zalloc(s, c, __ESP_FILE__, __LINE__)
|
||||
|
||||
#define wifi_calloc(cnt, s, c) \
|
||||
s_wifi_osi_funcs.calloc(cnt, s, c, __ESP_FILE__, __LINE__)
|
||||
|
||||
#define wifi_realloc(ptr, s, c) \
|
||||
s_wifi_osi_funcs.realloc(ptr, s, c, __ESP_FILE__, __LINE__)
|
||||
|
||||
#define wifi_free(p) \
|
||||
s_wifi_osi_funcs.free(p, __ESP_FILE__, __LINE__)
|
||||
|
||||
#define wifi_get_free_heap_size() \
|
||||
s_wifi_osi_funcs.get_free_heap_size()
|
||||
|
||||
#define wifi_srand(s) \
|
||||
s_wifi_osi_funcs.srand(s)
|
||||
|
||||
#define wifi_rand() \
|
||||
s_wifi_osi_funcs.rand()
|
||||
|
||||
void *osi_task_top_sp(void);
|
||||
#define OSI_QUEUE_SEND_FRONT 0
|
||||
#define OSI_QUEUE_SEND_BACK 1
|
||||
#define OSI_QUEUE_SEND_OVERWRITE 2
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
gwen:
|
||||
core: 38f8c34
|
||||
net80211: 38f8c34
|
||||
pp: ee8b2d1
|
||||
wpa: 38f8c34
|
||||
espnow: 38f8c34
|
||||
wps: 38f8c34
|
||||
core: eacdf2c
|
||||
net80211: eacdf2c
|
||||
pp: eacdf2c
|
||||
wpa: eacdf2c
|
||||
espnow: eacdf2c
|
||||
wps: eacdf2c
|
||||
|
||||
smartconfig: 2.8.1
|
||||
phy: 1055_22
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -17,7 +17,7 @@
|
||||
#include "esp_libc.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_wifi_os_adapter.h"
|
||||
#include "esp_wifi_osi.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
@ -27,11 +27,7 @@
|
||||
|
||||
#include "nvs.h"
|
||||
|
||||
#if defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL) || defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NANO)
|
||||
#include "esp_newlib.h"
|
||||
#endif
|
||||
|
||||
static void *task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio)
|
||||
void *__wifi_task_create(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio)
|
||||
{
|
||||
portBASE_TYPE ret;
|
||||
xTaskHandle handle;
|
||||
@ -40,152 +36,42 @@ static void *task_create_wrapper(void *task_func, const char *name, uint32_t sta
|
||||
return ret == pdPASS ? handle : NULL;
|
||||
}
|
||||
|
||||
static void task_delete_wrapper(void *task_handle)
|
||||
{
|
||||
vTaskDelete(task_handle);
|
||||
}
|
||||
|
||||
static void task_yield_wrapper(void)
|
||||
void __wifi_task_yield_from_isr(void)
|
||||
{
|
||||
portYIELD();
|
||||
}
|
||||
|
||||
static void task_yield_from_isr_wrapper(void)
|
||||
{
|
||||
portYIELD();
|
||||
}
|
||||
|
||||
static void task_delay_wrapper(uint32_t tick)
|
||||
void __wifi_task_delay(uint32_t tick)
|
||||
{
|
||||
vTaskDelay(tick);
|
||||
}
|
||||
|
||||
static void* task_get_current_task_wrapper(void)
|
||||
{
|
||||
return (void *)xTaskGetCurrentTaskHandle();
|
||||
}
|
||||
|
||||
static uint32_t task_get_max_priority_wrapper(void)
|
||||
uint32_t __wifi_task_get_max_priority(void)
|
||||
{
|
||||
return (uint32_t)(configMAX_PRIORITIES);
|
||||
}
|
||||
|
||||
static uint32_t task_ms_to_tick_wrapper(uint32_t ms)
|
||||
uint32_t __wifi_task_ms_to_ticks(uint32_t ms)
|
||||
{
|
||||
return (uint32_t)(ms / portTICK_RATE_MS);
|
||||
}
|
||||
|
||||
static void task_suspend_all_wrapper(void)
|
||||
void __wifi_task_suspend_all(void)
|
||||
{
|
||||
vTaskSuspendAll();
|
||||
}
|
||||
|
||||
static void task_resume_all_wrapper(void)
|
||||
void __wifi_task_resume_all(void)
|
||||
{
|
||||
xTaskResumeAll();
|
||||
}
|
||||
|
||||
static void os_init_wrapper(void)
|
||||
{
|
||||
#if defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL) || defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NANO)
|
||||
esp_newlib_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void os_start_wrapper(void)
|
||||
{
|
||||
vTaskStartScheduler();
|
||||
}
|
||||
|
||||
static void *semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||
{
|
||||
return (void *)xSemaphoreCreateCounting(max, init);
|
||||
}
|
||||
|
||||
static void semphr_delete_wrapper(void *semphr)
|
||||
{
|
||||
vSemaphoreDelete(semphr);
|
||||
}
|
||||
|
||||
static bool semphr_take_from_isr_wrapper(void *semphr, int *hptw)
|
||||
{
|
||||
signed portBASE_TYPE ret;
|
||||
|
||||
ret = xSemaphoreTakeFromISR(semphr, (signed portBASE_TYPE *)hptw);
|
||||
|
||||
return ret == pdPASS ? true : false;
|
||||
}
|
||||
|
||||
static bool semphr_give_from_isr_wrapper(void *semphr, int *hptw)
|
||||
{
|
||||
signed portBASE_TYPE ret;
|
||||
|
||||
ret = xSemaphoreGiveFromISR(semphr, (signed portBASE_TYPE *)hptw);
|
||||
|
||||
return ret == pdPASS ? true : false;
|
||||
}
|
||||
|
||||
static bool semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
||||
{
|
||||
signed portBASE_TYPE ret;
|
||||
|
||||
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
||||
ret = xSemaphoreTake(semphr, portMAX_DELAY);
|
||||
} else {
|
||||
ret = xSemaphoreTake(semphr, block_time_tick);
|
||||
}
|
||||
|
||||
return ret == pdPASS ? true : false;
|
||||
}
|
||||
|
||||
static bool semphr_give_wrapper(void *semphr)
|
||||
{
|
||||
signed portBASE_TYPE ret;
|
||||
|
||||
ret = xSemaphoreGive(semphr);
|
||||
|
||||
return ret == pdPASS ? true : false;
|
||||
}
|
||||
|
||||
static void *mutex_create_wrapper(void)
|
||||
{
|
||||
return (void *)xSemaphoreCreateRecursiveMutex();
|
||||
}
|
||||
|
||||
static void mutex_delete_wrapper(void *mutex)
|
||||
{
|
||||
vSemaphoreDelete(mutex);
|
||||
}
|
||||
|
||||
static bool mutex_lock_wrapper(void *mutex)
|
||||
{
|
||||
signed portBASE_TYPE ret;
|
||||
|
||||
ret = xSemaphoreTakeRecursive(mutex, portMAX_DELAY);
|
||||
|
||||
return ret == pdPASS ? true : false;
|
||||
}
|
||||
|
||||
static bool mutex_unlock_wrapper(void *mutex)
|
||||
{
|
||||
signed portBASE_TYPE ret;
|
||||
|
||||
ret = xSemaphoreGiveRecursive(mutex);
|
||||
|
||||
return ret == pdPASS ? true : false;
|
||||
}
|
||||
|
||||
static void *queue_create_wrapper(uint32_t queue_len, uint32_t item_size)
|
||||
void *__wifi_queue_create(uint32_t queue_len, uint32_t item_size)
|
||||
{
|
||||
return (void *)xQueueCreate(queue_len, item_size);
|
||||
}
|
||||
|
||||
static void queue_delete_wrapper(void *queue)
|
||||
{
|
||||
vQueueDelete(queue);
|
||||
}
|
||||
|
||||
static bool queue_send_wrapper(void *queue, void *item, uint32_t block_time_tick, uint32_t pos)
|
||||
int __wifi_queue_send(void *queue, void *item, uint32_t block_time_tick, uint32_t pos)
|
||||
{
|
||||
signed portBASE_TYPE ret;
|
||||
BaseType_t os_pos;
|
||||
@ -206,7 +92,7 @@ static bool queue_send_wrapper(void *queue, void *item, uint32_t block_time_tick
|
||||
return ret == pdPASS ? true : false;
|
||||
}
|
||||
|
||||
static bool queue_send_from_isr_wrapper(void *queue, void *item, int *hptw)
|
||||
int __wifi_queue_send_from_isr(void *queue, void *item, int *hptw)
|
||||
{
|
||||
signed portBASE_TYPE ret;
|
||||
|
||||
@ -215,7 +101,7 @@ static bool queue_send_from_isr_wrapper(void *queue, void *item, int *hptw)
|
||||
return ret == pdPASS ? true : false;
|
||||
}
|
||||
|
||||
static bool queue_recv_wrapper(void *queue, void *item, uint32_t block_time_tick)
|
||||
int __wifi_queue_recv(void *queue, void *item, uint32_t block_time_tick)
|
||||
{
|
||||
signed portBASE_TYPE ret;
|
||||
|
||||
@ -228,187 +114,24 @@ static bool queue_recv_wrapper(void *queue, void *item, uint32_t block_time_tick
|
||||
return ret == pdPASS ? true : false;
|
||||
}
|
||||
|
||||
static bool queue_recv_from_isr_wrapper(void *queue, void *item, int *hptw)
|
||||
{
|
||||
signed portBASE_TYPE ret;
|
||||
|
||||
ret = xQueueReceiveFromISR(queue, item, (signed portBASE_TYPE *)hptw);
|
||||
|
||||
return ret == pdPASS ? true : false;
|
||||
}
|
||||
|
||||
static uint32_t queue_msg_waiting_wrapper(void *queue)
|
||||
{
|
||||
return (uint32_t)uxQueueMessagesWaiting(queue);
|
||||
}
|
||||
|
||||
static uint32_t get_free_heap_size_wrapper(void)
|
||||
{
|
||||
return (uint32_t)esp_get_free_heap_size();
|
||||
}
|
||||
|
||||
static void *timer_create_wrapper(const char *name, uint32_t period_ticks, bool auto_load, void *arg, void (*cb)(void *timer))
|
||||
void *__wifi_timer_create(const char *name, uint32_t period_ticks, bool auto_load, void *arg, void (*cb)(void *timer))
|
||||
{
|
||||
return xTimerCreate(name, period_ticks, auto_load, arg, (tmrTIMER_CALLBACK)cb);
|
||||
}
|
||||
|
||||
static void *timer_get_arg_wrapper(void *timer)
|
||||
{
|
||||
return pvTimerGetTimerID(timer);
|
||||
}
|
||||
|
||||
static bool timer_reset_wrapper(void *timer, uint32_t ticks)
|
||||
int __wifi_timer_reset(void *timer, uint32_t ticks)
|
||||
{
|
||||
return xTimerReset(timer, ticks);
|
||||
}
|
||||
|
||||
static bool timer_stop_wrapper(void *timer, uint32_t ticks)
|
||||
int __wifi_timer_stop(void *timer, uint32_t ticks)
|
||||
{
|
||||
return xTimerStop(timer, ticks);
|
||||
}
|
||||
|
||||
static bool timer_delete_wrapper(void *timer, uint32_t ticks)
|
||||
{
|
||||
return xTimerDelete(timer, ticks);
|
||||
}
|
||||
|
||||
static void *malloc_wrapper(uint32_t s, uint32_t cap, const char *file, size_t line)
|
||||
{
|
||||
uint32_t os_caps;
|
||||
|
||||
if (cap & (OSI_MALLOC_CAP_8BIT | OSI_MALLOC_CAP_DMA))
|
||||
os_caps = MALLOC_CAP_8BIT | MALLOC_CAP_DMA;
|
||||
else
|
||||
os_caps = MALLOC_CAP_32BIT;
|
||||
|
||||
return _heap_caps_malloc(s, os_caps, file, line);
|
||||
}
|
||||
|
||||
static void *zalloc_wrapper(uint32_t s, uint32_t cap, const char *file, size_t line)
|
||||
{
|
||||
uint32_t os_caps;
|
||||
|
||||
if (cap & (OSI_MALLOC_CAP_8BIT | OSI_MALLOC_CAP_DMA))
|
||||
os_caps = MALLOC_CAP_8BIT | MALLOC_CAP_DMA;
|
||||
else
|
||||
os_caps = MALLOC_CAP_32BIT;
|
||||
|
||||
return _heap_caps_zalloc(s, os_caps, file, line);
|
||||
}
|
||||
|
||||
static void *realloc_wrapper(void *ptr, uint32_t s, uint32_t cap, const char *file, size_t line)
|
||||
{
|
||||
uint32_t os_caps;
|
||||
|
||||
if (cap & (OSI_MALLOC_CAP_8BIT | OSI_MALLOC_CAP_DMA))
|
||||
os_caps = MALLOC_CAP_8BIT | MALLOC_CAP_DMA;
|
||||
else
|
||||
os_caps = MALLOC_CAP_32BIT;
|
||||
|
||||
return _heap_caps_realloc(ptr, s, os_caps, file, line);
|
||||
}
|
||||
|
||||
static void *calloc_wrapper(uint32_t cnt, uint32_t s, uint32_t cap, const char *file, size_t line)
|
||||
{
|
||||
uint32_t os_caps;
|
||||
|
||||
if (cap & (OSI_MALLOC_CAP_8BIT | OSI_MALLOC_CAP_DMA))
|
||||
os_caps = MALLOC_CAP_8BIT | MALLOC_CAP_DMA;
|
||||
else
|
||||
os_caps = MALLOC_CAP_32BIT;
|
||||
|
||||
return _heap_caps_calloc(cnt , s, os_caps, file, line);
|
||||
}
|
||||
|
||||
static void free_wrapper(void *ptr, const char *file, size_t line)
|
||||
{
|
||||
_heap_caps_free(ptr, file, line);
|
||||
}
|
||||
|
||||
static void srand_wrapper(uint32_t seed)
|
||||
{
|
||||
/* empty function */
|
||||
}
|
||||
|
||||
static int32_t rand_wrapper(void)
|
||||
{
|
||||
return (int32_t)esp_random();
|
||||
}
|
||||
|
||||
void *osi_task_top_sp(void)
|
||||
void *__wifi_task_top_sp(void)
|
||||
{
|
||||
extern uint32_t **pxCurrentTCB;
|
||||
|
||||
return pxCurrentTCB[0];
|
||||
}
|
||||
|
||||
const wifi_osi_funcs_t s_wifi_osi_funcs = {
|
||||
.version = ESP_WIFI_OS_ADAPTER_VERSION,
|
||||
|
||||
.task_create = task_create_wrapper,
|
||||
.task_delete = task_delete_wrapper,
|
||||
.task_yield = task_yield_wrapper,
|
||||
.task_yield_from_isr = task_yield_from_isr_wrapper,
|
||||
.task_delay = task_delay_wrapper,
|
||||
.task_get_current_task = task_get_current_task_wrapper,
|
||||
.task_get_max_priority = task_get_max_priority_wrapper,
|
||||
|
||||
.task_ms_to_tick = task_ms_to_tick_wrapper,
|
||||
|
||||
.task_suspend_all = task_suspend_all_wrapper,
|
||||
.task_resume_all = task_resume_all_wrapper,
|
||||
|
||||
.os_init = os_init_wrapper,
|
||||
.os_start = os_start_wrapper,
|
||||
|
||||
.semphr_create = semphr_create_wrapper,
|
||||
.semphr_delete = semphr_delete_wrapper,
|
||||
.semphr_take_from_isr = semphr_take_from_isr_wrapper,
|
||||
.semphr_give_from_isr = semphr_give_from_isr_wrapper,
|
||||
.semphr_take = semphr_take_wrapper,
|
||||
.semphr_give = semphr_give_wrapper,
|
||||
|
||||
.mutex_create = mutex_create_wrapper,
|
||||
.mutex_delete = mutex_delete_wrapper,
|
||||
.mutex_lock = mutex_lock_wrapper,
|
||||
.mutex_unlock = mutex_unlock_wrapper,
|
||||
|
||||
.queue_create = queue_create_wrapper,
|
||||
.queue_delete = queue_delete_wrapper,
|
||||
.queue_send = queue_send_wrapper,
|
||||
.queue_send_from_isr = queue_send_from_isr_wrapper,
|
||||
.queue_recv = queue_recv_wrapper,
|
||||
.queue_recv_from_isr = queue_recv_from_isr_wrapper,
|
||||
.queue_msg_waiting = queue_msg_waiting_wrapper,
|
||||
|
||||
.timer_create = timer_create_wrapper,
|
||||
.timer_get_arg = timer_get_arg_wrapper,
|
||||
.timer_reset = timer_reset_wrapper,
|
||||
.timer_stop = timer_stop_wrapper,
|
||||
.timer_delete = timer_delete_wrapper,
|
||||
|
||||
.malloc = malloc_wrapper,
|
||||
.zalloc = zalloc_wrapper,
|
||||
.realloc = realloc_wrapper,
|
||||
.calloc = calloc_wrapper,
|
||||
.free = free_wrapper,
|
||||
.get_free_heap_size = get_free_heap_size_wrapper,
|
||||
|
||||
.srand = srand_wrapper,
|
||||
.rand = rand_wrapper,
|
||||
|
||||
.nvs_set_i8 = nvs_set_i8,
|
||||
.nvs_get_i8 = nvs_get_i8,
|
||||
.nvs_set_u8 = nvs_set_u8,
|
||||
.nvs_get_u8 = nvs_get_u8,
|
||||
.nvs_set_u16 = nvs_set_u16,
|
||||
.nvs_get_u16 = nvs_get_u16,
|
||||
.nvs_open = nvs_open,
|
||||
.nvs_close = nvs_close,
|
||||
.nvs_commit = nvs_commit,
|
||||
.nvs_set_blob = nvs_set_blob,
|
||||
.nvs_get_blob = nvs_get_blob,
|
||||
.nvs_erase_key = nvs_erase_key,
|
||||
|
||||
.magic = ESP_WIFI_OS_ADAPTER_MAGIC,
|
||||
};
|
@ -20,11 +20,14 @@
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_event_loop.h"
|
||||
#include "esp_wifi_osi.h"
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
|
||||
static const char* TAG = "event";
|
||||
static bool s_event_init_flag = false;
|
||||
static void *s_event_queue = NULL;
|
||||
@ -43,7 +46,7 @@ static void esp_event_loop_task(void *pvParameters)
|
||||
{
|
||||
while (1) {
|
||||
system_event_t evt;
|
||||
if (wifi_queue_recv(s_event_queue, &evt, OSI_FUNCS_TIME_BLOCKING) == pdPASS) {
|
||||
if (xQueueReceive(s_event_queue, &evt, portMAX_DELAY) == pdPASS) {
|
||||
esp_err_t ret = esp_event_process_default(&evt);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "default event handler failed!");
|
||||
@ -71,8 +74,8 @@ esp_err_t esp_event_send(system_event_t *event)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
int ret = wifi_queue_send(s_event_queue, event, 0, OSI_QUEUE_SEND_BACK);
|
||||
if (ret != true) {
|
||||
int ret = xQueueGenericSend(s_event_queue, event, 0, queueSEND_TO_BACK);
|
||||
if (ret != pdPASS) {
|
||||
if (event) {
|
||||
ESP_LOGE(TAG, "e=%d f", event->event_id);
|
||||
} else {
|
||||
@ -95,10 +98,10 @@ esp_err_t esp_event_loop_init(system_event_cb_t cb, void *ctx)
|
||||
}
|
||||
s_event_handler_cb = cb;
|
||||
s_event_ctx = ctx;
|
||||
s_event_queue = wifi_queue_create(32, sizeof(system_event_t));
|
||||
s_event_queue = xQueueCreate(32, sizeof(system_event_t));
|
||||
if(s_event_queue == NULL)
|
||||
return ESP_ERR_NO_MEM;
|
||||
if(wifi_task_create(esp_event_loop_task, "esp_event_loop_task", EVENT_LOOP_STACKSIZE, NULL, wifi_task_get_max_priority() - 5) == NULL) {
|
||||
if(xTaskCreate(esp_event_loop_task, "esp_event_loop_task", EVENT_LOOP_STACKSIZE, NULL, configMAX_PRIORITIES - 5, NULL) != pdPASS) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
s_event_handler_cb = cb;
|
||||
|
@ -25,13 +25,19 @@
|
||||
#include "esp_log.h"
|
||||
#include "esp_image_format.h"
|
||||
#include "esp_phy_init.h"
|
||||
#include "esp_wifi_osi.h"
|
||||
#include "esp_heap_caps_init.h"
|
||||
#include "esp_task_wdt.h"
|
||||
#include "internal/esp_wifi_internal.h"
|
||||
#include "internal/esp_system_internal.h"
|
||||
#include "esp8266/eagle_soc.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
#if defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL) || defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NANO)
|
||||
#include "esp_newlib.h"
|
||||
#endif
|
||||
|
||||
extern void chip_boot(void);
|
||||
extern int rtc_init(void);
|
||||
extern int mac_init(void);
|
||||
@ -95,7 +101,7 @@ static void user_init_entry(void *param)
|
||||
|
||||
app_main();
|
||||
|
||||
wifi_task_delete(NULL);
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void call_user_start(size_t start_addr)
|
||||
@ -149,9 +155,11 @@ void call_user_start(size_t start_addr)
|
||||
|
||||
heap_caps_init();
|
||||
|
||||
wifi_os_init();
|
||||
#if defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL) || defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NANO)
|
||||
esp_newlib_init();
|
||||
#endif
|
||||
|
||||
assert(wifi_task_create(user_init_entry, "uiT", CONFIG_MAIN_TASK_STACK_SIZE, NULL, wifi_task_get_max_priority()) != NULL);
|
||||
assert(xTaskCreate(user_init_entry, "uiT", CONFIG_MAIN_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES, NULL) == pdPASS);
|
||||
|
||||
wifi_os_start();
|
||||
vTaskStartScheduler();
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "esp_libc.h"
|
||||
#include "esp_wifi_osi.h"
|
||||
#include "esp_task_wdt.h"
|
||||
#include "portmacro.h"
|
||||
#include "esp8266/eagle_soc.h"
|
||||
@ -30,8 +29,9 @@ static const char *TAG = "wdt";
|
||||
static void esp_task_wdt_isr(void *param)
|
||||
{
|
||||
extern void panicHandler(void *frame, int wdt);
|
||||
extern void *__wifi_task_top_sp(void);
|
||||
|
||||
panicHandler(osi_task_top_sp(), 1);
|
||||
panicHandler(__wifi_task_top_sp(), 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "priv/esp_spi_flash_raw.h"
|
||||
|
||||
#include "esp_attr.h"
|
||||
#include "esp_wifi_osi.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_task_wdt.h"
|
||||
|
@ -41,9 +41,11 @@
|
||||
#include "dhcpserver/dhcpserver.h"
|
||||
#include "dhcpserver/dhcpserver_options.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_wifi_osi.h"
|
||||
#include "internal/esp_wifi_internal.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "timers.h"
|
||||
|
||||
struct tcpip_adapter_pbuf {
|
||||
struct pbuf_custom pbuf;
|
||||
|
||||
@ -72,7 +74,7 @@ static esp_err_t tcpip_adapter_reset_ip_info(tcpip_adapter_if_t tcpip_if);
|
||||
static esp_err_t tcpip_adapter_start_ip_lost_timer(tcpip_adapter_if_t tcpip_if);
|
||||
static void tcpip_adapter_dhcpc_cb(struct netif *netif);
|
||||
static void tcpip_adapter_ip_lost_timer(void *arg);
|
||||
static void tcpip_adapter_dhcpc_done(void *arg);
|
||||
static void tcpip_adapter_dhcpc_done(TimerHandle_t arg);
|
||||
static bool tcpip_inited = false;
|
||||
|
||||
static const char* TAG = "tcpip_adapter";
|
||||
@ -83,7 +85,7 @@ void system_station_got_ip_set();
|
||||
|
||||
static int dhcp_fail_time = 0;
|
||||
static tcpip_adapter_ip_info_t esp_ip[TCPIP_ADAPTER_IF_MAX];
|
||||
static void *dhcp_check_timer;
|
||||
static TimerHandle_t *dhcp_check_timer;
|
||||
|
||||
static void tcpip_adapter_dhcps_cb(u8_t client_ip[4])
|
||||
{
|
||||
@ -180,7 +182,7 @@ void tcpip_adapter_init(void)
|
||||
IP4_ADDR(&esp_ip[TCPIP_ADAPTER_IF_AP].gw, 192, 168 , 4, 1);
|
||||
IP4_ADDR(&esp_ip[TCPIP_ADAPTER_IF_AP].netmask, 255, 255 , 255, 0);
|
||||
|
||||
dhcp_check_timer = wifi_timer_create("check_dhcp", wifi_task_ms_to_ticks(500), true, NULL, tcpip_adapter_dhcpc_done);
|
||||
dhcp_check_timer = xTimerCreate("check_dhcp", 500 / portTICK_RATE_MS, true, NULL, tcpip_adapter_dhcpc_done);
|
||||
if (!dhcp_check_timer) {
|
||||
ESP_LOGI(TAG, "TCPIP adapter timer create error");
|
||||
}
|
||||
@ -269,7 +271,7 @@ static int tcpip_adapter_sta_recv_cb(void *buffer, uint16_t len, void *eb)
|
||||
return tcpip_adapter_recv_cb(esp_netif[ESP_IF_WIFI_STA], buffer, len, eb);
|
||||
}
|
||||
|
||||
static void tcpip_adapter_dhcpc_done(void *arg)
|
||||
static void tcpip_adapter_dhcpc_done(TimerHandle_t xTimer)
|
||||
{
|
||||
struct dhcp *clientdhcp = netif_dhcp_data(esp_netif[TCPIP_ADAPTER_IF_STA]) ;
|
||||
struct netif *netif = esp_netif[TCPIP_ADAPTER_IF_STA];
|
||||
@ -283,7 +285,7 @@ static void tcpip_adapter_dhcpc_done(void *arg)
|
||||
struct autoip *autoip = netif_autoip_data(netif);
|
||||
#endif
|
||||
|
||||
wifi_timer_stop(dhcp_check_timer, 0);
|
||||
xTimerStop(dhcp_check_timer, 0);
|
||||
if (netif_is_up(esp_netif[TCPIP_ADAPTER_IF_STA])) {
|
||||
if (clientdhcp->state == DHCP_STATE_BOUND
|
||||
#if LWIP_IPV4 && LWIP_AUTOIP
|
||||
@ -298,7 +300,7 @@ static void tcpip_adapter_dhcpc_done(void *arg)
|
||||
} else if (dhcp_fail_time < (CONFIG_IP_LOST_TIMER_INTERVAL * 1000 / 500)) {
|
||||
ESP_LOGD(TAG,"dhcpc time(ms): %d\n", dhcp_fail_time * 500);
|
||||
dhcp_fail_time ++;
|
||||
wifi_timer_reset(dhcp_check_timer, 0);
|
||||
xTimerReset(dhcp_check_timer, 0);
|
||||
} else {
|
||||
dhcp_fail_time = 0;
|
||||
ESP_LOGD(TAG,"ERROR dhcp get ip error\n");
|
||||
@ -1062,7 +1064,7 @@ esp_err_t tcpip_adapter_dhcpc_start(tcpip_adapter_if_t tcpip_if)
|
||||
}
|
||||
|
||||
dhcp_fail_time = 0;
|
||||
wifi_timer_reset(dhcp_check_timer, 0);
|
||||
xTimerReset(dhcp_check_timer, 0);
|
||||
ESP_LOGD(TAG, "dhcp client start successfully");
|
||||
dhcpc_status[tcpip_if] = TCPIP_ADAPTER_DHCP_STARTED;
|
||||
return ESP_OK;
|
||||
|
Reference in New Issue
Block a user