更新模板到最新状态
This commit is contained in:
@@ -1,47 +1,14 @@
|
||||
# INCS
|
||||
list(APPEND incs "../sal")
|
||||
|
||||
set(srcs-app
|
||||
)
|
||||
|
||||
# 基础程序
|
||||
set(srcs-common
|
||||
"ota.c"
|
||||
"../app/app_main.c"
|
||||
"../app/console.c"
|
||||
"../app/drivers/data_port/sb_data_port.c"
|
||||
"../app/drivers/data_port/uart/uart_port.c"
|
||||
"../app/button/button_event.c"
|
||||
)
|
||||
# SRCS
|
||||
list(APPEND srcs "main.c")
|
||||
list(APPEND srcs "ota.c")
|
||||
|
||||
# 自定义框架抽象层
|
||||
set(srcs-components
|
||||
"../components/system/source/k_kit/k_kit.c"
|
||||
"../components/system/source/shell/sh_vt100.c"
|
||||
"../components/system/source/shell/sh_vset.c"
|
||||
"../components/system/source/shell/sh.c"
|
||||
"../sal/esp32s3/kernel/os_heap.c"
|
||||
"../sal/esp32s3/kernel/os_mutex.c"
|
||||
"../sal/esp32s3/kernel/os_hook.c"
|
||||
"../sal/esp32s3/kernel/os_timer.c"
|
||||
"../sal/esp32s3/kernel/os_semaphore.c"
|
||||
"../sal/esp32s3/kernel/os_thread.c"
|
||||
"../sal/esp32s3/kernel/os_kit.c"
|
||||
"../sal/esp32s3/kernel/os_service.c"
|
||||
"../sal/esp32s3/chip/uart_esp32.c"
|
||||
"../sal/esp32s3/soc_shell.c"
|
||||
"../app/config/board_config.c"
|
||||
)
|
||||
set(incs
|
||||
"../app"
|
||||
"../components/system/include"
|
||||
"../components/system/source"
|
||||
"../components/system/source/k_kit"
|
||||
"../components/system/source/shell"
|
||||
"../sal/esp32s3"
|
||||
"../sal/esp32s3/kernel"
|
||||
"${IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos"
|
||||
)
|
||||
|
||||
idf_component_register(SRCS "main.c"
|
||||
${srcs-components}
|
||||
${srcs-common}
|
||||
INCLUDE_DIRS "." ${incs})
|
||||
# idf_component_register
|
||||
idf_component_register(
|
||||
INCLUDE_DIRS ${incs}
|
||||
SRCS ${srcs}
|
||||
)
|
||||
|
||||
77
main/main.c
77
main/main.c
@@ -9,83 +9,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "os/os.h"
|
||||
#include "os_entry.h"
|
||||
#include "app_main.h"
|
||||
|
||||
#include "ota.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
#undef SYS_LOG_DOMAIN
|
||||
#define SYS_LOG_DOMAIN "OS"
|
||||
#include "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);
|
||||
}
|
||||
|
||||
static void _os_init(void)
|
||||
{
|
||||
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);
|
||||
|
||||
extern void work_app_main(void *arg);
|
||||
static os_work_t _work_hdl_init;
|
||||
os_work_create(&_work_hdl_init, "work-main", work_app_main, NULL, 3);
|
||||
os_work_submit(default_os_work_q_hdl, &_work_hdl_init, 0);
|
||||
}
|
||||
|
||||
static void _init_prev_nvs(void)
|
||||
{
|
||||
esp_err_t err = nvs_flash_init();
|
||||
@@ -110,7 +40,6 @@ int app_main(void)
|
||||
_init_prev_nvs();
|
||||
|
||||
/* 初始化 os 抽象层 */
|
||||
_os_init();
|
||||
|
||||
return 0;
|
||||
extern void work_app_main(void *arg);
|
||||
return os_entry(work_app_main);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user