📄 tlg1100app.c
字号:
}
/*****************************************************************************
* TLGAPP_SetChannelAux
******************************************************************************/
uint8 gValidChnNum;
TLGDLL_API int TLGAPP_SetChannelAux(int chn, int useFast)
{
int i = 0;
int result = 0; /* Must init this variable. By Paul */
gValidChnNum = 0; /* By Paul */
if (chn == 0) return 0;
if (p_tlg_cur_map == NULL) return 0;
if (!tlg_init_done) TLGAPP_Init(tlg_i2c_addr);
while (p_tlg_cur_map[i] CHN_S != 0)
{
/* found channel to change to */
if (p_tlg_cur_map[i] CHN_S == (uint32)chn)
{
gValidChnNum = 1; /* By Paul */
/* change LNA if required */
TLGAPP_SetLnaGpio(p_tlg_cur_map[i] HZ_S);
/* update bw if needed */
TLGAPP_ChannelSetup(tlg_cur_mode, p_tlg_cur_map[i] STD_S, p_tlg_cur_map[i] BW_S);
if (tlg_cur_mode == TLG_MODE_ANALOG_TV)
{
if (useFast)
result = TLG_FastScanTVChn(tlg_i2c_addr, p_tlg_cur_map[i] HZ_S);
else
result = TLG_ScanTVChn(tlg_i2c_addr, p_tlg_cur_map[i] HZ_S);
} else
result = TLG_ScanFMChn(tlg_i2c_addr, p_tlg_cur_map[i] HZ_S, tlg_slope, tlg_offset);
break; /* If this channel is found, then break here. By Paul */
}
i++;
}
return(result);
}
/*****************************************************************************
* TLGAPP_SetChannel
******************************************************************************/
TLGDLL_API int TLGAPP_SetChannel(int chn) {
return TLGAPP_SetChannelAux(chn, false /* useFast */);
}
/*****************************************************************************
* TLGAPP_FastSetChannel
******************************************************************************/
TLGDLL_API int TLGAPP_FastSetChannel(int chn) {
return TLGAPP_SetChannelAux(chn, true /* useFast */);
}
/*****************************************************************************
* TLGAPP_ScanChannels
******************************************************************************/
uint32 tlg_prev_fm_ssi = 0;
uint32 tlg_prev_fm_chn = 0;
extern TLGDLL_API uint32 tlg_cur_fm_ssi;
TLGDLL_API void TLGAPP_ScanChannels(p_tlg_channel_t(tlg_scan_map), int max_scan)
{
int chni, scani=0;
tlg_prev_fm_ssi = 0;
tlg_prev_fm_chn = 0;
for(chni=0; p_tlg_cur_map[chni] CHN_S != 0; chni++) {
int locked;
#ifdef TLG_USE_FAST_LOCK_DETECT
locked = TLGAPP_FastSetChannel(p_tlg_cur_map[chni] CHN_S);
#else
locked = TLGAPP_SetChannel(p_tlg_cur_map[chni] CHN_S);
#endif /* TLG_USE_FAST_LOCK_DETECT */
if (locked || tlg_prev_fm_ssi) {
int schn = chni;
/*** not locked, then report prev cached radio chn ***/
if (!locked) {
schn = tlg_prev_fm_chn;
tlg_prev_fm_chn = 0;
tlg_prev_fm_ssi = 0;
} else if (tlg_cur_mode == TLG_MODE_FM_RADIO) {
/*** if locked and no prev radio, or prev weaker than cur ***/
if (!tlg_prev_fm_ssi || tlg_prev_fm_ssi < tlg_cur_fm_ssi)
{
tlg_prev_fm_ssi = tlg_cur_fm_ssi;
tlg_prev_fm_chn = chni;
continue;
} else { /*** previous wins ***/
schn = tlg_prev_fm_chn;
tlg_prev_fm_chn = 0;
tlg_prev_fm_ssi = 0;
}
}
/* leave room for 0-valued entry to terminate channel map */
if (scani >= (max_scan-1)) break;
(*(tlg_scan_map + scani)) CHN_S = p_tlg_cur_map[schn] CHN_S;
(*(tlg_scan_map + scani)) HZ_S = p_tlg_cur_map[schn] HZ_S;
(*(tlg_scan_map + scani)) BW_S = p_tlg_cur_map[schn] BW_S;
(*(tlg_scan_map + scani)) STD_S = p_tlg_cur_map[schn] CHN_S;
/* customizable callback routine */
TLGAPP_ScanChanFound(p_tlg_cur_map[schn] CHN_S);
}
}
tlg_scan_map[scani] CHN_S = 0;
tlg_scan_map[scani] HZ_S = 0;
tlg_scan_map[scani] BW_S = 0;
tlg_scan_map[scani] STD_S = 0;
}
/*****************************************************************************
* TLGAPP_SeekNextChn
******************************************************************************/
TLGDLL_API void TLGAPP_SeekNextChn(int chn) {
int chni, scani=0, cnt=0;
tlg_prev_fm_ssi = 0;
tlg_prev_fm_chn = 0;
if (p_tlg_cur_map == NULL) return;
chni = chn;
while (cnt < 2) {
int locked;
chni++;
if (p_tlg_cur_map[chni] CHN_S = 0) {
cnt++;
chni = 0;
}
#ifdef TLG_USE_FAST_LOCK_DETECT
locked = TLGAPP_FastSetChannel(p_tlg_cur_map[chni] CHN_S);
#else
locked = TLGAPP_SetChannel(p_tlg_cur_map[chni] CHN_S);
#endif /* TLG_USE_FAST_LOCK_DETECT */
if (locked || tlg_prev_fm_ssi) {
int schn = chni;
/*** not locked, then report prev cached radio chn ***/
if (!locked) {
schn = tlg_prev_fm_chn;
tlg_prev_fm_chn = 0;
tlg_prev_fm_ssi = 0;
} else if (tlg_cur_mode == TLG_MODE_FM_RADIO) {
/*** if locked and no prev radio, or prev weaker than cur ***/
if (!tlg_prev_fm_ssi || tlg_prev_fm_ssi < tlg_cur_fm_ssi) {
tlg_prev_fm_ssi = tlg_cur_fm_ssi;
tlg_prev_fm_chn = chni;
continue;
} else { /*** previous wins ***/
schn = tlg_prev_fm_chn;
tlg_prev_fm_chn = 0;
tlg_prev_fm_ssi = 0;
}
}
if (schn != chni) {
#ifdef TLG_USE_FAST_LOCK_DETECT
locked = TLGAPP_FastSetChannel(p_tlg_cur_map[schn] CHN_S);
#else
locked = TLGAPP_SetChannel(p_tlg_cur_map[schn] CHN_S);
#endif /* TLG_USE_FAST_LOCK_DETECT */
}
break;
}
}
}
/*****************************************************************************
* TLGAPP_SeekPrevChn
******************************************************************************/
TLGDLL_API void TLGAPP_SeekPrevChn(int chn) {
int chni, scani=0, cnt=0, chncnt=0;
tlg_prev_fm_ssi = 0;
tlg_prev_fm_chn = 0;
if (p_tlg_cur_map == NULL) return;
chni = chn;
while (cnt < 2) {
int locked;
chni--;
if (chni < 0) {
cnt++;
chni = tlg_cur_chn_cnt - 1;
}
#ifdef TLG_USE_FAST_LOCK_DETECT
locked = TLGAPP_FastSetChannel(p_tlg_cur_map[chni] CHN_S);
#else
locked = TLGAPP_SetChannel(p_tlg_cur_map[chni] CHN_S);
#endif /* TLG_USE_FAST_LOCK_DETECT */
if (locked || tlg_prev_fm_ssi) {
int schn = chni;
/*** not locked, then report prev cached radio chn ***/
if (!locked) {
schn = tlg_prev_fm_chn;
tlg_prev_fm_chn = 0;
tlg_prev_fm_ssi = 0;
} else if (tlg_cur_mode == TLG_MODE_FM_RADIO) {
/*** if locked and no prev radio, or prev weaker than cur ***/
if (!tlg_prev_fm_ssi || tlg_prev_fm_ssi < tlg_cur_fm_ssi) {
tlg_prev_fm_ssi = tlg_cur_fm_ssi;
tlg_prev_fm_chn = chni;
continue;
} else { /*** previous wins ***/
schn = tlg_prev_fm_chn;
tlg_prev_fm_chn = 0;
tlg_prev_fm_ssi = 0;
}
}
if (schn != chni) {
#ifdef TLG_USE_FAST_LOCK_DETECT
locked = TLGAPP_FastSetChannel(p_tlg_cur_map[schn] CHN_S);
#else
locked = TLGAPP_SetChannel(p_tlg_cur_map[schn] CHN_S);
#endif /* TLG_USE_FAST_LOCK_DETECT */
}
break;
}
}
}
/*****************************************************************************
* TLGAPP_TurnOnTestPattern
******************************************************************************/
TLGDLL_API void TLGAPP_TurnOnTestPattern(void) {
if (!tlg_init_done) TLGAPP_Init(tlg_i2c_addr);
TLG_SetVideoTestPatternState(tlg_i2c_addr, TLG_ON);
}
/*****************************************************************************
* TLGAPP_TurnOffTestPattern
******************************************************************************/
TLGDLL_API void TLGAPP_TurnOffTestPattern(void) {
if (!tlg_init_done) TLGAPP_Init(tlg_i2c_addr);
TLG_SetVideoTestPatternState(tlg_i2c_addr, TLG_OFF);
}
/*****************************************************************************
* TLGAPP_TurnOnTestToneMode
******************************************************************************/
TLGDLL_API void TLGAPP_TurnOnTestToneMode(void) {
/** turn gain all the way down before turning on test tones */
TLG_SetAudioGain(tlg_i2c_addr, tlg_cur_aud_mode, TLG_MIN_AUD_GAIN);
TLG_SetAudioTestToneMode(tlg_i2c_addr, TLG_ON);
}
/*****************************************************************************
* TLGAPP_TurnOffTestToneMode
******************************************************************************/
TLGDLL_API void TLGAPP_TurnOffTestToneMode(void) {
/** restore gain setting */
TLG_SetAudioGain(tlg_i2c_addr, tlg_cur_aud_mode, tlg_cur_gain);
TLG_SetAudioTestToneMode(tlg_i2c_addr, TLG_OFF);
}
#endif /* TLG_CHIP_TYPE */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -