136 lines
3.2 KiB
C
136 lines
3.2 KiB
C
|
/*********************************************************************************************
|
||
|
* 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 "asm/charge.h"
|
||
|
#if TCFG_AUDIO_ENABLE
|
||
|
/* #include "audio_encode.h" */
|
||
|
/* #include "audio_decode.h" */
|
||
|
#endif/*TCFG_AUDIO_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, 1024, 768},
|
||
|
{"systimer", 7, 0, 128, 0 },
|
||
|
{"update", 1, 0, 512, 0 },
|
||
|
{"dw_update", 2, 0, 256, 128 },
|
||
|
#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 },
|
||
|
#endif/*TCFG_AUDIO_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;
|
||
|
}
|
||
|
|
||
|
void app_main()
|
||
|
{
|
||
|
struct intent it;
|
||
|
|
||
|
if (!UPDATE_SUPPORT_DEV_IS_NULL()) {
|
||
|
int update = 0;
|
||
|
update = update_result_deal();
|
||
|
}
|
||
|
|
||
|
#if TCFG_AUDIO_ENABLE
|
||
|
extern int audio_dec_init();
|
||
|
extern int audio_enc_init();
|
||
|
audio_dec_init();
|
||
|
audio_enc_init();
|
||
|
#endif/*TCFG_AUDIO_ENABLE*/
|
||
|
|
||
|
init_intent(&it);
|
||
|
|
||
|
it.name = "mesh";
|
||
|
it.action = ACTION_AT_MAIN;
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
|