更新模板到最新状态
This commit is contained in:
27
sal/CMakeLists.txt
Normal file
27
sal/CMakeLists.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
list(APPEND incs ".")
|
||||
list(APPEND incs "${IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos")
|
||||
list(APPEND incs "../components/system/include")
|
||||
list(APPEND incs "../components/system/source")
|
||||
list(APPEND incs "../components/system/source/k_kit")
|
||||
list(APPEND incs "../components/system/source/shell")
|
||||
|
||||
list(APPEND srcs "esp32/kernel/os_heap.c")
|
||||
list(APPEND srcs "esp32/kernel/os_mutex.c")
|
||||
list(APPEND srcs "esp32/kernel/os_hook.c")
|
||||
list(APPEND srcs "esp32/kernel/os_timer.c")
|
||||
list(APPEND srcs "esp32/kernel/os_semaphore.c")
|
||||
list(APPEND srcs "esp32/kernel/os_thread.c")
|
||||
list(APPEND srcs "esp32/kernel/os_kit.c")
|
||||
list(APPEND srcs "esp32/kernel/os_service.c")
|
||||
list(APPEND srcs "esp32/chip/uart_esp32.c")
|
||||
list(APPEND srcs "esp32/soc_shell.c")
|
||||
list(APPEND srcs "esp32/os_entry.c")
|
||||
|
||||
idf_component_register(
|
||||
INCLUDE_DIRS ${incs}
|
||||
SRCS ${srcs}
|
||||
REQUIRES
|
||||
driver
|
||||
nvs_flash
|
||||
spi_flash
|
||||
)
|
||||
@@ -211,6 +211,23 @@ os_state os_work_create(os_work_t *work_handle, const char *name, os_work_fn wor
|
||||
}
|
||||
}
|
||||
|
||||
os_state os_work_create_default(os_work_t *work_handle, const char *name, os_work_fn work_route, void *arg, uint8_t sub_prior, os_time_t delay_ms)
|
||||
{
|
||||
if (!os_work_is_valid(work_handle))
|
||||
{
|
||||
os_state ret = os_work_create(work_handle, name, work_route, arg, sub_prior);
|
||||
if (ret == OS_OK)
|
||||
{
|
||||
os_work_submit(default_os_work_q_hdl, work_handle, delay_ms);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
return OS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
void os_work_delete(os_work_t *work_handle)
|
||||
{
|
||||
OS_ASS_ISR();
|
||||
@@ -127,7 +127,7 @@ os_state os_thread_create(os_thread_t *thread,
|
||||
thread_handle,
|
||||
OS_KERNEL_PRIO(priority),
|
||||
&thread_handle->pxCreatedTask,
|
||||
1);
|
||||
0);
|
||||
if (ret != pdPASS)
|
||||
{
|
||||
OS_ERR("err %d\r\n", ret);
|
||||
72
sal/esp32/os_entry.c
Normal file
72
sal/esp32/os_entry.c
Normal file
@@ -0,0 +1,72 @@
|
||||
#include "os_entry.h"
|
||||
|
||||
#undef SYS_LOG_DOMAIN
|
||||
#define SYS_LOG_DOMAIN "OS"
|
||||
#include "kernel/os_util.h"
|
||||
|
||||
#ifndef CONFIG_OS_THREAD_MAIN_STACK_SIZE
|
||||
#define CONFIG_OS_THREAD_MAIN_STACK_SIZE 0x1C00
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_OS_THREAD_MAIN_PRIORITY
|
||||
#define CONFIG_OS_THREAD_MAIN_PRIORITY OS_PRIORITY_NORMAL
|
||||
#endif
|
||||
|
||||
static unsigned s_int_nest;
|
||||
|
||||
static unsigned _port_interrupt_save(void)
|
||||
{
|
||||
if (s_int_nest == 0)
|
||||
{
|
||||
os_interrupt_disable();
|
||||
}
|
||||
return s_int_nest++;
|
||||
}
|
||||
|
||||
static void _port_interrupt_restore(unsigned nest)
|
||||
{
|
||||
s_int_nest = nest;
|
||||
if (nest == 0)
|
||||
{
|
||||
os_interrupt_enable();
|
||||
}
|
||||
}
|
||||
|
||||
static k_work_q_t *_port_get_work_q_hdl(void)
|
||||
{
|
||||
struct os_thread_handle *thread_handle = os_thread_get_self();
|
||||
os_work_q_list_t *work_q_list = thread_handle->work_q_list;
|
||||
return &work_q_list->work_q_handle;
|
||||
}
|
||||
|
||||
static void _port_thread_sleep(k_tick_t sleep_ticks)
|
||||
{
|
||||
vTaskDelay(sleep_ticks);
|
||||
}
|
||||
|
||||
int os_entry(os_work_fn work_route)
|
||||
{
|
||||
static k_init_t const init_struct = {
|
||||
.malloc = os_malloc,
|
||||
.free = os_free,
|
||||
.get_sys_ticks = os_get_sys_ticks,
|
||||
.interrupt_save = _port_interrupt_save,
|
||||
.interrupt_restore = _port_interrupt_restore,
|
||||
.scheduler_disable = os_scheduler_suspend,
|
||||
.scheduler_enable = os_scheduler_resume,
|
||||
.get_work_q_hdl = _port_get_work_q_hdl,
|
||||
.thread_sleep = _port_thread_sleep,
|
||||
};
|
||||
k_init(&init_struct);
|
||||
|
||||
os_work_q_create(default_os_work_q_hdl,
|
||||
"app-work_q",
|
||||
CONFIG_OS_THREAD_MAIN_STACK_SIZE,
|
||||
CONFIG_OS_THREAD_MAIN_PRIORITY);
|
||||
|
||||
static os_work_t _work_hdl_init;
|
||||
os_work_create(&_work_hdl_init, "work-main", work_route, NULL, 3);
|
||||
os_work_submit(default_os_work_q_hdl, &_work_hdl_init, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
static char s_nvs_str_buf[0x40];
|
||||
|
||||
static int _value_set_str(const char *argv[]) { SET_VAR(&s_nvs_str_buf, 0, 0); }
|
||||
static int _value_set_str(const char *argv[]) { return SET_VAR(&s_nvs_str_buf, 0, 0); }
|
||||
|
||||
SH_CMD_FN(_nvs_dump);
|
||||
SH_CMD_FN(_nvs_erase);
|
||||
5
sal/os_entry.h
Normal file
5
sal/os_entry.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "os/os.h"
|
||||
|
||||
int os_entry(os_work_fn work_route);
|
||||
Reference in New Issue
Block a user