连续签到天数:1天 | 签到总天数:222天 | 签到总奖励:5096金币 |
|
发表于 2017-7-4 08:38:21
|
显示全部楼层
ATS2825没你们说的那么难懂,其实他的架构很清晰,看如下:
int main(int argc, const char *argv[])
{
app_result_e result = RESULT_NULL;
g_standby_exit_flag = (bool) ((argc & PARAM_S3_EXIT) != 0);
argc = argc & (~PARAM_S3_EXIT);
/*ap初始化*/
_app_init();
if (g_standby_exit_flag == TRUE)
{
sd_sec_param_t sd_sec_param;
sd_sec_param.file_offset = NOR_S3BT_APP_STATUS;
sd_sec_param.sram_addr = g_btplay_s3bt_param_buffer;
sd_sec_param.sec_num = 1;
base_ext_vram_read(&sd_sec_param);
g_btplay_enter_s3bt_status = g_btplay_s3bt_param_buffer[0];
g_btplay_enter_s3bt_a2dp_status = g_btplay_s3bt_param_buffer[1];
g_btplay_enter_s3bt_hfp_status = g_btplay_s3bt_param_buffer[2];
}
//创建主视图
g_last_btplay_status = g_btplay_cur_info.status = BTPLAY_IDLE;
btplay_create_main_view();
kill_conflict_console();
g_btplay_init_flag = TRUE;
//解除静音并设置音量模式
com_set_mute(FALSE);
com_reset_sound_volume(SET_VOLUME_SYNC_TO_REMOTE);
if ((g_ap_switch_var.call_background_status != CALL_BACK_STATUS_BACK)
&& (g_standby_exit_flag == FALSE))
{
com_tts_state_play(TTS_MODE_ONLYONE | TTS_MODE_NOBLOCK, TTS_ENTER_BTPLAY);
//创建蓝牙后台
com_btmanager_init(FALSE);
//等待TTS结束
if (com_tts_state_play_wait() == TTS_PLAY_RET_BY_KEY)
{
sys_os_time_dly(10); //等待100ms,以便短按抬起能够完成
}
}
while (1)
{
result = com_view_loop();
if (result == RESULT_NONE_EVENT)
{
result = RESULT_NULL;
break;
}
else if (result > RESULT_COMMON_RESERVE)
{
goto btplay_main_exit;
}
else
{
; //nothing
}
}
g_btplay_init_flag = FALSE;
#ifdef SUPPORT_BTT_TEST
if (g_app_info_state.stub_tools_type == STUB_PC_TOOL_BTT_MODE)
{
while (1)
{
if (g_bt_stack_cur_info.conn_status != CONN_STATUS_NONE)
{
enter_btt_test();
break;
}
sys_os_time_dly(1);
result = com_view_loop(); //更新 g_bt_stack_cur_info 状态
if (result > RESULT_COMMON_RESERVE)
{
goto btplay_main_exit;
}
}
}
#endif
keytone_set_dac_chan(DAF1_EN); //切换按键音通道必须确保中间件不存在
create_console();
result = get_message_loop();
#ifdef SUPPORT_ASET_TEST
if (g_app_info_state.stub_tools_type == STUB_PC_TOOL_ASET_EQ_MODE)
{
aset_test_exit();
}
#endif
kill_console();
keytone_set_dac_chan(DAF0_EN); //切换按键音通道必须确保中间件不存在
btplay_main_exit:
if (result == RESULT_SYSTEM_ENTER_S3)
{
sd_sec_param_t sd_sec_param;
libc_memset(SRAM_S3BT_BUFFER, 0x0, 0x200);
if (g_ap_switch_var.s3bt_nor_erase_flag == FALSE)
{
sd_sec_param.file_offset = NOR_S3BT_ERASE_WRITE;
sd_sec_param.sram_addr = g_btplay_s3bt_param_buffer;
sd_sec_param.sec_num = 1;
base_ext_vram_write(&sd_sec_param);
g_ap_switch_var.s3bt_nor_erase_flag = TRUE;
}
g_btplay_s3bt_param_buffer[0] = g_btplay_cur_info.status;
g_btplay_s3bt_param_buffer[1] = g_bt_stack_cur_info.rmt_dev[g_bt_stack_cur_info.a2dp_active_id].a2dp_status;
g_btplay_s3bt_param_buffer[2] = g_bt_stack_cur_info.rmt_dev[g_bt_stack_cur_info.hfp_active_id].hfp_status;
sd_sec_param.file_offset = NOR_S3BT_APP_STATUS;
sd_sec_param.sram_addr = g_btplay_s3bt_param_buffer;
sd_sec_param.sec_num = 1;
base_ext_vram_write(&sd_sec_param);
PRINT_INFO("ap enter s3bt");
}
//create new app
com_ap_switch_deal(result);
_app_exit();
return result;
}
|
|