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

📄 clid.cpp

📁 This R2.9 revision of the CLID detector provides the TYPE 1 (on-hook, between first and second ring,
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#if !defined (_dsp)
            clid_compare(pDb->sBytes, uByte);
#endif
            pDb->sCheckSum = uByte;
            _store_byte(pDb, pSc, uByte);
            pDb->sState = CLID_ST_DATA;
            sReport = ICLID_EV_START;
        }
        else ; // keep looking....
        break;
    case CLID_ST_DATA:
        uByte = _find_byte(pDb, pSc);
        if (!(uByte & 0xff00))
        {
#if !defined (_dsp)
            clid_compare(pDb->sBytes, uByte);
#endif
            pDb->sCheckSum += uByte;
            if (pDb->sBytes == 1)
            {
                pDb->sLen = uByte;
            }

            if (pDb->sBytes >= pDb->sLen+2)
            {
                /* check sum byte */
                if ((pDb->sCheckSum & 0x00ff) == 0x00)
                {
                    pDb->sState = CLID_ST_DONE;
                    sReport = ICLID_EV_END;
                }
                else
                {
//                    _reset(pDb);
                    sReport = ICLID_EV_ABORT;
                }
            }
            _store_byte(pDb, pSc, uByte);
        }
        else ; // go on...
        {
            // marks between bytes are too long...
            if (pDb->sCurrBitLen > 100)
            {
                 sReport = ICLID_EV_ABORT;
//              _reset(pDb);
            }
        }
        break;
    case CLID_ST_DONE:
        /* do nothing till clid msg is retrieved and clid is reset */
        break;
    default:
        break;
    }

    switch (sReport & 0xff00)
    {
    case ICLID_EV_START:
        pDb->Stts.sStart++;
        break;
    case ICLID_EV_END:
        pDb->Stts.sEnd++;
        break;
    case ICLID_EV_ABORT:
        pDb->Stts.sAbort++;
        break;
    }

    return sReport;
}

/*-------------------------------------------------------------------------*/
S16                         _state_machine_type2
/*-------------------------------------------------------------------------*/
(
CLID_tDb *pDb,
CLID_tSc *pSc
)
{
    U16 uByte;
    S16 sReport = ICLID_EV_NONE;

    switch(pDb->sState)
    {
    case CLID_ST_IDLE:
        _wait_marks(pDb, pSc);
        if (pDb->sCurrBitLen > 100) // 20 bits
        {
            pDb->sState = CLID_ST_MARKS;
            sReport = ICLID_EV_EARLY_ON;
        }
        else ; 
        break;

    case CLID_ST_MARKS:
        uByte = _find_byte(pDb, pSc);
        if ((uByte & 0xff) != 0xff) // ParameterType can not be 0xff
        {
#if !defined (_dsp)
            clid_compare(pDb->sBytes, uByte);
#endif
            pDb->sCheckSum = uByte;
            _store_byte(pDb, pSc, uByte);
            pDb->sState = CLID_ST_DATA;
            sReport = ICLID_EV_START;
        }
        else;  // keep looking....
        break;
    case CLID_ST_DATA:
        uByte = _find_byte(pDb, pSc);
        if (!(uByte & 0xff00))
        {
#if !defined (_dsp)
            clid_compare(pDb->sBytes, uByte);
#endif
            pDb->sCheckSum += uByte;
            if (pDb->sBytes == 1)
            {
                pDb->sLen = uByte;
            }

            if (pDb->sBytes >= pDb->sLen+2)
            {
                /* check sum byte */
                if ((pDb->sCheckSum & 0x00ff) == 0x00)
                {
                    pDb->sState = CLID_ST_DONE;
                    sReport = ICLID_EV_END;
                }
                else
                {
//                    _reset(pDb);
                    sReport = ICLID_EV_ABORT;
                }
            }
            _store_byte(pDb, pSc, uByte);
        }
        else ; // go on...
        {
            // marks between bytes are too long...
            if (pDb->sCurrBitLen > 100)
            {
                 sReport = ICLID_EV_ABORT;
//              _reset(pDb);
            }
        }
        break;
    case CLID_ST_DONE:
        /* do nothing till clid msg is retrieved and clid is reset */
        break;
    default:
        break;
    }

    switch (sReport & 0xff00)
    {
    case ICLID_EV_START:
        pDb->Stts.sStart++;
        break;
    case ICLID_EV_END:
        pDb->Stts.sEnd++;
        break;
    case ICLID_EV_ABORT:
        pDb->Stts.sAbort++;
        break;
    }

    return sReport;
}
/*-------------------------------------------------------------------------*/
S16                         _state_machine_cas
/*-------------------------------------------------------------------------*/
(
CLID_tDb *pDb,
CLID_tSc *pSc
)
{
    S16 sReport = ICLID_EV_NONE;

    switch(pDb->sState)
    {
    case CLID_ST_IDLE:
        // min 3 good frames in a row
        if (((pDb->uCasReg & 0x007f) == 0x000e) ||
            ((pDb->uCasReg & 0x00ff) == 0x001e) ||
            ((pDb->uCasReg & 0x01ff) == 0x003e) ||
            ((pDb->uCasReg & 0x03ff) == 0x007e))
        {
            sReport = ICLID_EV_CAS;
            pDb->sState = CLID_ST_DONE;
            pDb->Stts.sCas++;
        }
        else; // go on
        break;
    case CLID_ST_DONE:
        break;
    }

    return sReport;
}
        
