/********************************************************************************************* * Filename : app_main.c * Description : * Author : Bingquan * Email : caibingquan@zh-jieli.com * Last modifiled : 2019-05-11 14:54 * Copyright:(c)JIELI 2011-2019 @ , All Rights Reserved. *********************************************************************************************/ #include "system/includes.h" #include "app_config.h" #include "app_action.h" #include "app_main.h" #include "update.h" #include "update_loader_download.h" #include "app_charge.h" #include "app_power_manage.h" #include "asm/charge.h" #if TCFG_KWS_VOICE_RECOGNITION_ENABLE #include "jl_kws/jl_kws_api.h" #endif /* #if TCFG_KWS_VOICE_RECOGNITION_ENABLE *// #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" /*任务列表 */ const struct task_info task_info_table[] = { {"app_core", 1, 0, 640, 128 }, {"sys_event", 7, 0, 256, 0 }, {"btctrler", 4, 0, 512, 256 }, {"btencry", 1, 0, 512, 128 }, {"btstack", 3, 0, 768, 256 }, {"systimer", 7, 0, 128, 0 }, {"update", 1, 0, 512, 0 }, #if CONFIG_APP_GAMEBOX {"gamebox", 3, 0, 1024, 128 }, #endif #if (RCSP_BTMATE_EN) {"rcsp_task", 2, 0, 640, 0 }, #endif #if TCFG_AUDIO_ENABLE {"audio_dec", 3, 0, 768, 128 }, {"audio_enc", 4, 0, 512, 128 }, {"aec", 2, 0, 768, 128 }, #endif/*TCFG_AUDIO_ENABLE*/ #if TCFG_KWS_VOICE_RECOGNITION_ENABLE {"kws", 2, 0, 256, 64 }, #endif /* #if TCFG_KWS_VOICE_RECOGNITION_ENABLE */ {0, 0}, }; APP_VAR app_var; void app_var_init(void) { app_var.play_poweron_tone = 1; app_var.auto_off_time = TCFG_AUTO_SHUT_DOWN_TIME; app_var.warning_tone_v = 340; app_var.poweroff_tone_v = 330; } __attribute__((weak)) u8 get_charge_online_flag(void) { return 0; } void clr_wdt(void); void check_power_on_key(void) { #if TCFG_POWER_ON_NEED_KEY u32 delay_10ms_cnt = 0; 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(); } } #endif } void app_main() { struct intent it; if (!UPDATE_SUPPORT_DEV_IS_NULL()) { int update = 0; update = update_result_deal(); } printf(">>>>>>>>>>>>>>>>>app_main...\n"); if (get_charge_online_flag()) { #if(TCFG_SYS_LVD_EN == 1) vbat_check_init(); #endif } else { check_power_on_voltage(); } #if TCFG_POWER_ON_NEED_KEY check_power_on_key(); #endif #if TCFG_AUDIO_ENABLE extern int audio_dec_init(); extern int audio_enc_init(); audio_dec_init(); audio_enc_init(); #endif/*TCFG_AUDIO_ENABLE*/ #if TCFG_KWS_VOICE_RECOGNITION_ENABLE jl_kws_main_user_demo(); #endif /* #if TCFG_KWS_VOICE_RECOGNITION_ENABLE */ init_intent(&it); #if(CONFIG_APP_KEYBOARD) it.name = "hid_key"; it.action = ACTION_HID_MAIN; #elif (CONFIG_APP_MOUSE_SINGLE) it.name = "mouse_single"; it.action = ACTION_MOUSE_MAIN; #elif (CONFIG_APP_MOUSE_DUAL) it.name = "mouse_dual"; it.action = ACTION_MOUSE_DUAL_MAIN; #elif(CONFIG_APP_KEYFOB) it.name = "keyfob"; it.action = ACTION_KEYFOB; #elif(CONFIG_APP_STANDARD_KEYBOARD) it.name = "standard_keyboard"; it.action = ACTION_STANDARD_KEYBOARD; #elif(CONFIG_APP_KEYPAGE) it.name = "keypage"; it.action = ACTION_KEYPAGE; #elif(CONFIG_APP_GAMEBOX) it.name = "gamebox"; it.action = ACTION_GAMEBOX; #elif(CONFIG_APP_REMOTE_CONTROL) it.name = "hid_vrc"; it.action = ACTION_REMOTE_CONTROL; #elif(CONFIG_APP_IDLE) it.name = "idle"; it.action = ACTION_IDLE_MAIN; #else while (1) { printf("no app!!!"); } #endif log_info("run app>>> %s", it.name); log_info("%s,%s", __DATE__, __TIME__); start_app(&it); #if TCFG_CHARGE_ENABLE set_charge_event_flag(1); #endif } /* * app模式切换 */ void app_switch(const char *name, int action) { struct intent it; struct application *app; log_info("app_exit\n"); init_intent(&it); app = get_current_app(); if (app) { /* * 退出当前app, 会执行state_machine()函数中APP_STA_STOP 和 APP_STA_DESTORY */ it.name = app->name; it.action = ACTION_BACK; start_app(&it); } /* * 切换到app (name)并执行action分支 */ it.name = name; it.action = action; start_app(&it); } int eSystemConfirmStopStatus(void) { /* 系统进入在未来时间里,无任务超时唤醒,可根据用户选择系统停止,或者系统定时唤醒(100ms) */ //1:Endless Sleep //0:100 ms wakeup /* log_info("100ms wakeup"); */ return 1; } __attribute__((used)) int *__errno() { static int err; return &err; }