#include "includes.h" #include "nwy_keypad.h" bool usb_log_status=false; static void gpiosInit(void); static void spiFlashInit(void); static void lcdsInit(void); /////////////////////////pin33关闭其关机功能,然后配置成IO检测 static void _openkeypad(nwy_key_t key, nwy_keyState_t evt) { if(key==12){ backLightReset(); tryWakeupApp(); if(evt == key_state_press){ sutApp.pwrKeyStatus=0; }else{ sutApp.pwrKeyStatus=1; } } } static void pin33Init(void){ nwy_powerkey_poweroff_ctrl(0);//关闭PIN_33脚关机功能 reg_nwy_key_cb(_openkeypad); } ////////////////////////////////////////////////////////////////////// void boardInit(void){ pin33Init(); logPortInit();//实际工程时按需打开 gpiosInit(); lcdsInit(); } //////////////////////封装一下AT接口///////////////////////////////// void msgAtSend(char *at){ ohpoc_msg_send(at, strlen(at)); } void msgAtSends(char *at ,int len){ ohpoc_msg_send(at, len); } //////////////////////封装AT接口结束///////////////////////////////// //////////////////////日志串口配置开?//////////////////////////////// void logDataCb(const char *data,uint32 length){ usbCmdHandler(data,length); } bool logPortInit(void){ bool ret; ret=nwy_usb_serial_reg_recv_cb(logDataCb); if(false==ret) OSI_LOGI(0,"nwy_usb_serial_reg_recv_cb failed"); else{ usb_log_status=true; MSG_INFO(1,"logPortInit ok"); } return ret; } //////////////////////日志打印结束/////////////////////////////// ///////////////////////GPIOS初始?///////////////////////////// unsigned short keyStatus=0;//保存键值状? unsigned char hpStatus=0; const unsigned char keyTable[KS_KEY_MAX]={ G_KEY_MIC_PTT }; const unsigned char mKeyTable[MKS_KEY_INS]={ G_KEY_IN1, G_KEY_IN2, G_KEY_IN3 }; static void startKeyTimer(void); static void gpioIsqActive(int param){ unsigned short i; tryWakeupApp();//有按键动作,唤醒 startKeyTimer(); //检测普通按?将值设置进keyStatus即可,去抖动等操作在定时器中完成 for(i=0;i 10) vol=10; //return vol/2; return vol; } void pttBeepStart(bool isMicReq){ if(true==isMicReq) pwmBeepStart(500, 50); else pwmBeepStart(500, 50); } void beepStart(int freq){ //const unsigned char duty[5]={100,99,98,97,96}; int index=getDutyBySpk(); if(index==0) return;//最小声时直接不需要播放了 pwmBeepStart(freq, index);//占空比80 } void beepStop(void){ nwy_pwm_stop(pwm_p); MSG_INFO(1, "beep stop"); } static void pwmTimerCb(void *param){//beep 结束操作 beepStop(); sutPocStatus.beep=0; } #else void beepStart(int freq){} #endif ///////////////////////PWM控制结束//////////////////////////////// //////////////////////修改EQ增益配置值/////////////////////////////// void modifyEqData(void){ const char *handFreeEq="AT+CAVQE=0,1,12,\"01000700c800070002000000800c07000300f4ffa4060f000300fbff9001070000000000e803070000000000d007070000000000a60e070001000000\"\r\n"; msgAtSend(handFreeEq); } //////////////////////修改输出增益配置/////////////////////////////// void modifyAudioOutGainConfig(void){ char cmd[20]="AT+CACCP=0,1,2,\""; unsigned char alg1=211,alg2=0xff; unsigned char dac=125;//default=46 int i; msgAtSend(cmd); for(i=0;i<16;i++){ if(i==15){ alg1=0; alg2=0; } snprintf(cmd, sizeof(cmd), "0000%02x00%02x%02x0000", dac,alg1,alg2); msgAtSend(cmd); alg1 += 3; } msgAtSend("\"\r\n"); }