/*--------------------- public  functions ---------------------------------*/

/*---------------------------------------------------------------------*/
void                        CLID_MIKET_init_db
/*---------------------------------------------------------------------*/
(
void *p2db,
ICLID_tCfg *pCfg
)
{
    CLID_tDb *pDb = (CLID_tDb *)p2db;
    memset(pDb,0,sizeof(CLID_tDb));
    pDb->Cfg = *pCfg;
}

/*---------------------------------------------------------------------*/
void                        CLID_MIKET_control
/*---------------------------------------------------------------------*/
(
void *p2db,
Int sCmd,
ICLID_Status *pStatus
)
{
    CLID_tDb *pDb = (CLID_tDb *)p2db;

    if (sCmd & ICLID_CMD_RESET) 
    {
        _reset(pDb);
    }
  
    if (sCmd & ICLID_CMD_RESET_STTS) 
    {
        memset(&pDb->Stts,0, sizeof(CLID_MIKET_tStts));
    }

    if (sCmd & ICLID_CMD_CFG)
    {
    	pDb->Cfg = pStatus->Cfg;
    }

    if (sCmd & ICLID_CMD_TYPE1)
    {
    	pDb->sIsOn = 1;
    }
    
    if (sCmd & ICLID_CMD_TYPE2)
    {
    	pDb->sIsOn = 2;
    }

    if (sCmd & ICLID_CMD_CAS)
    {
    	pDb->sIsOn = 3;
    }

    if (sCmd & ICLID_CMD_OFF)
    {
    	pDb->sIsOn = 0;
    }

    pStatus->size = sizeof(ICLID_Status);
}

/*-------------------------------------------------------------------------*/
S16                         CLID_MIKET_process
/*-------------------------------------------------------------------------*/
(
void *p2db,
void *p2sc,
S16 *psIn
)
{
    CLID_tDb *pDb = (CLID_tDb *)p2db;
    CLID_tSc *pSc = (CLID_tSc *)p2sc;

    S16 sReport = ICLID_EV_NONE;

    if (pDb->sIsOn != 0)
    {
        memset(pSc, 0, sizeof(CLID_tSc));


        if (pDb->sIsOn == CLID_MODE_CAS)
        {
		    clid_cas_bp_filter          (pDb, pSc, psIn);
            pDb->sCasIdx++;
            if (pDb->sCasIdx >= CLID_CAS_IDX)
            {
                pDb->sCasIdx = 0;
                clid_cas_move_data_in   (pDb, pSc);
                clid_cas_freqdet_flt    (pDb, pSc);
                clid_cas_freqdet        (pDb, pSc);
                clid_cas_test           (pDb, pSc);
                sReport = 
                    _state_machine_cas  (pDb, pSc);
                clid_cas_move_data_out  (pDb, pSc);
            }
        }
        else
        {
            clid_move_data_in           (pDb, pSc, psIn);
    		clid_bp_filter              (pDb, pSc);
            clid_convert_baseband       (pDb, pSc);
            clid_resample_6k            (pDb, pSc);
            clid_matched_filter         (pDb, pSc);

            if (pDb->sIsOn == CLID_MODE_TYPE1)
            {
                sReport = 
                    _state_machine_type1(pDb, pSc);
            }
            else
            {
                sReport = 
                    _state_machine_type2(pDb, pSc);
            }
    	    clid_move_data_out          (pDb, pSc);
        }
    }
    return sReport;
}

/*-------------------------------------------------------------------------*/
void                        CLID_MIKET_get_stats
/*-------------------------------------------------------------------------*/
(
void *p2db,
CLID_MIKET_tStts *pStts
)
{
    *pStts = ((CLID_tDb *)p2db)->Stts;
}


⌨️ 快捷键说明

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