phantom_cmd.c
来自「QPSK Tuner details, for conexant chipset」· C语言 代码 · 共 769 行 · 第 1/3 页
C
769 行
* TRUE - operation successful; FALSE - otherwise. LLF command specific errors are returned in the LLF
* structure.
*
* I/O Parameters Descriptions
* IN PHANTOM_NIM* p_nim Pointer to PHANTOM_NIM structure allocated by application
* IN/OUT LLF* p_llf Pointer to the LLF structure. The data member of the structure is also a
* place holder for the LLF returned values.
* IN BOOL wait_for_response When TRUE, the LLF polls the Read token for a match and then reads the
* return results (the number of results to read is provided in the input
* LLF data). When FALSE, returns immediately after executing the LLF.
* Ideally every LLF should wait for a response.
*******************************************************************************************************/
BOOL
PHANTOM_ExecuteLLF(PHANTOM_NIM* p_nim,
PHANTOM_LLF* p_llf)
{
unsigned char index;
unsigned char token_byte;
unsigned short poll_count; /* PHANTOM_MAX_READ_CONTROL_BYTE_POLL value must not overflow this */
unsigned char llf_opcode_addr;
unsigned char llf_args_start_addr;
unsigned char llf_write_control_addr;
unsigned char max_receive_bytes;
unsigned char llf_receive_args_offset;
/* Validation */
if (p_nim == 0) /* bad pointer */
{
return (False);
}
if (p_llf == 0) /* bad pointer */
{
return (False);
}
p_llf->send_to = PHANTOM_LLF_SECTION_LOWER; /* Use only the lower section */
llf_opcode_addr = PHANTOM_LLF_LWRITE_OPCODE;
llf_args_start_addr = PHANTOM_LLF_LWRITE_ARG_BASE;
llf_write_control_addr = PHANTOM_LLF_LWRITE_CONTROL_BYTE;
/* -- Process the LLF packet -- */
/* Write the OpCode first */
(*p_nim->SBWrite)(p_nim->demod_handle,
(unsigned char)llf_opcode_addr,
p_llf->op_code,
&p_nim->iostatus);
if (p_nim->iostatus != 0UL) /* SBWrite error! */
{
return(False);
}
/* Write the required number of LLF arguments */
if (p_llf->send_data_length > PHANTOM_MAX_LLF_WRITE_ARGS)
{
p_llf->send_data_length = PHANTOM_MAX_LLF_WRITE_ARGS;
}
for (index = 0; index < p_llf->send_data_length; index++)
{
(*p_nim->SBWrite)(p_nim->demod_handle,
(unsigned char)(llf_args_start_addr + index),
p_llf->data[index],
&p_nim->iostatus);
if (p_nim->iostatus != 0UL) /* SBWrite error! */
{
return(False);
}
}
/* Write the control byte */
token_byte = PHANTOM_LLF_READY_TOKEN;
(*p_nim->SBWrite)(p_nim->demod_handle,
(unsigned char)llf_write_control_addr,
token_byte,
&p_nim->iostatus);
if (p_nim->iostatus != 0UL) /* SBWrite error! */
{
return(False);
}
/* Wait for LLF execution */
for (poll_count = 0; poll_count < PHANTOM_MAX_READ_CONTROL_BYTE_POLL; poll_count++)
{
token_byte = (*p_nim->SBRead)(p_nim->demod_handle,
(unsigned char)llf_write_control_addr,
&p_nim->iostatus);
if (p_nim->iostatus != 0UL) /* SBRead error! */
{
return(False);
}
/* Verify it is reset to zero by the microcode */
if (token_byte == PHANTOM_LLF_DONE_TOKEN)
{
break;
}
}
/* Read the return data if present */
if (token_byte == PHANTOM_LLF_DONE_TOKEN)
{
if (p_llf->received_data_length != 0x00)
{
/* Maximum allowed return bytes for this session */
max_receive_bytes = (unsigned char)(PHANTOM_MAX_LLF_ARG_SIZE - p_llf->send_data_length);
if (p_llf->received_data_length > max_receive_bytes)
{
p_llf->received_data_length = max_receive_bytes;
}
llf_receive_args_offset = (unsigned char)(llf_args_start_addr + p_llf->send_data_length);
for (index = 0; index < p_llf->received_data_length; index++)
{
p_llf->data[index] = (*p_nim->SBRead)(p_nim->demod_handle,
(unsigned char)(llf_receive_args_offset + index),
&p_nim->iostatus);
if (p_nim->iostatus != 0UL) /* SBRead error! */
{
return(False);
}
}
}
}
else /* Token mismatch */
{
return(False);
}
return (True);
}
/*******************************************************************************************************
* Name: PHANTOM_LLF_ChangeChannel
*
* Description:
*
* Return Value:
* TRUE - operation successful; FALSE - otherwise
*
* I/O Parameters Descriptions
*
* IN PHANTOM_NIM* p_nim
* IN unsigned long tuner_frequency tuner frequency in khz.
* IN unsigned short nominal_symbol_rate Symbol rate in ksps
* IN unsigned char select_bin_mode 0 = blind mode; 1 = quick mode; 2 = disable; 3 = installation.
* acquisition state mcahine.
* IN unsigned char spectral_inversion Spectral inversion [off, on, off/both, on/both]
* IN unsigned char modcode internal modcode.
* IN unsigned char pilot ON, OFF or UNKNOWN
* IN unsigned short frequency_search_range 0 to 10,000
* IN unsigned short nominal_central_frequency 0 to 10,000
* IN unsigned char roll_off_factor Roll off factor [0 to 2]
* IN unsigned char viterbi_code_rate Additional coderates (applies to DVB/DTV).
* IN unsigned char vco_divider 3 = /8; 1 = /4; 2 = /2; 0 = no divide.
* IN unsigned long vco_clk_by_main_div
*
*******************************************************************************************************/
BOOL
PHANTOM_LLF_ChangeChannel(PHANTOM_NIM* p_nim,
unsigned long tuner_frequency,
unsigned short nominal_symbol_rate,
unsigned char select_bin_mode,
unsigned char spectral_inversion,
unsigned char modcode,
unsigned char pilot,
unsigned short frequency_search_range,
unsigned short nominal_central_frequency,
unsigned char roll_off_factor,
unsigned char viterbi_code_rate,
unsigned char vco_divider,
unsigned long vco_clk_by_main_div)
{
PHANTOM_LLF llf;
llf.op_code = PHANTOM_OPCODE_CHANGE_CHANNEL;
llf.data[0] = (unsigned char)((tuner_frequency >> 16) & 0x000000FF); /* 23:16 */
llf.data[1] = (unsigned char)((tuner_frequency >> 8) & 0x000000FF); /* 15:8 */
llf.data[2] = (unsigned char)(tuner_frequency & 0x000000FF); /* 7:0 */
llf.data[3] = (unsigned char)((nominal_symbol_rate >> 8) & 0x00FF); /* MSB */
llf.data[4] = (unsigned char)(nominal_symbol_rate & 0x00FF); /* LSB */
llf.data[5] = (unsigned char)((select_bin_mode & 0x03) | ((spectral_inversion << 0x02) & 0x0C)); /* SI[3:2], node[1:0] */
llf.data[6] = (unsigned char)((modcode & 0x3F) | (pilot << 0x06)); /* pilot[7:6], modcode[5:0] */
llf.data[7] = (unsigned char)((frequency_search_range >> 8) & 0x00FF); /* MSB */
llf.data[8] = (unsigned char)(frequency_search_range & 0x00FF); /* LSB */
llf.data[9] = (unsigned char)((nominal_central_frequency >> 8) & 0x00FF); /* MSB */
llf.data[10] = (unsigned char)(nominal_central_frequency & 0x00FF); /* LSB */
llf.data[11] = (unsigned char)(roll_off_factor & 0x03);
llf.data[12] = viterbi_code_rate;
llf.data[13] = vco_divider;
llf.data[14] = (unsigned char)((vco_clk_by_main_div >> 24) & 0x000000FF); /* 31:24 */
llf.data[15] = (unsigned char)((vco_clk_by_main_div >> 16) & 0x000000FF); /* 23:16 */
llf.data[16] = (unsigned char)((vco_clk_by_main_div >> 8) & 0x000000FF); /* 15:8 */
llf.data[17] = (unsigned char)(vco_clk_by_main_div & 0x000000FF); /* 7:0 */
llf.send_data_length = 18; /* Number of LLF arguments */
llf.received_data_length = 0; /* Number of return arguments */
/* reset the tuner handshake bit */
if (PHANTOM_DRIVER_ResetTunerHandshake(p_nim) == False)
{
return (False);
}
if (PHANTOM_ExecuteLLF(p_nim, &llf) == False) /* Send it to DPR */
{
return (False);
}
/* Wait until tuner is free */
if (PHANTOM_DRIVER_IsTunerI2CDone(p_nim) == False)
{
return (False);
}
return (True);
}
/*******************************************************************************************************
* Name: PHANTOM_LLF_MPEGConfig
*
* Description:
* This function will set the MPEG output configuration.
* Return Value:
* TRUE - operation successful; FALSE - otherwise
*
* I/O Parameters Descriptions
* IN PHANTOM_NIM* p_nim Pointer to PHANTOM_NIM structure allocated by application.
* IN unsigned char basic_settings [0]: 0 = serial; 1 = parallel.
* [1]: Gapped Mode (
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?