⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ring_chk.c

📁 基于KEIL C的RTXTiny操作系统的电话振铃检测程序。单片机为LPC900系列。 本程序并不能直接使用
💻 C
字号:

#include <reg931.h>                    /* special function registers 8052      */
#include <rtx51tny.h>                 /* RTX-51 tiny functions & defines      */
#include <stdio.h>                    /* standard I/O .h-file                 */
#include <ctype.h>                    /* character functions                  */
#include <string.h>                   /* string and memory functions          */
#include <absacc.h>
#include <intrins.h>


EXT_MODBUS uchar idata RingCnt;    //振铃计数器
EXT_MODBUS uint idata RingCnt_TimeOut; //振铃超时计数器
EXT_MODBUS uchar idata RING_CNT;
EXT_MODBUS uchar idata RcvMode;
EXT_MODBUS uint idata RingCnt_Tmp;
/*
************************************************************************************************
* Name       : void RingChkTask (void) _task_ RING_CHK_TASK  
* Describe   : 振铃检测
* Input      : 
* Output     : 
* Create by  : xy-mcu@163.com              Date:2003年04月08日 星期二  20:47:28
* Moid   by  :                     Date:
************************************************************************************************
*/

void RingChkTask (void) _task_ RING_CHK_TASK
{
    uchar i;
    RingCnt =0;
    while(1)
    {
        RingChk_ini();//开始振铃检测,
        os_clear_signal(RING_CHK_TASK);
        
        //os_wait(K_SIG,0,0);//等待外部中断的信号。
        if(SIG_EVENT == os_wait(K_SIG+K_TMO,250,0))//等待2.5秒。
        {
            os_wait(K_TMO,OS_TICKS_PER_SEC,0);//等待1秒。
            i=RingCnt_Tmp;
            if(i>10)RingCnt++;
        
            if(RingCnt== RING_CNT)
            {
                EX1 = 0;//关闭振铃检测。
                os_send_signal(INIT);//检测到,发送信号给处理程序。
                RingCnt =0;
                //os_wait(K_TMO,OS_TICKS_PER_SEC*3,0);//等待3秒。
                os_wait(K_SIG,0,0);//等待信号,(从振铃处理程序回来的。通常是本次电话打入处理完成后,发送该信号。)
                //重新开始。
            }
            else
            {
                os_wait(K_TMO,OS_TICKS_PER_SEC*2,0);//等待2秒。
                os_wait(K_TMO,OS_TICKS_PER_SEC*1,0);//等待2秒。
            }
        }
        else
        {
            RingCnt =0;//没有收到下一个振铃信号。超时处理。
        }
    }
}
/*
************************************************************************************************
* Name       : 
* Describe   : 振铃检测中断,
* Input      : 
* Output     : 
* Create by  : xuyong              Date:2005年01月31日 星期一  22:52:38
* Moid   by  :                     Date:
************************************************************************************************
*/
void Ring_Chk_INT(void) interrupt 2 using 3
{
    if(RingCnt_Tmp ==0)
    {
        isr_send_signal(RING_CHK_TASK);
    }
    RingCnt_Tmp ++;
}

void RingChk_ini(void)  //外部中断1初始化,下降沿中断。
{
    TCON|=4;
    EX1 =1;
    RingCnt_Tmp=0;
}
/*
************************************************************************************************
* Name       : 
* Describe   : 
* Input      : 
* Output     : 
* Create by  : xuyong              Date:2005年02月06日 星期日  00:29:21
* Moid   by  :                     Date:
************************************************************************************************
*
void RingChk_Off(void)
{
    EX1 = 0 ;
}
/*
************************************************************************************************
* Name       : 
* Describe   : 
* Input      : 
* Output     : 
* Create by  : xuyong              Date:2005年01月31日 星期一  22:49:24
* Moid   by  :                     Date:
************************************************************************************************
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -