This commit is contained in:
lmx
2025-10-30 17:53:59 +08:00
parent a6919c7e43
commit 1d0eaa037b
174 changed files with 196655 additions and 223635 deletions

259
apps/xtell_hide/app_main.c Normal file
View File

@ -0,0 +1,259 @@
#include "system/includes.h"
/*#include "btcontroller_config.h"*/
#include "btstack/btstack_task.h"
#include "app_config.h"
#include "app_action.h"
#include "asm/pwm_led.h"
#include "tone_player.h"
#include "gpio.h"
#include "app_main.h"
#include "asm/charge.h"
#include "update.h"
#include "app_power_manage.h"
#include "app_charge.h"
#include "bt_profile_cfg.h"
#include "dev_manager/dev_manager.h"
#include "update_loader_download.h"
#define LOG_TAG_CONST APP
#define LOG_TAG "[APP]"
#define LOG_ERROR_ENABLE
#define LOG_DEBUG_ENABLE
#define LOG_INFO_ENABLE
/* #define LOG_DUMP_ENABLE */
#define LOG_CLI_ENABLE
#include "debug.h"
#ifdef CONFIG_BOARD_AISPEECH_VAD_ASR
u8 user_at_cmd_send_support = 1;
#endif
/*任务列表 */
const struct task_info task_info_table[] = {
{"app_core", 1, 0, 768, 256 },
{"sys_event", 7, 0, 256, 0 },
{"systimer", 7, 0, 128, 0 },
{"btctrler", 4, 0, 512, 384 },
{"btencry", 1, 0, 512, 128 },
{"tws", 5, 0, 512, 128 },
#if (BT_FOR_APP_EN)
{"btstack", 3, 0, 1024, 256 },
#else
{"btstack", 3, 0, 768, 256 },
#endif
{"audio_dec", 5, 0, 800, 128 },
{"aud_effect", 5, 1, 800, 128 },
/*
*为了防止dac buf太大通话一开始一直解码
*导致编码输入数据需要很大的缓存,这里提高编码的优先级
*/
{"audio_enc", 6, 0, 768, 128 },
{"aec", 2, 1, 768, 128 },
#if TCFG_AUDIO_HEARING_AID_ENABLE
{"HearingAid", 6, 0, 768, 128 },
#endif/*TCFG_AUDIO_HEARING_AID_ENABLE*/
#ifdef CONFIG_BOARD_AISPEECH_NR
{"aispeech_enc", 2, 1, 512, 128 },
#endif /*CONFIG_BOARD_AISPEECH_NR*/
#ifdef CONFIG_BOARD_AISPEECH_VAD_ASR
{"asr", 1, 0, 768, 128 },
{"audio_asr_export_task", 1, 0, 512, 128 },
#endif/*CONFIG_BOARD_AISPEECH_VAD_ASR*/
#ifndef CONFIG_256K_FLASH
{"aec_dbg", 3, 0, 128, 128 },
#if AUDIO_ENC_MPT_SELF_ENABLE
{"enc_mpt_self", 3, 0, 512, 128 },
#endif/*AUDIO_ENC_MPT_SELF_ENABLE*/
{"update", 1, 0, 256, 0 },
{"tws_ota", 2, 0, 256, 0 },
{"tws_ota_msg", 2, 0, 256, 128 },
{"dw_update", 2, 0, 256, 128 },
{"rcsp_task", 2, 0, 640, 128 },
{"aud_capture", 4, 0, 512, 256 },
{"data_export", 5, 0, 512, 256 },
{"anc", 3, 1, 512, 128 },
#endif
#if TCFG_GX8002_NPU_ENABLE
{"gx8002", 2, 0, 256, 64 },
#endif /* #if TCFG_GX8002_NPU_ENABLE */
#if TCFG_GX8002_ENC_ENABLE
{"gx8002_enc", 2, 0, 128, 64 },
#endif /* #if TCFG_GX8002_ENC_ENABLE */
#if TCFG_KWS_VOICE_RECOGNITION_ENABLE
{"kws", 2, 0, 256, 64 },
#endif /* #if TCFG_KWS_VOICE_RECOGNITION_ENABLE */
{"usb_msd", 1, 0, 512, 128 },
#if !TCFG_USB_MIC_CVP_ENABLE
{"usbmic_write", 2, 0, 256, 128 },
#endif
#if AI_APP_PROTOCOL
{"app_proto", 2, 0, 768, 64 },
#endif
#if (TCFG_SPI_LCD_ENABLE||TCFG_SIMPLE_LCD_ENABLE)
{"ui", 2, 0, 768, 256 },
#else
{"ui", 3, 0, 384 - 64, 128 },
#endif
#if (TCFG_DEV_MANAGER_ENABLE)
{"dev_mg", 3, 0, 512, 512 },
#endif
{"audio_vad", 1, 1, 512, 128 },
#if TCFG_KEY_TONE_EN
{"key_tone", 5, 0, 256, 32 },
#endif
#if (TCFG_WIRELESS_MIC_ENABLE)
{"wl_mic_enc", 2, 0, 768, 128 },
#endif
#if (TUYA_DEMO_EN)
{"user_deal", 7, 0, 512, 512 },//定义线程 tuya任务调度
{"dw_update", 2, 0, 256, 128 },
#endif
#if TCFG_AUDIO_SPATIAL_EFFECT_ENABLE
{"imu_trim", 1, 0, 256, 128 },
#endif /*TCFG_AUDIO_SPATIAL_EFFECT_ENABLE*/
#if TCFG_AUDIO_ANC_ACOUSTIC_DETECTOR_EN
{"speak_to_chat", 2, 0, 256, 128 },
{"icsd_adt", 2, 0, 512, 128 },
{"icsd_src", 2, 1, 512, 128 },
#endif /*TCFG_AUDIO_ANC_ACOUSTIC_DETECTOR_EN*/
{"pmu_task", 6, 0, 256, 128 },
{"WindDetect", 2, 0, 256, 128 },
{0, 0},
};
APP_VAR app_var;
/*
* 2ms timer中断回调函数
*/
void timer_2ms_handler()
{
}
void app_var_init(void)
{
memset((u8 *)&bt_user_priv_var, 0, sizeof(BT_USER_PRIV_VAR));
app_var.play_poweron_tone = 1;
}
void app_earphone_play_voice_file(const char *name);
void clr_wdt(void);
void check_power_on_key(void)
{
u32 delay_10ms_cnt = 0;
#if 0 //PC_MODE_DETECTION
gpio_set_pull_up(IO_PORTP_00, 0);
gpio_set_pull_down(IO_PORTP_00, 1);
gpio_set_direction(IO_PORTP_00, 1);
gpio_set_die(IO_PORTP_00, 1);
#endif
while (1) {
clr_wdt();
os_time_dly(1);
extern u8 get_power_on_status(void);
if (get_power_on_status()) {
log_info("+");
delay_10ms_cnt++;
if (delay_10ms_cnt > 70) {
/* extern void set_key_poweron_flag(u8 flag); */
/* set_key_poweron_flag(1); */
return;
}
} else {
log_info("-");
delay_10ms_cnt = 0;
log_info("enter softpoweroff\n");
power_set_soft_poweroff();
}
}
}
extern int cpu_reset_by_soft();
extern int audio_dec_init();
extern int audio_enc_init();
__attribute__((weak))
u8 get_charge_online_flag(void)
{
return 0;
}
/*充电拔出,CPU软件复位, 不检测按键,直接开机*/
static void app_poweron_check(int update)
{
#if (CONFIG_BT_MODE == BT_NORMAL)
if (!update && cpu_reset_by_soft()) {
app_var.play_poweron_tone = 0;
return;
}
#if TCFG_CHARGE_OFF_POWERON_NE
if (is_ldo5v_wakeup()) {
app_var.play_poweron_tone = 0;
return;
}
#endif
//#ifdef CONFIG_RELEASE_ENABLE
#if TCFG_POWER_ON_NEED_KEY
check_power_on_key();
#endif
//#endif
#endif
}
extern u32 timer_get_ms(void);
void app_main()
{
int update = 0;
u32 addr = 0, size = 0;
struct intent it;
if (!UPDATE_SUPPORT_DEV_IS_NULL()) {
update = update_result_deal();
}
app_var_init();
// if (get_charge_online_flag()) {
#if(TCFG_SYS_LVD_EN == 1)
vbat_check_init();
#endif
// init_intent(&it);
// it.name = "idle";
// it.action = ACTION_IDLE_MAIN;
// start_app(&it);
// } else {
check_power_on_voltage();
app_poweron_check(update);
init_intent(&it);
it.name = "handler";
it.action = ACTION_EARPHONE_MAIN;
start_app(&it);
// }
log_info("app_main\n");
app_var.start_time = timer_get_ms();
}