重构项目配置并添加对 SBDEMO 的支持

更新多个 ESP32 芯片(C2、C3、S3)
的版本配置为 SBDEMO
产品添加新的配置文件实现板卡和应用程序配置模块添加 CRC 实用函数修改系统日志以支持动态日志控制更新 Kconfig 和 sdkconfig 的默认设置以适应新产品
This commit is contained in:
LokLiang
2025-02-21 10:30:22 +08:00
parent 73df531ac3
commit e9b5e42ef2
28 changed files with 1561 additions and 48 deletions

View File

@@ -7,9 +7,15 @@
/* 配置 */
#include "config/board_config.h"
#include "config/app_config.h"
/* SDK */
#include "esp_err.h"
#include "hal/spi_types.h"
/* 驱动 */
#include "drivers/ws2812_spi/ws2812_spi.h"
#include "drivers/ws2812_spi/ws2812_spi_shell.h"
/* 通用模块 */
#include "button/button.h"
@@ -22,7 +28,7 @@
#include "console.h"
#include "shell/sh_vset.h"
#define CONFIG_SYS_LOG_LEVEL SYS_LOG_LEVEL_DBG
#define CONFIG_SYS_LOG_LEVEL SYS_LOG_LEVEL_INF
#define SYS_LOG_DOMAIN "MAIN"
#include "sys_log.h"
@@ -30,6 +36,8 @@ nvs_handle g_nvs_hdl; // nvs 句柄
os_work_q_t g_work_q_hdl_low; // 低于 default_os_work_q_hdl 优先级的工作队列
static void _init_nvs(void);
static void _init_work_q(void);
static void _init_ws2812(void);
static void _change_mode_event_button(button_hdl_t *handle, press_event_t event);
static void _vset_cb(sh_t *sh_hdl);
@@ -38,14 +46,24 @@ void work_app_main(void *arg)
/* 初始化 SDK 的 nvs 模块 */
_init_nvs();
/* 初始化配置 */
board_cfg_init(); // 板级配置
app_cfg_init(); // 应用配置
/* 初始化其他优先级的工作队列 */
_init_work_q();
/* 初始化按键检测和控制 */
btn_attach(&g_cfg_board->key_boot, _change_mode_event_button, EVENT_PRESS_UP | EVENT_PRESS_DOWN | EVENT_LONG_PRESS_HOLD);
btn_attach(&g_cfg_board->key_reset, _change_mode_event_button, EVENT_PRESS_UP | EVENT_PRESS_DOWN | EVENT_LONG_PRESS_HOLD);
/* 初始化 ws2812 */
_init_ws2812();
ws2812_spi_shell_register(); // 用于测试 ws2812 的 shell 命令
/* 启动 shell */
SYS_LOG_INF("app start");
vset_init(&g_uart_handle_vt100, _vset_cb);
os_thread_sleep(100);
shell_start(NULL);
shell_start(_vset_cb);
SYS_LOG_DBG("app start");
}
static void _init_nvs(void)
@@ -57,6 +75,28 @@ static void _init_nvs(void)
}
}
static void _init_work_q(void)
{
/* 不使用以节省内存 */
// os_work_q_create(&g_work_q_hdl_low,
// "app-work_q-low",
// 0x2000,
// OS_PRIORITY_LOW);
}
static void _init_ws2812(void)
{
#if (CONFIG_LED_STRIP_MAX_LEDS)
ws2812_spi_led_strip_init(SPI2_HOST, CONFIG_LED_STRIP_MAX_LEDS);
#else
ws2812_spi_led_strip_init(SPI2_HOST, 10);
#endif
}
static void _vset_cb(sh_t *sh_hdl)
{
}
static void _change_mode_event_button(button_hdl_t *handle, press_event_t event)
{
static const char *const stat_tab[] = {
@@ -69,7 +109,3 @@ static void _change_mode_event_button(button_hdl_t *handle, press_event_t event)
SYS_LOG_DBG("button stat: %s", stat_tab[event]);
}
}
static void _vset_cb(sh_t *sh_hdl)
{
}