csdsc10.c
来自「QPSK Tuner details, for conexant chipset」· C语言 代码 · 共 303 行
C
303 行
/*************************************************************************
* DiSEqC10.C *
* Copyright ? Shenzhen Coship Electronics Co.,LTD. 2002.3 *
* All rights reserved. *
* *
* Author: Zhou Cheng *
* Date: 2002/3/13 *
* Compiler: *
* *
* Description: DiSEqC1.0 命令 *
* DiSEqC10PowerOn , DiSEqC10SendSwitch *
* Notes: *
* Update: 2002/3/10 Zhou Cheng *
* 2002/3/14 Zhou Cheng *
*************************************************************************/
#include "cs_typedef.h"
#include "CSHDI_typedef.h"
#include "CSQpskCFG.h"
#include "cs_qpsk.h"
#include "cs_frnpublic.h"
#include "CSDSC10.h"
#include "AllCommand.h"
#define DiSEqC_ADDR 0xE0
#define DiSEqC10_SLAVEADDR 0x10
#define DiSEqC10_POWERON 0x03
#define DiSEqC10_PORTSWITCH 0x38
typedef enum
{
COMMITTEDSWITCHONLY,
UNCOMMITTEDSWITCHONLY,
DISEQC11BOTH,
CommitedAndToneBurst,
UnCommitedAndToneBurst,
CommitedAndUnCommited,
CommitedAndUnCommitedAndToneBurst
}DISEQC_SW;
/* +==========================================================================+ */
/* | DiSEqC 代码部分 | */
/* +==========================================================================+ */
/* +==========================================================================+ */
/* | Function: DiSEqC1.0 开关上电 只在上电时候调用一次 | */
/* +==========================================================================+ */
CSQPSK_Error_t CSDSC10PowerOn ( CSHDITunerIndex bTunerIndex )
{
BYTE bValue[4];
bValue[0] = DiSEqC_ADDR;
bValue[1] = DiSEqC10_SLAVEADDR;
bValue[2] = DiSEqC10_POWERON;
return ( CSDSCSendCommand ( bTunerIndex, bValue, 3 ) );
}
/* +==========================================================================+ */
/* | Function: 设置DiSEqC1.0开关\Tone Burst开关 | */
/* +==========================================================================+ */
CSQPSK_Error_t CSDSC10SendSwitch ( CSHDITunerIndex bTunerIndex,
BYTE bSwitchNo, // DiSEqC1.0开关 ( PORT_A / PORT_B / PORT_C / PORT_D )
BYTE bBand, // 波段 ( BAND_LOW / BAND_HIGH )
BYTE bPolarisation, // 极性 ( POLARISATION_V / POLARISATION_H )
BYTE bToneBurst, // Tone Burst开关 ( TONEBURST_NONE / TONEBURST_A / TONEBURST_B )
BYTE bRepeatTime // 重复次数 ( NoRepeat / OnceRepeat / TwiceRepeat )
)
{
BYTE bSwitchByte;
BYTE bSwitch;
//USPPrint(3, "bSwitchNo = %d, bToneBurst =%d", bSwitchNo, bToneBurst);
switch (bSwitchNo)
{
case DISEQC10_OFF:
return CSQPSK_SUCCESS ;
case PORT_4_A:
bSwitch = 0 ;
break;
case PORT_4_B:
bSwitch = 1 ;
break;
case PORT_4_C:
bSwitch = 2 ;
break;
case PORT_4_D:
bSwitch = 3 ;
break;
case PORT_2_A:
bSwitch = 0 ;
break;
case PORT_2_B:
bSwitch = 3 ;
break;
}
bSwitchByte = 0xF0 | ( bSwitch << 2 ) | ( ((bPolarisation+1)%2) << 1 ) | ( bBand );
return ( CSDSCSend10Command ( bTunerIndex, 0, bSwitchByte, bToneBurst, bRepeatTime ) );
}
/* +==========================================================================+ */
/* | Function: 设置DiSEqC1.1开关\Tone Burst开关 级联 | */
/* +==========================================================================+ */
CSQPSK_Error_t CSDSC11SendSwitch ( CSHDITunerIndex bTunerIndex,
BYTE bCommittedSwitch,
BYTE bUncommittedSwitch,
BYTE bBand, // 波段 ( BAND_LOW / BAND_HIGH )
BYTE bPolarisation, // 极性 ( POLARISATION_V / POLARISATION_H )
BYTE bToneBurst, // Tone Burst开关 ( TONEBURST_NONE / TONEBURST_A / TONEBURST_B )
BYTE bRepeatTime, // 重复次数 ( NoRepeat / OnceRepeat / TwiceRepeat )
BYTE OptionSwitch)
{
BYTE bSwitch;
BYTE bCommittedSwitchByte;
BYTE bUnCommittedSwitchByte;
//USPPrint(3, "bCommittedSwitch = %d, bUncommittedSwitch = %d, bToneBurst = %d, bRepeatTime = %d\r\n", bCommittedSwitch, bUncommittedSwitch, bToneBurst, bRepeatTime);
//SFG BYTE bSwitchType = DISEQC11BOTH;
DISEQC_SW bSwitchType = DISEQC11BOTH;
int ii;
for (ii = 0; ii <= bRepeatTime; ii++)
{
if ((1 == OptionSwitch) ||(2 == OptionSwitch))
{
CSDSCSendOptionCmd( bTunerIndex, OptionSwitch);
}
if ((bCommittedSwitch >= 1) && (bCommittedSwitch <= 4))
{
bCommittedSwitchByte = 0xF0 | ( (bCommittedSwitch -1) << 2 ) | ( ((bPolarisation+1)%2) << 1 ) | ( bBand );
CSDSCSend10Command (bTunerIndex, 0, bCommittedSwitchByte, 0, 0);
}
if ((bUncommittedSwitch >= 1) && (bUncommittedSwitch <= 16))
{
bUnCommittedSwitchByte = 0xF0 | (bUncommittedSwitch - 1);
CSDSCSend11Command (bTunerIndex, 0, bUnCommittedSwitchByte, 0);
}
if ((1 == bToneBurst) || (2 == bToneBurst))
{
CSSendToneBurstCommand(bTunerIndex, bToneBurst);
}
}
#if 0
if(((DISEQC10_OFF >= bCommittedSwitch) || (bCommittedSwitch > PORT_4_D))
&& ((bUncommittedSwitch < 1) || (bUncommittedSwitch > 16))
&& ((1 != bToneBurst) && (2 != bToneBurst))
&& ((1 != OptionSwitch) && (2 != OptionSwitch)))
{
USPPrint(3, "1111111111111\r\n");/*ok*/
return CSQPSK_SUCCESS;
}
else if(((DISEQC10_OFF >= bCommittedSwitch) || (bCommittedSwitch > PORT_4_D))
&& ((1 > bUncommittedSwitch) || (bUncommittedSwitch > 16))
&& ((1 != OptionSwitch) && (2 != OptionSwitch))
&& ((1 == bToneBurst) || (2 == bToneBurst)))
{
USPPrint(3, "22222222222222\r\n");/*ok*/
return (CSSendToneBurstCommand(bTunerIndex, bToneBurst));/*只有ToneBurst 有效*/
}
else if (((DISEQC10_OFF >= bCommittedSwitch) || (bCommittedSwitch > PORT_4_D))
&& ((1 != bToneBurst) && (2 != bToneBurst))
&& ((1 != OptionSwitch) && (2 != OptionSwitch))
&& ((bUncommittedSwitch >= 1) && (bUncommittedSwitch <= 16))) /*1.1 有效*/
{
USPPrint(3, "3333333333333333\r\n");/*ok*/
bUnCommittedSwitchByte = 0xF0 | (bUncommittedSwitch - 1);
//CSDSCSend10Command (bTunerIndex, UNCOMMITTEDSWITCHONLY, bCommittedSwitchByte, bToneBurst, bRepeatTime);
//CSDSCSendOptionCmd( bTunerIndex, OptionSwitch);
CSDSCSend11Command (bTunerIndex, 0, bUnCommittedSwitchByte, bRepeatTime);
}
else if (/*1.0 有效*/
((bUncommittedSwitch < 1) || (bUncommittedSwitch > 16))
&& ((1 != bToneBurst) && (2 != bToneBurst))
&& ((1 != OptionSwitch) && (2 != OptionSwitch))
&& ((DISEQC10_OFF < bCommittedSwitch) || (bCommittedSwitch <= PORT_4_D)))
{
USPPrint(3, "444444444444444\r\n");/*ok*/
bCommittedSwitchByte = 0xF0 | ( (bCommittedSwitch -1) << 2 ) | ( ((bPolarisation+1)%2) << 1 ) | ( bBand );
//CSDSCSendOptionCmd( bTunerIndex, OptionSwitch);
CSDSCSend10Command (bTunerIndex, 0, bCommittedSwitchByte, 0, bRepeatTime);
}
else if (((DISEQC10_OFF >= bCommittedSwitch) || (bCommittedSwitch > PORT_4_D))/*只有option 有效*/
&& ((bUncommittedSwitch < 1) || (bUncommittedSwitch > 16))
&& ((1 != bToneBurst) && (2 != bToneBurst))
&& ((1 == OptionSwitch) || (2 == OptionSwitch)))
{
CSDSCSendOptionCmd( bTunerIndex, OptionSwitch);
}
/*因为由于上层1.0和Toneburst 不能同时存在*/
else if (((DISEQC10_OFF < bCommittedSwitch) || (bCommittedSwitch <= PORT_4_D))
&& ((bUncommittedSwitch < 1) || (bUncommittedSwitch > 16)) /*1.0 ,toneburst有效*/
&& ((1 == bToneBurst) || (2 == bToneBurst)))
{
USPPrint(3, "55555555555555555\r\n");
bCommittedSwitchByte = 0xF0 | ( (bCommittedSwitch -1) << 2 ) | ( ((bPolarisation+1)%2) << 1 ) | ( bBand );
for (ii = 0; ii <= bRepeatTime; ii++)
{
CSDSCSendOptionCmd( bTunerIndex, OptionSwitch);
CSDSCSend10Command (bTunerIndex, 0, bCommittedSwitchByte, 0, 0);
CSSendToneBurstCommand(bTunerIndex, bToneBurst);
}
}
else if (((DISEQC10_OFF >= bCommittedSwitch) || (bCommittedSwitch > PORT_4_D))
&& ((bUncommittedSwitch >= 1) || (bUncommittedSwitch <= 16)) /*1.1 ,toneburst有效*/
&& ((1 == bToneBurst) || (2 == bToneBurst)))
{
USPPrint(3, "66666666666666666\r\n");/*ok*/
bUnCommittedSwitchByte = 0xF0 | (bUncommittedSwitch - 1);
for (ii = 0; ii <= bRepeatTime; ii++)
{
CSDSCSendOptionCmd( bTunerIndex, OptionSwitch);
CSDSCSend11Command (bTunerIndex, 0, bUnCommittedSwitchByte, 0);
CSSendToneBurstCommand(bTunerIndex, bToneBurst);
}
}
/*!!!!!!!!!!!!!!!!!!!实验证明1.0和1.1 无法共存将会互相影?!!!!!!!!!!!!!!!!!!!!!!!!?/
else if (((DISEQC10_OFF < bCommittedSwitch) || (bCommittedSwitch <= PORT_4_D))
&& ((bUncommittedSwitch >= 1) || (bUncommittedSwitch <= 16)) /*1.0 ,1.1有效*/
&& ((1 != bToneBurst) && (2 != bToneBurst)))
{
USPPrint(3, "77777777777777777\r\n");/*ok*/
bCommittedSwitchByte = 0xF0 | ( (bCommittedSwitch -1) << 2 ) | ( ((bPolarisation+1)%2) << 1 ) | ( bBand );
bUnCommittedSwitchByte = 0xF0 | (bUncommittedSwitch - 1);
for (ii = 0; ii <= bRepeatTime; ii++)
{
CSDSCSendOptionCmd( bTunerIndex, OptionSwitch);
CSDSCSend10Command (bTunerIndex, 0, bCommittedSwitchByte, 0, 0);
CSDSCSend11Command (bTunerIndex, 0, bUnCommittedSwitchByte, 0);
}
}
#if 0/*三者不可能同时存在,因为由于上层1.0和Toneburst 不能同时存在*/
else if (((DISEQC10_OFF >= bCommittedSwitch) || (bCommittedSwitch > PORT_4_D))
&& ((bUncommittedSwitch >= 1) || (bUncommittedSwitch <= 16)) /*1.0 ,1.1,toneburst都有效*/
&& ((1 == bToneBurst) || (2 == bToneBurst)))
{
}
#endif
#endif
/*
switch (bCommittedSwitch)
{
case DISEQC10_OFF:
bSwitchType = UNCOMMITTEDSWITCHONLY;
case PORT_4_A:
bSwitch = 0 ;
break;
case PORT_4_B:
bSwitch = 1 ;
break;
case PORT_4_C:
bSwitch = 2 ;
break;
case PORT_4_D:
bSwitch = 3 ;
break;
case PORT_2_A:
bSwitch = 0 ;
break;
case PORT_2_B:
bSwitch = 3 ;
break;
}
bCommittedSwitchByte = 0xF0 | ( bSwitch << 2 ) | ( ((bPolarisation+1)%2) << 1 ) | ( bBand );
if((0 == bUncommittedSwitch) || (bUncommittedSwitch > 16))
bSwitchType = COMMITTEDSWITCHONLY;
else
bUnCommittedSwitchByte = 0xF0 | (bUncommittedSwitch - 1);
if(COMMITTEDSWITCHONLY == bSwitchType)
return ( CSDSCSend10Command ( bTunerIndex, 0, bCommittedSwitchByte, bToneBurst, bRepeatTime ) );
else if (UNCOMMITTEDSWITCHONLY == bSwitchType)
return ( CSDSCSend10Command ( bTunerIndex, 1, bUnCommittedSwitchByte, bToneBurst, bRepeatTime ) );
else
return (CSDSCSend11Command ( bTunerIndex, bCommittedSwitchByte, bUnCommittedSwitchByte, bRepeatTime ));*/
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?