📄 cx24143_regs.c
字号:
{
/* invalid setting in reg.map, report to app */
_DRIVER_SetError(nim,REG_VERFY_DFLT,rvm_msg,idx);
return(False);
}
} /* switch(... */
return(True);
} /* RegisterVerifyRegDefault() */
/*******************************************************************************************************/
/* RegisterVerifyRegBitCount() */
/*******************************************************************************************************/
BOOL RegisterVerifyRegBitCount( /* function to verify that bit count rules are adhered to */
NIM *nim, /* pointer to nim */
int idx) /* register to test */
{
static CHAR *rvm_msg = "RegisterVerifyRegBitCount()";
int len;
/* bit count of zero is an error! */
if (Register[idx].bit_count != 0)
{
/* test for bit counts of less-eq 8 */
if (Register[idx].bit_count <= 8)
{
/* calc the number of valid positions starting pt. can be */
len = (8 - Register[idx].bit_count);
if (RegisterOneOf((CHAR)(Register[idx].starting+'0'),"76543210",len+1) == True) return(True);
}
else
{
/* if bit-count > 8, then start can be anywhere --> look at reg.map SYSSymbolRate[21:0] */
return(True);
}
}
/* invalid setting in reg.map, report to app */
_DRIVER_SetError(nim,REG_VERFY_BCNT,rvm_msg,idx);
return(False);
} /* RegisterVerifyBitCount() */
/*******************************************************************************************************/
/* RegisterOneOf() */
/*******************************************************************************************************/
BOOL RegisterOneOf( /* function to find match in match_list for len. */
CHAR match, /* char to match */
CHAR *match_list, /* list to match against */
int len) /* max length of match_list */
{
register int i;
/* try to match 'match' with 'match_list[0..n] */
for (i = 0 ; match_list[i] != CNULL ; i++)
{
if (match == match_list[i]) return(True);
if (i > 255) break;
if (i >= len) break;
}
return(False);
} /* RegisterOneOf() */
/*******************************************************************************************************/
/* Register_bitlength() */
/*******************************************************************************************************/
int Register_bitlength( /* returns the length in bit of a register */
REGIDX regidx) /* regidx of register number to read bitlength of */
{
return(Register[regidx].bit_count);
} /* Register_bitlength() */
/*******************************************************************************************************/
/* RegisterWritePLLMult() */
/*******************************************************************************************************/
BOOL RegisterWritePLLMult( /* function to write PLLMult register */
NIM *nim, /* pointer to nim */
ULONG ulRegVal) /* value to write to PLLMult register */
{
/* only write the PLLMult value if it is different from the last value
* programmed to the PLLMult register.
*/
if (nim->ucPLLMult_shadow != (UCHAR)ulRegVal)
{
if (RegisterWrite(nim,CX24130_PLLMULT,ulRegVal) == False)
{
return (False);
}
nim->ucPLLMult_shadow = (UCHAR)ulRegVal;
}
return (True);
} /* RegisterWritePLLMult() */
#ifdef CAMARIC_FEATURES
/*******************************************************************************************************/
/* RegisterReadCentralFreq() */
/*******************************************************************************************************/
BOOL RegisterReadCentralFreq( /* function to read current central freq register for camaric */
NIM *nim, /* pointer to nim */
ULONG *pFreq) /* pointer to returned frequency value */
{
ULONG ulRegVal = 0UL;
/* read if the demod is a Camaric (CX24123 or CX24123C) */
if (DRIVER_Camaric(nim) == True)
{
/* initialize return value */
*pFreq = 0UL;
/* read the sign bit and shift it to bit 12 */
if (RegisterRead(nim,CX24123_ACQPRFREQCURRSIGN,&ulRegVal) != True)
{
return(False);
}
*pFreq |= ulRegVal << 12;
/* read the MSB of mantissa and shift it to bit 11 */
if (RegisterRead(nim,CX24123_ACQPRFREQCURRMSB,&ulRegVal) != True)
{
return(False);
}
*pFreq |= ulRegVal << 4;
/* read the LSB of mantissa */
if (RegisterRead(nim,CX24123_ACQPRFREQCURRLSB,&ulRegVal) != True)
{
return(False);
}
*pFreq |= ulRegVal;
return (True);
} /* if (DRIVER_Camaric(nim) == True) */
return(False);
} /* RegisterReadCentralFreq() */
/*******************************************************************************************************/
/* RegisterWriteCentralFreq() */
/*******************************************************************************************************/
BOOL RegisterWriteCentralFreq( /* function to write nominal central freq register for camaric */
NIM *nim, /* pointer to nim */
ULONG ulFreq) /* frequency value to write */
{
ULONG ulRegVal;
/* read if the demod is a Camaric (CX24123 or CX24123C) */
if (DRIVER_Camaric(nim) == True)
{
/* write the sign bit at bit 12 */
ulRegVal = (ulFreq & 0x1000UL) >> 12;
if (RegisterWrite(nim,CX24123_ACQPRFREQNOMSIGN,ulRegVal) != True)
{
return(False);
}
/* write the MSB of mantissa at bits 11:4 */
ulRegVal = (ulFreq & 0xff0UL) >> 4;
if (RegisterWrite(nim,CX24123_ACQPRFREQNOMMSB,ulRegVal) != True)
{
return(False);
}
/* write the LSB of mantissa at bits 3:0 */
ulRegVal = ulFreq & 0xfUL;
if (RegisterWrite(nim,CX24123_ACQPRFREQNOMLSB,ulRegVal) != True)
{
return(False);
}
return (True);
} /* if (DRIVER_Camaric(nim) == True) */
return(False);
} /* RegisterWriteCentralFreq() */
#endif /* #ifdef CAMARIC_FEATURES */
/*******************************************************************************************************/
/* RegisterWriteClkSmoothDiv() */
/*******************************************************************************************************/
BOOL RegisterWriteClkSmoothDiv( /* function to write mpeg clk smoother freq divider */
NIM *nim, /* pointer to nim */
ULONG ulClkSmoothDiv) /* clk smoother freq divider value to write */
{
ULONG ulRegVal;
if (DRIVER_Cobra(nim) == True)
{
ulRegVal = ulClkSmoothDiv;
if (RegisterWrite(nim,CX24130_MPGCLKSMOOTHFREQDIV,ulRegVal) == False)
{
return (False);
}
}
#ifdef CAMARIC_FEATURES
else if (DRIVER_Camaric(nim) == True) /* Camaric (CX24123 or CX24123C) */
{
/* write 8 LSB bits */
ulRegVal = ulClkSmoothDiv & 0xFFUL;
if (RegisterWrite(nim,CX24123_MPGCLKSMFREQDIVLSB,ulRegVal) != True)
{
return (False);
}
/* write 1 middle bit */
ulRegVal = (ulClkSmoothDiv & 0x100UL) >> 8;
if (RegisterWrite(nim,CX24123_MPGCLKSMFREQDIVMID,ulRegVal) != True)
{
return (False);
}
/* write 2 MSB bits */
ulRegVal = (ulClkSmoothDiv & 0x600UL) >> 9;
if (RegisterWrite(nim,CX24123_MPGCLKSMFREQDIVMSB,ulRegVal) != True)
{
return (False);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -