?? sttuner.c
字號:
See Also: STTUNER_Scan() STTUNER_ScanContinue()*****************************************************************************/ST_ErrorCode_t STTUNER_SetFrequency(STTUNER_Handle_t Handle, U32 Frequency, STTUNER_Scan_t *ScanParams_p, U32 Timeout){ ST_ErrorCode_t Error = ST_NO_ERROR; TUNER_ControlBlock_t *Tuner_p; /* Check the parameters */ if((Handle == 0) || (ScanParams_p == NULL)) { return ST_ERROR_BAD_PARAMETER; } /* Obtain the control block from the handle */ Tuner_p = GetControlBlockFromHandle(Handle); /* Ensure the handle is valid */ if (Tuner_p != NULL) { /* Check the scan parameters are valid. Note that it does not * make sense to allow xxx_ALL because we are scanning for an * exact frequency. We therefore reject the scan unless all * parameters are exact. */ if (ScanParams_p->Polarization != STTUNER_PLR_ALL && ScanParams_p->Modulation != STTUNER_MOD_ALL && ScanParams_p->FECRates != STTUNER_FEC_ALL) { /* Set internal control block parameters */ Tuner_p->ScanInfo.FrequencyStart = Frequency; Tuner_p->ScanInfo.FrequencyEnd = Frequency; Tuner_p->Timeout = Timeout; Tuner_p->SingleScan = *ScanParams_p; Tuner_p->ScanExact = TRUE; /* Ensure the tuner is not already scanning */ if (Tuner_p->TunerInfo.Status == STTUNER_STATUS_SCANNING) { /* We must first abort the current scanning operation */ TUNER_AbortScan(Tuner_p); } /* Commence a scan with the required parameters */ Error = TUNER_StartScan(Tuner_p); } else { /* The scan parameter contains an invalid setting */ Error = ST_ERROR_BAD_PARAMETER; } } else { /* The handle is invalid */ Error = ST_ERROR_INVALID_HANDLE; } /* Common exit point */ return Error;} /* STTUNER_SetFrequency() *//*****************************************************************************Name: STTUNER_SetLNBToneState()Description: Sets the LNB tone generator.Parameters: Handle, handle to sttuner device LNBToneState, new state for LNB tone.Return Value: ST_NO_ERROR, the operation was carried out without error. ST_ERROR_BAD_PARAMETER Handle NULL or incorrect tone setting.See Also: Nothing.*****************************************************************************/ST_ErrorCode_t STTUNER_SetLNBToneState(STTUNER_Handle_t Handle, STTUNER_LNBToneState_t LNBToneState){ ST_ErrorCode_t Error = ST_NO_ERROR; TUNER_ControlBlock_t *Tuner_p; /* Check the parameters */ if(Handle == 0) { return ST_ERROR_BAD_PARAMETER; } /* Obtain the control block from the handle */ Tuner_p = GetControlBlockFromHandle(Handle); /* Ensure the handle is valid */ if (Tuner_p != NULL) { /* Ensure tone state is valid */ if (LNBToneState == STTUNER_LNB_TONE_OFF || LNBToneState == STTUNER_LNB_TONE_22KHZ) { SAT_Config_t SatConfig; /* Get current settings */ Error = SAT_GetConfig(Tuner_p->SatHandle, &SatConfig); if (Error == ST_NO_ERROR) { /* Invoke new configuration */ SatConfig.ToneState = LNBToneState; Error = SAT_SetConfig(Tuner_p->SatHandle, &SatConfig); /* Was config set correctly? */ if (Error == ST_NO_ERROR) { /* Update internal status */ Tuner_p->TunerInfo.ScanInfo.LNBToneState = LNBToneState; } } } else { /* The scan parameter contains an invalid setting */ Error = ST_ERROR_BAD_PARAMETER; } } else { /* The handle is invalid */ Error = ST_ERROR_INVALID_HANDLE; } /* Common exit point */ return Error;} /* STTUNER_SetLNBToneState() *//*****************************************************************************Name: STTUNER_Scan()Description: This routine commences a scan starting from the "FreqFrom" and iterates in steps of "FreqStep" until "FreqTo". It is non-blocking i.e., returns to the caller immediately. A callback routine may be invoked with an appropriate error code, if either: a) The tuner has just lost lock. b) The scan completed without a lock i.e., "not found". c) The scan has got a lock. d) The scan has timed out. If no callback is setup, the caller may interrogate the progress of the scan by calling STTUNER_GetStatus() at any time. NOTE: The caller can advance to the next scan frequency by using the STTUNER_ScanContinue() call.Parameters: Handle, the handle of the tuner device. FreqFrom, Start frequency. FreqTo, End frequency. FreqStep, Frequency step - not used at present. Timeout, timeout period (in ms) to allow for lock.Return Value: ST_NO_ERROR, the operation was carried out without error. ST_ERROR_INVALID_HANDLE, the handle was invalid. ST_ERROR_BAD_PARAMETER, one of the frequency parameters passed in is invalid.See Also: STTUNER_ScanContinue()*****************************************************************************/ST_ErrorCode_t STTUNER_Scan(STTUNER_Handle_t Handle, U32 FreqFrom, U32 FreqTo, U32 FreqStep, U32 Timeout){ ST_ErrorCode_t Error = ST_NO_ERROR; TUNER_ControlBlock_t *Tuner_p; /* Check the parameters */ if((Handle == 0) || (FreqFrom == 0)) { return ST_ERROR_BAD_PARAMETER; } /* Obtain the control block from the handle */ Tuner_p = GetControlBlockFromHandle(Handle); /* Ensure the handle is valid */ if (Tuner_p != NULL) { /* Determine scan step direction for the scan loop */ if (FreqFrom <= FreqTo) { /* Ascending direction (multiply step by 1) */ Tuner_p->ScanInfo.ScanDirection = 1; } else { /* Descending direction (multiply step by -1) */ Tuner_p->ScanInfo.ScanDirection = -1; } Tuner_p->ScanInfo.FrequencyStart = FreqFrom; Tuner_p->ScanInfo.FrequencyEnd = FreqTo; Tuner_p->Timeout = Timeout; Tuner_p->ScanExact = FALSE; /* Ensure the tuner is not already scanning */ if (Tuner_p->TunerInfo.Status == STTUNER_STATUS_SCANNING) { /* We must first abort the current scanning operation */ TUNER_AbortScan(Tuner_p); } /* Commence a scan with the required parameters */ Error = TUNER_StartScan(Tuner_p); } else { /* The handle is invalid */ Error = ST_ERROR_INVALID_HANDLE; } /* Common exit point */ return Error;} /* STTUNER_Scan() *//*****************************************************************************Name: STTUNER_ScanContinue()Description: This routine is used to continue a previously invoked scan operatation. It is non-blocking i.e., returns to the caller immediately -- see STTUNER_Scan() for more information. NOTE: STTUNER_ScanContinue() will return an error if the previous scan step has not completed.Parameters: Handle, the handle of the tuner device. Timeout, timeout period (in ms) to allow for lock.Return Value: ST_NO_ERROR, the operation was carried out without error. ST_ERROR_INVALID_HANDLE, the handle was invalid. ST_ERROR_DEVICE_BUSY, the previous scan step is still in progress. ST_ERROR_BAD_PARAMETER, the end of the scan list has been reached, or a scan has not yet been initiated.See Also: STTUNER_Scan()*****************************************************************************/ST_ErrorCode_t STTUNER_ScanContinue(STTUNER_Handle_t Handle, U32 Timeout){ ST_ErrorCode_t Error = ST_NO_ERROR; TUNER_ControlBlock_t *Tuner_p; if(Handle == 0) { return ST_ERROR_BAD_PARAMETER; } /* Obtain the control block from the handle */ Tuner_p = GetControlBlockFromHandle(Handle); /* Ensure the handle is valid */ if (Tuner_p != NULL) { /* Attempt to continue for the next scan */ Tuner_p->Timeout = Timeout; Tuner_p->ScanExact = FALSE; Error = TUNER_ContinueScan(Tuner_p); } else { /* The handle is invalid */ Error = ST_ERROR_INVALID_HANDLE; } /* Common exit point */ return Error;} /* STTUNER_ScanContinue() *//*****************************************************************************Name: STTUNER_SetBandList()Description: Sets the current frequency bands and associated local oscillator frequencies.Parameters: Handle, the handle of the tuner device.Return Value: ST_NO_ERROR, the operation was carried out without error. ST_ERROR_INVALID_HANDLE, the handle was invalid. ST_ERROR_DEVICE_BUSY, the band/lo frequencies can not be set during a scan. ST_ERROR_BAD_PARAMETER Handle or BandList_p NULLSee Also: STTUNER_GetBandList()*****************************************************************************/ST_ErrorCode_t STTUNER_SetBandList(STTUNER_Handle_t Handle, const STTUNER_BandList_t *BandList_p){ ST_ErrorCode_t Error = ST_NO_ERROR; TUNER_ControlBlock_t *Tuner_p; /* Check the parameters */ if((Handle == 0) || (BandList_p == NULL)) { return ST_ERROR_BAD_PARAMETER; } /* Obtain the control block from the handle */ Tuner_p = GetControlBlockFromHandle(Handle); /* Ensure the handle is valid */ if (Tuner_p != NULL) { /* Check device is idle before setting new list */ if (Tuner_p->TunerInfo.Status != STTUNER_STATUS_SCANNING) { /* Ensure the tuner is not currently scanning */ if (Tuner_p->InitParams.BandListMax >= BandList_p->NumElements) { /* Copy the supplied bank/LO frequencies into the tuner * control block -- we must ensure we lock out the scan * task whilst doing this. */ semaphore_wait(&Tuner_p->ScanTask.GuardSemaphore); Tuner_p->BandList.NumElements = BandList_p->NumElements; memcpy(Tuner_p->BandList.BandList, BandList_p->BandList, (BandList_p->NumElements * sizeof(STTUNER_Band_t))); semaphore_signal(&Tuner_p->ScanTask.GuardSemaphore); } else { /* Number of elements exceeds maximum allowed */ Error = ST_ERROR_BAD_PARAMETER; } } else { /* Scan task is busy */ Error = ST_ERROR_DEVICE_BUSY; } } else { /* The handle is invalid */ Error = ST_ERROR_INVALID_HANDLE; } /* Common exit point */ return Error;} /* STTUNER_SetBandList() *//*****************************************************************************Name: STTUNER_SetScanList()Description: Sets the scanning criteria for a tuner scan.Parameters: Handle, the handle of the tuner device. ScanList_p, pointer to a scan list reflecting the scanning criteria.Return Value: ST_NO_ERROR, the operation was carried out without error. ST_ERROR_INVALID_HANDLE, the handle was invalid. ST_ERROR_DEVICE_BUSY, the tuner is scanning, we do not allow the parameters to be set during a scan. ST_ERROR_BAD_PARAMETER Handle or ScanList_p NULLSee Also: STTUNER_GetScanList()*****************************************************************************/ST_ErrorCode_t STTUNER_SetScanList(STTUNER_Handle_t Handle, const STTUNER_ScanList_t *ScanList_p){ ST_ErrorCode_t Error = ST_NO_ERROR;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -