📄 dcf_drv.c
字号:
/* */
/* DESCRIPTION: The function stops the integrated BER tester */
/* by programming the BERT_ON bit of BERT_0 register. */
/* */
/* RETURNS: True if successful, False if unsuccessful. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
bool DCF_DRIVER_Init_Bert(DCF_NIM *pNim)
{
unsigned char u8RegData;
bool bRetVal;
/* sanity check */
if(pNim == NULL)
{
return (False);
}
/* 0xA0[7] = 0, 0xA0[3] = 0 */
gDemReg[ST0_RID_BERT_0].value = gDemReg[ST0_RID_BERT_0].value & 0x77;
u8RegData = gDemReg[ST0_RID_BERT_0].value;
bRetVal = DCF_RegWrite(pNim, gDemReg[ST0_RID_BERT_0].addr, 1, &u8RegData, DCF_DEMOD_I2C);
return (True);
}
/*****************************************************************************/
/* FUNCTION: DCF_DRIVER_Stop_Bert */
/* */
/* PARAMETERS: pNim - pointer to DCF_NIM struct. */
/* */
/* DESCRIPTION: The function stops the integrated BER tester */
/* by programming the BERT_ON bit of BERT_0 register. */
/* */
/* RETURNS: True if successful, False if unsuccessful. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
bool DCF_DRIVER_Stop_BERT(DCF_NIM *pNim)
{
unsigned char u8RegData;
bool bRetVal;
/* sanity check */
if(pNim == NULL)
{
return (False);
}
gDemReg[ST0_RID_BERT_0].value = gDemReg[ST0_RID_BERT_0].value & 0x1F;
u8RegData = gDemReg[ST0_RID_BERT_0].value;
bRetVal = DCF_RegWrite(pNim, gDemReg[ST0_RID_BERT_0].addr, 1, &u8RegData, DCF_DEMOD_I2C);
return (True);
}
/*****************************************************************************/
/* FUNCTION: DCF_DRIVER_Get_Blk_CT */
/* */
/* PARAMETERS: pNim - pointer to DCF_NIM struct. */
/* pu16Data - the pointer to the return data. */
/* */
/* DESCRIPTION: The function gets the 16-bit block counter */
/* by reading RS_DESC_0 / RS_DESC_1 registers. */
/* */
/* RETURNS: True if successful, False if unsuccessful. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
bool DCF_DRIVER_Get_Blk_CT(DCF_NIM *pNim, unsigned short *pu16Data)
{
unsigned short u16Temp;
bool bRetVal;
unsigned char u8RegData[2];
/* sanity check */
if((pNim == NULL) || (pu16Data == NULL))
{
return (False);
}
/* read the internal register */
bRetVal = DCF_RegRead(pNim, gDemReg[ST0_RID_RS_DESC_0].addr, 2, u8RegData, DCF_DEMOD_I2C);
if(bRetVal == False)
{
return (False);
}
gDemReg[ST0_RID_RS_DESC_0].value = u8RegData[0];
gDemReg[ST0_RID_RS_DESC_1].value = u8RegData[1];
u16Temp = ((unsigned short)(gDemReg[ST0_RID_RS_DESC_1].value) << 8);
u16Temp += (unsigned short)(gDemReg[ST0_RID_RS_DESC_0].value);
*pu16Data = u16Temp;
return (True);
}
/*****************************************************************************/
/* FUNCTION: DCF_DRIVER_Get_Uncorr_CT */
/* */
/* PARAMETERS: pNim - pointer to DCF_NIM struct. */
/* pu16Data - the pointer to the return data. */
/* */
/* DESCRIPTION: The function gets the 16-bit uncorrected block counter */
/* by reading RS_DESC_4 / RS_DESC_5 registers. */
/* */
/* RETURNS: True if successful, False if unsuccessful. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
bool DCF_DRIVER_Get_Uncorr_CT(DCF_NIM *pNim, unsigned short *pu16Data)
{
unsigned short u16Temp;
bool bRetVal;
unsigned char u8RegData[2];
/* sanity check */
if((pNim == NULL) || (pu16Data == NULL))
{
return (False);
}
/* read the internal register */
bRetVal = DCF_RegRead(pNim, gDemReg[ST0_RID_RS_DESC_4].addr, 2, u8RegData, DCF_DEMOD_I2C);
if(bRetVal == False)
{
return (False);
}
gDemReg[ST0_RID_RS_DESC_4].value = u8RegData[0];
gDemReg[ST0_RID_RS_DESC_5].value = u8RegData[1];
u16Temp = ((unsigned short)(gDemReg[ST0_RID_RS_DESC_5].value) << 8);
u16Temp += (unsigned short)(gDemReg[ST0_RID_RS_DESC_4].value);
*pu16Data = u16Temp;
return (True);
}
/*****************************************************************************/
/* FUNCTION: DCF_DRIVER_Stop_Blk_Counter */
/* */
/* PARAMETERS: pNim - pointer to DCF_NIM struct. */
/* */
/* DESCRIPTION: The function stops the block counter. */
/* */
/* RETURNS: True if successful, False if unsuccessful. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
bool DCF_DRIVER_Stop_Blk_Counter(DCF_NIM *pNim)
{
unsigned char u8RegData;
bool bRetVal;
/* sanity check */
if(pNim == NULL)
return(False);
/* enable all counters: 0xDF[1] = 1*/
gDemReg[ST0_RID_RS_DESC_15].value = gDemReg[ST0_RID_RS_DESC_15].value | 0x02;
u8RegData = gDemReg[ST0_RID_RS_DESC_15].value;
bRetVal= DCF_RegWrite(pNim, gDemReg[ST0_RID_RS_DESC_15].addr, 1, &u8RegData, DCF_DEMOD_I2C);
return(bRetVal);
}
/*****************************************************************************/
/* FUNCTION: DCF_DRIVER_Start_Blk_Counter */
/* */
/* PARAMETERS: pNim - pointer to DCF_NIM struct. */
/* */
/* DESCRIPTION: The function starts the block counter. */
/* */
/* RETURNS: True if successful, False if unsuccessful. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
bool DCF_DRIVER_Start_Blk_Counter(DCF_NIM *pNim)
{
unsigned char u8RegData;
bool bRetVal;
/* sanity check */
if(pNim == NULL)
return(False);
/* set 0xDF[1:0] */
gDemReg[ST0_RID_RS_DESC_15].value = gDemReg[ST0_RID_RS_DESC_15].value & 0xFC;
u8RegData = gDemReg[ST0_RID_RS_DESC_15].value;
bRetVal= DCF_RegWrite(pNim, gDemReg[ST0_RID_RS_DESC_15].addr, 1, &u8RegData, DCF_DEMOD_I2C);
if(bRetVal == False)
return(False);
/* set 0xDF[0] */
gDemReg[ST0_RID_RS_DESC_15].value = gDemReg[ST0_RID_RS_DESC_15].value | 0x01;
u8RegData = gDemReg[ST0_RID_RS_DESC_15].value;
bRetVal= DCF_RegWrite(pNim, gDemReg[ST0_RID_RS_DESC_15].addr, 1, &u8RegData, DCF_DEMOD_I2C);
return(bRetVal);
}
/*****************************************************************************/
/* FUNCTION: DCF_DRIVER_Set_WAGC */
/* */
/* PARAMETERS: pNim - pointer to DCF_NIM struct. */
/* */
/* DESCRIPTION: The function does some WAGC settings. */
/* */
/* RETURNS: True if successful, False if unsuccessful. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
bool DCF_DRIVER_Set_WAGC(DCF_NIM *pNim)
{
unsigned char u8RegData;
bool bRetVal;
/* sanity check */
if(pNim == NULL)
return(False);
/* Wide Band AGC freeze */
/* 0x43[4] = 0 */
u8RegData = gDemReg[ST0_RID_WBAGC_3].value & 0xEF;
/* Wide Band AGC clear */
/* 0x43[6] = 1 */
u8RegData = gDemReg[ST0_RID_WBAGC_3].value | 0x40;
/* Wide Band AGC unlock forcing :
As WB AGC lock status is unknown, it is preferible to force the unlock,
This state will not change until the WB AGC will be released. This is
necessary to avoid improper PMF AGC starting. */
/* set 0x43[3]=0 */
u8RegData = gDemReg[ST0_RID_WBAGC_3].value & 0xF7;
bRetVal= DCF_RegWrite(pNim, gDemReg[ST0_RID_WBAGC_3].addr, 1, &u8RegData, DCF_DEMOD_I2C);
return(bRetVal);
}
/*****************************************************************************/
/* FUNCTION: DCF_DRIVER_Set_PMFAGC */
/* */
/* PARAMETERS: pNim - pointer to DCF_NIM struct. */
/* */
/* DESCRIPTION: The function does some PMFAGC settings. */
/* */
/* RETURNS: True if successful, False if unsuccessful. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
bool DCF_DRIVER_Set_PMFAGC(DCF_NIM *pNim)
{
unsigned char u8RegData;
bool bRetVal;
/* sanity check */
if(pNim == NULL)
return(False);
/* PMF AGC unlock forcing is enabled */
/* 0x71[7] = 1 */
gDemReg[ST0_RID_PMFAGC_1].value |= 0x80;
u8RegData = gDemReg[ST0_RID_PMFAGC_1].value;
bRetVal= DCF_RegWrite(pNim, gDemReg[ST0_RID_PMFAGC_1].addr, 1, &u8RegData, DCF_DEMOD_I2C);
if(bRetVal == False)
return(False);
/* PMF AGC accumulator
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -