?? ver8f0.c
字號:
/*
version1.8-> 2.5
new function ( Copy please )
int CheckInversion() : Checking I/Q Inverse or Not
void Acquisition(float _Freq1, U32 _SymbolRate,
S32 _QAMSize, FLAG _SpectrumInversion)
: Simple Final Command include AutoSpectral Inversion
void Check_Version() : Checking I2C Read or IC version.
modify program ( replace oldversion of newversion )
FLAG ROUTINE Driv0297CarrierSearch(SIGNAL *_pSignal, FLAG _SpectrumInversion,
S32 _SweepRate, S32 _CarrierOffset)
FLAG ROUTINE Driv0297DataSearch(SIGNAL *_pSignal, S32 _SweepRate, S32 _CarrierOffset,
FLAG _SpectrumInversion, S32 _InitDemodOffset)
read version
read noise level
VERSION 2.5-> 3.0
abstract : Fast Acquisition.
Adding Function : QAM_Init()
: Check_Lock()
delete function RegSetRegister()
RegGetRegister()
RegTriggerOn(void)
RegTriggerOff(void)
RegGetTrigger(void)
RegSetTrigger(FLAG _Trigger)
VERSION 3.0->3.2
BER function insert without R/S
double BlocksBertBER ;
double BlocksBERTSaturation ;
void BertSaturationComputation(double _BERIndicator);
double BertCount(int _ErrMode) ;
function void SetSerialParallel(int _OutMode); : 1 parallel, 0 serial
QAM128,QAM16 fast acquisition(), Driv0297CarrierSearch() are modified.
delete NTSC PAL select.
delete function QAM256_Init()
version 3.2-> 3.4
Acquisition();
RegSetOneRegister(WBAGC_11,0xFE) ;
RegSetOneRegister(WBAGC_11,0xFF) ;
revision 256QAM -> SR 6.5Msps
Driv0297CarrierSearch(&MySignal,_SpectrumInversion,1000,-100);
->Driv0297CarrierSearch(&MySignal,_SpectrumInversion,1200,-200);
version 3.4-> 3.5
Write & Read function adding.
Acquisition function change parameter for low symbol rate.
The customer which has used version3.4 recopy the Acquisition() function.
version 3.6
Adding Display function
void Show_Brief();
void Dump(float _Freq1, U32 _SymbolRate, S32 _QAMSize, FLAG _SpectrumInversion);
void Menu();
void Procedure();
adding Checking lock();
version 3.7b
kill flow Equalizer part Driv0297DataSearch-> see ver 3.7b
change parameter acquisition part
version 3.7c
This probram is copy of My desktop computer c:temp\autotestver3p7
it's only copy of Acquisition function
version 3.8
editing for 32QAM Low symbol 1Msps
256QAM Low symbol 1Msps
QAM64_REG CHANGE
adding auto define to fast acquisition.
version 4.0
Find bug QAM256 Lowsymbolrate case...
version 4.1
To get the faster acquisition.
Modify Time access velocity
to search type ver4p1
*/
#include "scr8f0.h"
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#define Mybug 1
#define NTSC 0 /* If PAL : 0 */
/* S32 I2cTempoValue = 50; */
void I2cTempo(void)
{
U32 i;
for ( i=0 ; i<I2cTempoValue ;i++ );
}
void I2cSetSDA(S32 level)
{
outportb(prnDataAddress,(level==0) ? SDALOW : SDAHIGH);
}
U8 I2cGetSDA(void)
{
return (inportb(prnStatusAddress) & SDALOW)==0 ? 0 : 1;
}
void I2cSetSCL(S32 level)
{
outportb(prnControlAddress,level==0 ? SCLLOW : SCLHIGH);
I2cTempo();
}
U8 I2cGetSCL(void)
{
return (inportb(prnStatusAddress) & SCLHIGH)==0 ? 0 : 1;
}
void I2cSetAck(S32 level)
{
if(level)
I2cSetSDA(HIGH);
else
I2cSetSDA(LOW);
I2cSetSCL(HIGH);
I2cSetSCL(LOW);
}
U8 I2cGetAck()
{
S32 val;
I2cSetSCL(HIGH);
val = !(ACK & I2cGetSDA());
I2cSetSCL(LOW);
return val;
}
void I2cWriteBit(S32 level)
{
I2cSetSDA(level);
I2cSetSCL(HIGH);
I2cSetSCL(LOW);
}
U8 I2cReadBit(void)
{
U8 bit;
I2cSetSCL(HIGH);
bit=I2cGetSDA();
I2cSetSCL(LOW);
return bit;
}
void I2cStart (void)
{
I2cSetSDA(HIGH);
I2cSetSCL(HIGH);
I2cSetSDA(LOW);
I2cSetSCL(LOW);
}
void I2cStop (void)
{
I2cSetSDA(LOW);
I2cSetSCL(HIGH);
I2cSetSDA(HIGH);
}
/*
FUNCTION :: I2cGetStatus
ACTION :: Get the status of the I2C bus
PARAMS IN :: NONE
PARAMS OUT:: NONE
RETURN :: ACK SCL SDA =b111=0x7
*/
S32 I2cGetStatus(void)
{
if(I2cGetSDA())
I2cStatus |= SDA;
else
I2cStatus &= ~SDA;
if(I2cGetSCL())
I2cStatus |= SCL;
else
I2cStatus &= ~SCL;
return(I2cStatus) ;
}
void I2cSetStatus(S32 _Status)
{
I2cStatus = _Status ;
}
void I2cInit(S32 tempo)
{
I2cPPortAddress = 0x378 ;
prnDataAddress = 0x378;
prnStatusAddress = I2cPPortAddress + 1 ;
prnControlAddress = I2cPPortAddress +2 ;
I2cSTVAddress = 0x38 ;
I2cStatus = 0x07 ;
NbI2CAccess = 0 ;
I2cTempoValue = tempo;
}
/*
FUNCTION :: I2cWriteByte
ACTION :: Send a byte to the slave
PARAMS IN :: data -> the byte to be send
PARAMS OUT:: NONE
RETURN :: NONE
*/
void I2cWriteByte(U8 data )
{
U8 i;
/* Write 8 bits Data */
for (i=0 ;i<8 ;i++)
I2cWriteBit((data<<i) & 0x80);
}
/*
FUNCTION :: I2cReadByte
ACTION :: Read a byte from the slave
PARAMS IN :: NONE
PARAMS OUT:: NONE
RETURN :: if error -1 else byte read
*/
U8 I2cReadByte(void)
{
S8 i, valRet=0;
/* Read 8 bits data */
I2cSetSDA(HIGH); /*SDA must be set HIGH, because the slave just pull down the line*/
for(i=7 ;i>=0 ;i--)
valRet = valRet | (I2cReadBit()<<i);
return valRet;
}
/*
FUNCTION :: I2cWriteNBytes
ACTION :: Send N bytes to the slave
PARAMS IN :: NbBytes -> Number of byte to send
data -> bytes to be send
PARAMS OUT:: NONE
RETURN :: NONE
*/
void I2cWriteNBytes(S32 NbBytes, U8 *data)
{
U8 b,B;
/* Write N bits Data */
for (B=0; B<NbBytes; B++)
for (b=0; b<8; b++)
I2cWriteBit((data[B]<<b) & 0x80);
}
/*
FUNCTION :: I2cReadNBytes
ACTION :: Read N bytes from the slave
PARAMS IN :: NbBytes -> Number of bytes to read
PARAMS OUT:: NONE
RETURN :: NONE
*/
void I2cReadNBytes(S32 NbBytes, U8 *data)
{
U8 b,B;
/* Read 8 bits data */
I2cSetSDA(HIGH); /*SDA must be set HIGH, because the slave just pull down the line */
for (B=0; B<NbBytes; B++)
for (b=0; b<8; b++)
data[B] = data[B] | (I2cReadBit()<<b);
}
/*
FUNCTION :: I2cReadWrite
ACTION :: Read/write data from/to the slave
PARAMS IN :: mode -> READ or WRITE
ChipAddress -> I2C address of the chip
Data -> Buffer containing data to send
NbData -> Number of data to write/read
PARAMS OUT:: Data -> Buffer containing data received
RETURN :: if error -1 else communication state
*/
S32 I2cReadWrite(S32 mode,U8 ChipAddress,U8 *Data,S32 NbData)
{
S8 i=0,ack;
I2cStart(); /*Start the I2C sequence*/
I2cWriteByte(ChipAddress+(mode==READ)); /*Send Slave chip address*/
ack=I2cGetAck(); /*Read Acknowledge bit*/
while((i<NbData) && ack)
{
if(mode==READ)
{
Data[i]=I2cReadByte(); /*Read data from the slave*/
I2cSetAck(i==(NbData-1)); /*Write Acknowledge bit*/
}
else
{
I2cWriteByte(Data[i]); /*Write data to the salve */
ack=I2cGetAck(); /*Read Acknowledge bit*/
}
i++;
}
if(!ack)
{
if(mode==READ)
for(i=0;i<NbData;i++)
Data[i]=-1;
return (-1);
}
I2cStop(); /*Stop the I2C sequence*/
return 0;
}
/*#include "reg0297.h"
***AddReg ************************************************************/
/* Add a new register to the register map */
void AddReg(S32 Id,S8 * Name,S8 Address,S8 Reset)
{
REGISTER *pReg;
pReg=&RegMap[Id];
pReg->Addr = Address;
pReg->Reset = Reset;
pReg->Value = 0x00;
strcpy(pReg->Name,Name);
}
/******** FieldCreateMask ****************************************************/
/* Create the mask of the field according the informations store in the */
/* FIELD structure */
/*****************************************************************************/
U8 FieldCreateMask(S32 field)
{
S32 i;
U8 mask=0;
/*Create mask*/
for (i = 0; i < FieldMap[field].Bits; i++)
{
mask <<= 1 ;
mask += 1 ;
}
mask = mask << FieldMap[field].Pos;
return mask;
}
/******** AddField **********************************************************/
/* Add a field to the field map */
/*****************************************************************************/
void AddField(S32 RegId, S32 FieldId,S8 * Name, S8 Pos, S8 NbBits, S8 Type)
{
FIELD *pField;
pField=&FieldMap[FieldId];
strcpy(pField->Name,Name);
pField->Reg= RegId;
pField->Pos= Pos;
pField->Bits= NbBits;
pField->Type= Type;
pField->Mask= FieldCreateMask(FieldId);
}
/******** RegSetOneRegister **************************************************/
/* Set Register value */
/* INPUT : data, register id */
/*****************************************************************************/
void RegSetOneRegister(S32 reg_id, U8 Data)
{
U8 data[2],UCtmp=-1,ChipAddress;
ChipAddress=0x38;
data[0]=RegMap[reg_id].Addr;
data[1]=Data;
UCtmp=I2cReadWrite(WRITE,ChipAddress,data,2);
RegNbI2cAccess += 1;
RegMap[reg_id].Value=Data;
return ;
}
/******** RegGetOneRegister **************************************************/
/* Get Register value */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -