Пример #1
0
/**

@brief   RTL2832 FC2580 NIM module builder

Use BuildRtl2832Fc2580Module() to build RTL2832 FC2580 NIM module, set all module function pointers with the
corresponding functions, and initialize module private variables.


@param [in]   ppNim                       Pointer to RTL2832 FC2580 NIM module pointer
@param [in]   pDvbtNimModuleMemory        Pointer to an allocated DVB-T NIM module memory
@param [in]   I2cReadingByteNumMax        Maximum I2C reading byte number for basic I2C reading function
@param [in]   I2cWritingByteNumMax        Maximum I2C writing byte number for basic I2C writing function
@param [in]   I2cRead                     Basic I2C reading function pointer
@param [in]   I2cWrite                    Basic I2C writing function pointer
@param [in]   WaitMs                      Basic waiting function pointer
@param [in]   pRtl2832ExtraModuleMemory   Pointer to an allocated RTL2832 extra module memory
@param [in]   DemodDeviceAddr             RTL2832 I2C device address
@param [in]   DemodCrystalFreqHz          RTL2832 crystal frequency in Hz
@param [in]   DemodAppMode                RTL2832 application mode for setting
@param [in]   DemodTsInterfaceMode        RTL2832 TS interface mode for setting
@param [in]   pFc2580ExtraModuleMemory    Pointer to an allocated FC2580 extra module memory
@param [in]   TunerDeviceAddr             FC2580 I2C device address
@param [in]   TunerAgcMode                FC2580 AGC mode


@note
	-# One should call BuildRtl2832Fc2580Module() to build RTL2832 FC2580 NIM module before using it.

*/
void
BuildRtl2832Fc2580Module(
	DVBT_NIM_MODULE **ppNim,								// DVB-T NIM dependence
	DVBT_NIM_MODULE *pDvbtNimModuleMemory,

	unsigned char I2cReadingByteNumMax,						// Base interface dependence
	unsigned char I2cWritingByteNumMax,
	BASE_FP_I2C_READ I2cRead,
	BASE_FP_I2C_WRITE I2cWrite,
	BASE_FP_WAIT_MS WaitMs,

	RTL2832_EXTRA_MODULE *pRtl2832ExtraModuleMemory,		// Demod dependence
	unsigned char DemodDeviceAddr,
	unsigned long DemodCrystalFreqHz,
	int DemodAppMode,
	int DemodTsInterfaceMode,
	unsigned long DemodUpdateFuncRefPeriodMs,
	int DemodIsFunc1Enabled,

	FC2580_EXTRA_MODULE *pFc2580ExtraModuleMemory,			// Tuner dependence
	unsigned char TunerDeviceAddr,
	unsigned long TunerCrystalFreqHz,
	int TunerAgcMode
	)
{
	DVBT_NIM_MODULE *pNim;



	// Set NIM module pointer with NIM module memory.
	*ppNim = pDvbtNimModuleMemory;
	
	// Get NIM module.
	pNim = *ppNim;

	// Set I2C bridge module pointer with I2C bridge module memory.
	pNim->pI2cBridge = &pNim->I2cBridgeModuleMemory;

	// Set NIM extra module pointer.
	pNim->pExtra = INVALID_POINTER_VALUE;


	// Set NIM type.
	pNim->NimType = DVBT_NIM_RTL2832_FC2580;


	// Build base interface module.
	BuildBaseInterface(
		&pNim->pBaseInterface,
		&pNim->BaseInterfaceModuleMemory,
		I2cReadingByteNumMax,
		I2cWritingByteNumMax,
		I2cRead,
		I2cWrite,
		WaitMs
		);

	// Build RTL2832 demod module.
	BuildRtl2832Module(
		&pNim->pDemod,
		&pNim->DvbtDemodModuleMemory,
		pRtl2832ExtraModuleMemory,
		&pNim->BaseInterfaceModuleMemory,
		&pNim->I2cBridgeModuleMemory,
		DemodDeviceAddr,
		DemodCrystalFreqHz,
		DemodAppMode,
		DemodUpdateFuncRefPeriodMs,
		DemodIsFunc1Enabled
		);

	// Build FC2580 tuner module.
	BuildFc2580Module(
		&pNim->pTuner,
		&pNim->TunerModuleMemory,
		pFc2580ExtraModuleMemory,
		&pNim->BaseInterfaceModuleMemory,
		&pNim->I2cBridgeModuleMemory,
		TunerDeviceAddr,
		TunerCrystalFreqHz,
		TunerAgcMode
		);


	// Set NIM module variables.
	pNim->DemodTsInterfaceMode = DemodTsInterfaceMode;


	// Set NIM module function pointers with default functions.
	pNim->GetNimType        = dvbt_nim_default_GetNimType;
	pNim->GetParameters     = dvbt_nim_default_GetParameters;
	pNim->IsSignalPresent   = dvbt_nim_default_IsSignalPresent;
	pNim->IsSignalLocked    = dvbt_nim_default_IsSignalLocked;
	pNim->GetSignalStrength = dvbt_nim_default_GetSignalStrength;
	pNim->GetSignalQuality  = dvbt_nim_default_GetSignalQuality;
	pNim->GetBer            = dvbt_nim_default_GetBer;
	pNim->GetSnrDb          = dvbt_nim_default_GetSnrDb;
	pNim->GetTrOffsetPpm    = dvbt_nim_default_GetTrOffsetPpm;
	pNim->GetCrOffsetHz     = dvbt_nim_default_GetCrOffsetHz;
	pNim->GetTpsInfo        = dvbt_nim_default_GetTpsInfo;
	pNim->UpdateFunction    = dvbt_nim_default_UpdateFunction;

	// Set NIM module function pointers with particular functions.
	pNim->Initialize     = rtl2832_fc2580_Initialize;
	pNim->SetParameters  = rtl2832_fc2580_SetParameters;


	return;
}
/**

@brief   RTL2836 FC2580 NIM module builder

Use BuildRtl2836Fc2580Module() to build RTL2836 FC2580 NIM module, set all module function pointers with the
corresponding functions, and initialize module private variables.


@param [in]   ppNim                        Pointer to RTL2836 FC2580 NIM module pointer
@param [in]   pDtmbNimModuleMemory         Pointer to an allocated DTMB NIM module memory
@param [in]   I2cReadingByteNumMax         Maximum I2C reading byte number for basic I2C reading function
@param [in]   I2cWritingByteNumMax         Maximum I2C writing byte number for basic I2C writing function
@param [in]   I2cRead                      Basic I2C reading function pointer
@param [in]   I2cWrite                     Basic I2C writing function pointer
@param [in]   WaitMs                       Basic waiting function pointer
@param [in]   DemodDeviceAddr              RTL2836 I2C device address
@param [in]   DemodCrystalFreqHz           RTL2836 crystal frequency in Hz
@param [in]   DemodTsInterfaceMode         RTL2836 TS interface mode
@param [in]   DemodUpdateFuncRefPeriodMs   RTL2836 update function reference period in millisecond
@param [in]   DemodIsFunc1Enabled          RTL2836 Function 1 enabling status for setting
@param [in]   DemodIsFunc2Enabled          RTL2836 Function 2 enabling status for setting
@param [in]   TunerDeviceAddr              FC2580 I2C device address
@param [in]   TunerCrystalFreqHz           FC2580 crystal frequency in Hz
@param [in]   TunerAgcMode                 FC2580 AGC mode


@note
	-# One should call BuildRtl2836Fc2580Module() to build RTL2836 FC2580 NIM module before using it.

*/
void
BuildRtl2836Fc2580Module(
    DTMB_NIM_MODULE **ppNim,							// DTMB NIM dependence
    DTMB_NIM_MODULE *pDtmbNimModuleMemory,

    unsigned long I2cReadingByteNumMax,					// Base interface dependence
    unsigned long I2cWritingByteNumMax,
    BASE_FP_I2C_READ I2cRead,
    BASE_FP_I2C_WRITE I2cWrite,
    BASE_FP_WAIT_MS WaitMs,

    unsigned char DemodDeviceAddr,						// Demod dependence
    unsigned long DemodCrystalFreqHz,
    int DemodTsInterfaceMode,
    unsigned long DemodUpdateFuncRefPeriodMs,
    int DemodIsFunc1Enabled,
    int DemodIsFunc2Enabled,

    unsigned char TunerDeviceAddr,						// Tuner dependence
    unsigned long TunerCrystalFreqHz,
    int TunerAgcMode
)
{
    DTMB_NIM_MODULE *pNim;



    // Set NIM module pointer with NIM module memory.
    *ppNim = pDtmbNimModuleMemory;

    // Get NIM module.
    pNim = *ppNim;

    // Set I2C bridge module pointer with I2C bridge module memory.
    pNim->pI2cBridge = &pNim->I2cBridgeModuleMemory;


    // Set NIM type.
    pNim->NimType = DTMB_NIM_RTL2836_FC2580;


    // Build base interface module.
    BuildBaseInterface(
        &pNim->pBaseInterface,
        &pNim->BaseInterfaceModuleMemory,
        I2cReadingByteNumMax,
        I2cWritingByteNumMax,
        I2cRead,
        I2cWrite,
        WaitMs
    );

    // Build RTL2836 demod module.
    BuildRtl2836Module(
        &pNim->pDemod,
        &pNim->DtmbDemodModuleMemory,
        &pNim->BaseInterfaceModuleMemory,
        &pNim->I2cBridgeModuleMemory,
        DemodDeviceAddr,
        DemodCrystalFreqHz,
        DemodTsInterfaceMode,
        DemodUpdateFuncRefPeriodMs,
        DemodIsFunc1Enabled,
        DemodIsFunc2Enabled
    );

    // Build FC2580 tuner module.
    BuildFc2580Module(
        &pNim->pTuner,
        &pNim->TunerModuleMemory,
        &pNim->BaseInterfaceModuleMemory,
        &pNim->I2cBridgeModuleMemory,
        TunerDeviceAddr,
        TunerCrystalFreqHz,
        TunerAgcMode
    );


    // Set NIM module function pointers with default functions.
    pNim->GetNimType        = dtmb_nim_default_GetNimType;
    pNim->GetParameters     = dtmb_nim_default_GetParameters;
    pNim->IsSignalPresent   = dtmb_nim_default_IsSignalPresent;
    pNim->IsSignalLocked    = dtmb_nim_default_IsSignalLocked;
    pNim->GetSignalStrength = dtmb_nim_default_GetSignalStrength;
    pNim->GetSignalQuality  = dtmb_nim_default_GetSignalQuality;
    pNim->GetBer            = dtmb_nim_default_GetBer;
    pNim->GetPer            = dtmb_nim_default_GetPer;
    pNim->GetSnrDb          = dtmb_nim_default_GetSnrDb;
    pNim->GetTrOffsetPpm    = dtmb_nim_default_GetTrOffsetPpm;
    pNim->GetCrOffsetHz     = dtmb_nim_default_GetCrOffsetHz;
    pNim->GetSignalInfo     = dtmb_nim_default_GetSignalInfo;
    pNim->UpdateFunction    = dtmb_nim_default_UpdateFunction;

    // Set NIM module function pointers with particular functions.
    pNim->Initialize     = rtl2836_fc2580_Initialize;
    pNim->SetParameters  = rtl2836_fc2580_SetParameters;


    return;
}