📄 tsktone.c
字号:
#include <p18cxxx.h>
#include "includes.h"
#include "funccommon.h"
#include "hardware.h"
#include "event.h"
extern OS_MEM *pMemSml;
extern OS_MEM *pMemLge;
#pragma romdata CCODE
INT16U rom bas[] = {
0,
131,147,165,175,196,220,247,
262,294,330,349,392,440,492,
523,579,651,695,781,868,977
};
INT8U rom mus1[][2] = {
{1,2},
{2,2},
{3,2},
{3,2},
{2,2},
{1,2},
{1,2},
{3,2},
{2,2},
{1,2},
{2,2},
{1,2},
{2,2},
{3,2},
{3,2},
{2,2},
{1,2},
{1,2},
{3,2},
{2,2},
{2,2},
{2,2},
{1,4},
{0,4}
};
void tskTone(void * data){
void rom * pMsg, *pSml;
INT8U err,i;
for(;;){
pMsg = OSQPend(peventTone, 0, &err);
if(err == OS_NO_ERR){
if((INT24U)pMsg >= PTR_MAX){
switch ((INT24U)pMsg){
case MSG_TONE_BUSY:
i = 1;
OSQPost(peventWICCmd, (OS_EVENT *) MSG_TONE450_ON);
for(;;){
pMsg = OSQPend(peventTone, 60, &err);
if(err == OS_TIMEOUT){
if(i== 0) {
OSQPost(peventWICCmd, (OS_EVENT *) MSG_TONE450_ON);
i = 1;
}
else{
OSQPost(peventWICCmd, (OS_EVENT *) MSG_TONE450_OFF);
i = 0;
}
}
else if (err == OS_NO_ERR){
if(((INT24U)pMsg) == MSG_TONE_STOP){
OSQPost(peventWICCmd, (OS_EVENT *) MSG_TONE450_OFF);
break;
}
if(((INT24U)pMsg)< PTR_MAX){
Func_Clear_Msg(pMsg);
}
}
}
break;
case MSG_SM_NEW:
Func_SetVoiceCh(VOX_HANDFREE);
OSTimeDly(300); //wait for 3s
OSQPost(peventWICCmd, (OS_EVENT *)MSG_RING_STOP);
Func_SetVoiceCh(VOX_HANDSET);
break;
case MSG_PLAY_MUS:
Func_SetVoiceCh(VOX_HANDFREE);
for(i = 0; i<(sizeof(mus1)/2); i++){
if(mus1[i][0] == 0) OSQPost(peventWICCmd, (OS_EVENT *) MSG_TONE450_OFF);
else{
pSml = OSMemGet(pMemSml, &err);
if(err == OS_NO_ERR){
err = mus1[i][0];
((MSG_HEAD *)pSml)->Msg_ID = MSG_TONE_PLAY;
((MSG_HEAD *)pSml)->pmemME = pMemSml;
((MSG_HEAD *)pSml)->Attached = FALSE;
((MSG_TONEPLAY *)pSml)->Num[0] = bas[err]/100+0x30;
((MSG_TONEPLAY *)pSml)->Num[1] = (bas[err]%100)/10+0x30;
((MSG_TONEPLAY *)pSml)->Num[2] = bas[err]%10+0x30;
OSQPost(peventWICCmd, (OS_EVENT *)pSml);
}
}
OSTimeDly(mus1[i][1]*20);
}
break;
}
}
else{
Func_Clear_Msg(pMsg);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -