123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
- * All rights reserved.
- *
- * This software is supplied "AS IS" without any warranties.
- * RDA assumes no responsibility or liability for the use of the software,
- * conveys no license or title under any patent, copyright, or mask work
- * right to the product. RDA reserves the right to make changes in the
- * software without notification. RDA also make no representation or
- * warranty that such application will be suitable for the specified use
- * without further testing or modification.
- */
- //#define OSI_LOG_TAG OSI_MAKE_LOG_TAG()
- #include "includes.h"
- /*
- appimg_exit
- 仅在程序退出时打印
- */
- void appimg_exit(void){
- LSAPI_Log_Debug("application image exit");
- }
- LSAPI_OSI_Thread_t * ToneThreadPtr=NULL;
-
- #define HANDSET_THREAD_STACK 4*1024
- void ToneThread(void *param){
- LSAPI_OSI_Event_t waitevent;
-
- for(;;){
- LSAPI_OSI_EventWait(LSAPI_OSI_ThreadCurrent(), &waitevent);
- if(sutPocStatus.beep==1){
- MSG_INFO(1, "TONE satrt");
- if(sutPocStatus.spk==0){
- LSAPI_AUD_CusToneV2(TONEFRE,TONEFRE,100,LSAPI_CUSTONE_GAIN_NEGA_24,0);//24
- LSAPI_AUD_SetPlayVolumeLevel(newPara.spkVol*6);//10
- }
- sutPocStatus.beep=0;
- }
- }
- }
- void ToneInit(void){
- ToneThreadPtr=LSAPI_OSI_ThreadCreate("tonedet", ToneThread, NULL, LSAPI_OSI_PRIORITY_NORMAL, HANDSET_THREAD_STACK, 4);
- if(ToneThreadPtr==NULL)MSG_INFO(1,"tone thread failed");
- }
- static void StartSubPTH(void)
- {
-
- if(NULL==LSAPI_OSI_ThreadCreate("sub", subTask, NULL, LSAPI_OSI_PRIORITY_NORMAL, SUB_TASK_THREAD_STACK, 10)){
- for(;;){
- LSAPI_Log_Debug("sub task failed");
- LSAPI_OSI_ThreadSleep(1000);
- }
- }
- }
- #define HANDSET_THREAD_STACK 4*1024
- void handsetStatusOutput(unsigned char status){
- char info[30];
- // return;
- snprintf(info,sizeof(info),"+HEADSET:%d\r\n",status);
- MSG_INFO(0,"%s",info);
-
- //outterInfo(info, strlen(info));
- switch(status){
- case 0://HEADSET CONNECT
- sutApp.earLev=1;
- msgAtSend("AT+AUDCH=1,3\r\n");
-
-
- sutApp.pcant=2;
- break;//HEADSET DISCONNECTED
-
- case 1:
- sutApp.earLev=0;
- msgAtSend("AT+AUDCH=0,0\r\n");
-
- sutApp.pcant=4;
- break;//HEADSET BTN PRESS
- case 2:
- micPttHandler(1);
- break;//HEADSET BTN RELEASED
- case 3:
- micPttHandler(0);
- break;
- }
- }
- void prvHeadSetDetectCallback(void *ctx, LSAPI_HeadSetDetectId_t id, uint32_t param)
- {
- MSG_INFO(1,"prvHeadSetDetectCallback_t(id:%d,param:%d)",id, param);
- switch(id){
- case LSAPI_HEADSET_PLUGIN:
- MSG_INFO(1,"--->>headset plugin");
- handsetStatusOutput(0);
- break;
- case LSAPI_HEADSET_PLUGOUT:
- MSG_INFO(1,"--->>headset plugout");
- handsetStatusOutput(1);
- break;
- case LSAPI_HEADSET_BTN_DOWN:
- MSG_INFO(1,"--->>headset btn_dwon(volt:%dmV)",param);
- handsetStatusOutput(2);
- break;
- case LSAPI_HEADSET_BTN_UP:
- MSG_INFO(1,"--->>headset btn_up(volt:%dmV)",param);
- handsetStatusOutput(3);
- break;
- default:
- break;
- }
- }
- void handSetThread(void *param){
- LSAPI_OSI_Event_t waitevent;
- LSAPI_HeadSetStatus_t status;
- static unsigned char FristHeadDet=0;
-
- MSG_INFO(1,"handSetThread start");
- switch (FristHeadDet)
- {
- case 0:
- status= LSAPI_Device_HeadSetGetStatus();//0628
-
- if(status == LSAPI_HEADSET_DISCONNECT)
- {
- MSG_INFO(1,"headset_disconnect");
- handsetStatusOutput(1);
- }
- else if(status == LSAPI_HEADSET_CONNECT)
- {
- MSG_INFO(1," headset_connect");
- handsetStatusOutput(0);
- }
- else
- {
- MSG_INFO(1,"unknow state");
- }
-
- FristHeadDet=1;
- break;
- }
-
- if(LSAPI_Device_HeadSetSetDetectCB(prvHeadSetDetectCallback)) MSG_INFO(1,"Handset cb ok");
- else MSG_INFO(1,"Handset cb failed!!!");
- for(;;){
- LSAPI_OSI_EventWait(LSAPI_OSI_ThreadCurrent(), &waitevent);
- }
- }
- void handSetInit(void){
- if(NULL==LSAPI_OSI_ThreadCreate("handset", handSetThread, NULL, LSAPI_OSI_PRIORITY_NORMAL, HANDSET_THREAD_STACK, 4)) MSG_INFO(1,"handset thread failed");
- }
- static void mainTask(void *param){
- #if 1
- handSetInit();
- ToneInit();
- dataInit();
- boardInit();
- StartSubPTH();//线程会调用外设接口,必须在boardInit后启势
- appRun();//应用主程庿pt)
- #else
- //LSAPI_OSI_ThreadSleep(10000);
- //StartSubPTH();
- //subTimerCtl(1);
- newPara.newold_plam=1;
- open_bnd_app();
- while(1){
- LSAPI_OSI_ThreadSleep(5000);
- }
- #endif
-
- }
- /*
- appimg_enter
- cat one入口函数
- */
- LSAPI_OSI_Thread_t * mainThreadPtr=NULL;
- int appimg_enter(void *param){
- if(NULL==(mainThreadPtr=LSAPI_OSI_ThreadCreate("main", mainTask, NULL, LSAPI_OSI_PRIORITY_BELOW_NORMAL, PT_THREAD_STACK, 5))){
- for(;;){
- LSAPI_Log_Debug("main task failed");
- LSAPI_OSI_ThreadSleep(1000);
- }
- }
- return 0;
- }
|