hpocapp.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. //#define OSI_LOG_TAG OSI_MAKE_LOG_TAG()
  13. #include "includes.h"
  14. /*
  15. appimg_exit
  16. 仅在程序退出时打印
  17. */
  18. void appimg_exit(void){
  19. LSAPI_Log_Debug("application image exit");
  20. }
  21. //POC 回调输出信息
  22. void virtual_uart_read(char *data, int len){
  23. pocCmdHandler(data, len);
  24. }
  25. LSAPI_OSI_Thread_t * ToneThreadPtr=NULL;
  26. #define HANDSET_THREAD_STACK 4*1024
  27. void ToneThread(void *param){
  28. LSAPI_OSI_Event_t waitevent;
  29. for(;;){
  30. LSAPI_OSI_EventWait(LSAPI_OSI_ThreadCurrent(), &waitevent);
  31. if(sutPocStatus.beep!=0){
  32. if(sutPocStatus.spk==0||sutPocStatus.beep==2){//100
  33. if(!sutPocStatus.PttFail)LSAPI_AUD_CusToneV2(TONEFRE,TONEFRE,100,LSAPI_CUSTONE_GAIN_NEGA_24,0);//24
  34. else LSAPI_AUD_CusToneV2(1000,1000,100,LSAPI_CUSTONE_GAIN_NEGA_24,0);//24
  35. LSAPI_AUD_SetPlayVolumeLevel(newPara.spkVol*7);//10
  36. if(sutPocStatus.prePtt){
  37. msgAtSend("AT+POC=reqspk00");
  38. //sutPocStatus.prePtt=0;
  39. }
  40. MSG_INFO(1, "TONE satrt");
  41. }
  42. }
  43. sutPocStatus.beep=0;
  44. sutPocStatus.PttFail=0;
  45. sutPocStatus.prePtt=0;
  46. }
  47. }
  48. void ToneInit(void){
  49. ToneThreadPtr=LSAPI_OSI_ThreadCreate("tonedet", ToneThread, NULL, LSAPI_OSI_PRIORITY_NORMAL, HANDSET_THREAD_STACK, 4);
  50. if(ToneThreadPtr==NULL)MSG_INFO(1,"tone thread failed");
  51. }
  52. void startSubTask(void);
  53. static void mainTask(void *param){
  54. LSAPI_OSI_ThreadSleep(10000);
  55. ToneInit();
  56. dataInit();
  57. boardInit();
  58. startSubTask();//线程会调用外设接口,必须在boardInit后启动
  59. LSAPI_GWSD_Register_Callback(virtual_uart_read);
  60. appRun();//应用主程序(pt)
  61. }
  62. /*
  63. appimg_enter
  64. cat one入口函数
  65. */
  66. LSAPI_OSI_Thread_t * mainThreadPtr=NULL;
  67. int appimg_enter(void *param){
  68. if(NULL==(mainThreadPtr=LSAPI_OSI_ThreadCreate("main", mainTask, NULL, LSAPI_OSI_PRIORITY_NORMAL, PT_THREAD_STACK, 5))){
  69. for(;;){
  70. LSAPI_Log_Debug("main task failed");
  71. LSAPI_OSI_ThreadSleep(1000);
  72. }
  73. }
  74. return 0;
  75. }
  76. void startSubTask(void){
  77. if(NULL==LSAPI_OSI_ThreadCreate("sub", subTask, NULL, LSAPI_OSI_PRIORITY_NORMAL, SUB_TASK_THREAD_STACK, 10)){
  78. MSG_ERR(1, "sub task failed");
  79. }else MSG_ERR(1, "sub task ok");
  80. }