?? mt88l89v2.~c
字號:
//NU_Sleep(50);
status = NU_Control_Timer(&DTMF_Dither_TimerCtrl, NU_ENABLE_TIMER);
TONE_TRACE("BSP --- MT88L89V2 check dial tone open !!!!!\n");
return 0;
}
/***************************************************
*
* DTMFCheckDialClose - stop check dial tone
*
* this routine call DTMFOpen to stop dial tone check
*
* RETURNS: int --- 0 OK
* -1 NOK
*
*/
int DTMFCheckDialClose(void)
{
int status;
status = NU_Control_Timer(&DTMF_Dither_TimerCtrl, NU_DISABLE_TIMER);
if (status != NU_SUCCESS)
{
return (-1);
}
g_IsCheckDialOpen = 0;
if (g_DtmfOpenStatus == 0/*1*/)
{
//g_DtmfOpenStatus = 1/*0*/;
DTMFOpen();
}
TONE_TRACE("BSP --- MT88L89V2 check dial tone close !!!!!\n");
return (0);
}
/***************************************************
*
* DTMFWrite - send DTMF data
*
* this function send DTMF data through write DTMF data Tx register
*
* RETURNS: int --- 0 OK
* <0 Error
*
*/
static unsigned int g_IsWriteNotify = 0;
int DTMFWrite
(
unsigned char _data, /* the data to write */
int notify /* is needed to notify application module */
/* notify = 0 --- no notify */
/* = 1 --- notify */
)
{
unsigned long * volatile pulPtr = (unsigned long *)HwBaseAddress;
if ((g_MastDataTxStatus != DTMF_TX_IDLE) || (g_MastDataTx != DTMF_TX_IDLE))
{
return DTMF_TX_BUSY;
}
if (CharToDTMF(_data) == 0xff)
{
return DTMF_DATA_ERROR;
}
if (g_DtmfOpenStatus == 0)
{
return DTMF_NOT_OPEN;
}
g_ChannelSave = ((unsigned char *)pulPtr)[HwPortB] & 0x18; /* to save bit3&bit4 of Port B*/
((unsigned char *)pulPtr)[HwPortB] |= 0x18; /* DTMF to line */
//NU_Sleep(1);
g_MastDataTx = _data;
g_MastDataTxStatus = DTMF_TX_WORK;
g_IsWriteNotify = notify;
return 0;
}
/***************************************************
*
* DTMF_Timer_Expiration - DTMF timer expiration routine
*
* this function is the DTMF timer expiration routine, this routine Tx or Rx
* DTMF data in poll module
*
* RETURNS: void
*
*/
void DTMF_Timer_Expiration
(
unsigned long id /* timer id */
)
{
int int_level = 0;
g_MastStatus = *(unsigned char *)DTMF_STATUS_BASE;
if (g_MastStatus & 0x04)/* rx ready */
{
g_pData = (unsigned char *)DTMF_RX_BASE;
g_MastDataRx = DTMFToChar((*g_pData&0x0F)); /* receive data */
//收到的數據,通知應用層....
/* debug information */
//TRACE("DTMF received:%c\n\n", g_MastDataRx);
TONE_TRACE("BSP --- MT88L89 receive DTMF:%c !!!!\n\n", g_MastDataRx);
DTMFSend(1, g_MastDataRx);
}
if ((g_MastDataTxStatus == DTMF_TX_WORK) && (g_MastDataTx != DTMF_TX_IDLE))
{
g_pData = (unsigned char *)DTMF_TX_BASE;
g_pCtrl = (unsigned char *)DTMF_CONTROL_BASE;
*g_pCtrl = 0x01; /* send data */
int_level = NU_Control_Interrupts(NU_DISABLE_INTERRUPTS);
*g_pData = CharToDTMF(g_MastDataTx); /* send first data */
g_MastDataTx = DTMF_TX_IDLE;
/* begin 2003-10-13, before send DTMF, close headphone */
_HeadPhone_close();
/* end */
NU_Control_Interrupts(int_level);
NU_Control_Timer(&DTMF_Mast_TimerCtrlTxTone, NU_ENABLE_TIMER);
//DTMFSend(0, 0);
TONE_TRACE("BSP --- MT88L89 sending data begin :%c !!!!\n", g_MastDataTx);
}
}
/***************************************************
*
*
* DTMF_TxTone_Timer_Expiration - DTMF Tx tone timer expiration routine
*
* this function is the DTMF Tx tone timer expiration routine
*
* RETURNS: void
*
*/
void DTMF_TxTone_Timer_Expiration
(
unsigned long id /* timer id */
)
{
g_pCtrl = (unsigned char *)DTMF_CONTROL_BASE;
*g_pCtrl = 0x00;
NU_Control_Timer(&DTMF_Mast_TimerCtrlTxTone, NU_DISABLE_TIMER);
NU_Control_Timer(&DTMF_Mast_TimerCtrlTxPause, NU_ENABLE_TIMER);
}
/***************************************************
*
*
* DTMF_TxPause_Timer_Expiration - DTMF Tx pause timer expiration routine
*
* this function is the DTMF Tx pause timer expiration routine
*
* RETURNS: void
*
*/
void DTMF_TxPause_Timer_Expiration
(
unsigned long id /* timer id */
)
{
int int_level;
unsigned long * volatile pulPtr = (unsigned long *)HwBaseAddress;
((unsigned char *)pulPtr)[HwPortB] &= ~0x18; /* clear bit3&bit4 of Port B */
((unsigned char *)pulPtr)[HwPortB] |= g_ChannelSave;/* resume bit3&bit4 of Port B */
NU_Control_Timer(&DTMF_Mast_TimerCtrlTxPause, NU_DISABLE_TIMER);
int_level = NU_Control_Interrupts(NU_DISABLE_INTERRUPTS);
/* reset status */
g_MastDataTxStatus = DTMF_TX_IDLE;
/* begin 2003-10-13, after DTMF send finish, open headphone */
_HeadPhone_open();
/* end */
NU_Control_Interrupts(int_level);
if (g_IsWriteNotify == 0x1)
{
DTMFSend(0, 0);
}
TONE_TRACE("BSP -- MT88L89 sending data end :%c !!!\n", g_MastDataTx);
}
void DTMF_Dither_Timer_Expiration
(
unsigned long id /* timer id */
)
{
char status;
int delay = 1200;
//while (delay-- > 0);/* delay for 120 ms */
status = ((*(unsigned char* )0x30000100) & 0x02) >> 1;
if (g_IsCheckDial == 0x1)
{
TONE_TRACE("BSP --- MT88L89 begin check dialtone !!!!!!!!!!!!!!!!!\n");
if (status == 0x1)
{
g_iDitherTimes++;
TONE_TRACE("BSP --- detect dialtone times = %d @@@\n", g_iDitherTimes);
if (g_iDitherTimes == 5)
{
g_iDitherTimes = 0;
DTMFSend(2, DTMF_DIAL);
status = NU_Control_Timer(&DTMF_Dither_TimerCtrl, NU_DISABLE_TIMER);
//status = NU_Control_Timer(&DTMF_Mast_TimerCtrl, NU_ENABLE_TIMER);
}
}
else
{
g_iDitherTimes = 0;
}
}
else
{
TONE_TRACE("BSP --- MT88L89 begin check dialtone off !!!!!!!!!!!!!!!!!\n");
if (status == 0x0)
{
g_iDitherTimes++;
TONE_TRACE("BSP --- detect dialtone off times = %d @@@\n", g_iDitherTimes);
if (g_iDitherTimes == 5)
{
g_iDitherTimes = 0;
DTMFSend(2, DTMF_DIAL_FINI);
status = NU_Control_Timer(&DTMF_Dither_TimerCtrl, NU_DISABLE_TIMER);
//status = NU_Control_Timer(&DTMF_Mast_TimerCtrl, NU_ENABLE_TIMER);
}
}
else
{
g_iDitherTimes = 0;
}
}
}
/***************************************************
*
*
* CharToDTMF - convert character to DTMF data
*
* this function convert character to DTMF data
*
* RETURNS: unsigned char --- converted DTMF data
*
*/
unsigned char CharToDTMF
(
unsigned char _ch /* character to convert */
)
{
unsigned char DTMFData;
switch (_ch)
{
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
DTMFData = _ch - '0';
break;
case '0':
DTMFData = 0x0A;
break;
case '*':
DTMFData = 0x0B;
break;
case '#':
DTMFData = 0x0C;
break;
case 'A':
case 'a':
DTMFData = 0x0D;
break;
case 'B':
case 'b':
DTMFData = 0x0E;
break;
case 'C':
case 'c':
DTMFData = 0x0F;
break;
case 'D':
case 'd':
DTMFData = 0x00;
break;
default: /* error */
DTMFData = 0xff;
break;
}
return DTMFData;
}
/***************************************************
*
*
* DTMFToChar - convert DTMF data to character
*
* this function convert DTMF data to character
*
* RETURNS: unsigned char --- converted character
*
*/
unsigned char DTMFToChar
(
unsigned char _DTMFData /* DTMF data to convert */
)
{
unsigned char ch;
switch (_DTMFData)
{
case 0x01:
case 0x02:
case 0x03:
case 0x04:
case 0x05:
case 0x06:
case 0x07:
case 0x08:
case 0x09:
ch = _DTMFData + '0';
break;
case 0x0A:
ch = '0';
break;
case 0x0B:
ch = '*';
break;
case 0x0C:
ch = '#';
break;
case 0x0D:
ch = 'A';
break;
case 0x0E:
ch = 'B';
break;
case 0x0F:
ch = 'C';
break;
case 0x0:
ch = 'D';
break;
default:
break;
}
return ch;
}
int GetHfcCodecStatus()
{
if ((g_MastDataTxStatus == DTMF_TX_IDLE) && (g_MastDataTx == DTMF_TX_IDLE))
{
return DTMF_WRITE_STATE_IDLE;
}
else
{
return DTMF_WRITE_STATE_BUZY;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -