📄 systemfunc.c
字号:
/*****************************************************************************
*
* File : SystemFunc.h
* ----
*
* Copyright Statement :
* ------------------
* Copyright (c) Philips Semiconductor Rennes 2001
*
* This software is protected by Copyright and the information contained herein
* is confidential. The software may not be copied and information contained
* herein may not be used or disclosed except with the written permission of
* comatlas SA.
*
*
* Project : Front-end
* -------
*
* Description :
* -----------
*
*
* Version : 1.0
* -------
*
* Modification History :
* --------------------
*
* Date Version Author Details
* ---- ------- ------ -------
* 16/03/01 1.0 XR creation
*
******************************************************************************
*/
#include "tmtypes.h"
#include "SystemFunc.h"
#include "Z_os_api.h"
#include "Gpio.h"
#include "i2c.h"
#include "Globals.h"
static UInt8 Buffer[256];
/*====================================Useless for stb=============================================*/
Bool SY_OpenCom(void)
{
return True;
}
Bool SY_CloseCom(void)
{
return True;
}
UInt8 SY_SetComConfig(I2C_Conf_T cfg)
{
return True;
}
void SY_GetComConfig(I2C_Conf_T *cfg)
{
return;
}
UInt32 SY_GetComError(void)
{
return 0;
}
/*====================================Necessary for stb=============================================*/
Bool SY_WriteDemod(UInt32 uHwAddress, UInt32 uIndex, UInt32 uNBytes, UInt32 *puData)
{
UInt32 cnt;
//dbprintf(("SY_WriteDemod(): [0x%x][0x%x] ::::%dbytes, 0x%x\n",uHwAddress,uIndex,uNBytes,*puData));
Buffer[0] = (UInt8)uIndex;
#if 1
for(cnt=0;cnt<uNBytes;cnt++)
{
Buffer[1] = (UInt8)puData[cnt];
//dbprintf(("SY_WriteDemod() : index is 0x%02X,value is 0x%02X\n",Buffer[0],Buffer[1]));
if(I2C_Write(I2C1_SCL, I2C1_SDA, uHwAddress,Buffer,2) != 2)
{
dbprintf(("Error!!!\n"));
return False;
}
Buffer[0]++;
}
#else
for(cnt =0;cnt<uNBytes;cnt++)
Buffer[cnt+1] = (UInt8)puData[cnt];
dbprintf(("----------------------\n"));
for(cnt =0;cnt<(uNBytes+1);cnt++)
{
dbprintf(("SY_WriteDemod(): write data %d :::: 0x%x\n",cnt, Buffer[cnt]));
}
dbprintf(("-----------------------\n"));
if(I2C_Write(I2C1_SCL, I2C1_SDA, uHwAddress,Buffer,uNBytes+1) != (uNBytes+1))
{
return False;
}
#endif
return True;
}
Bool SY_WriteBitDemod(UInt32 uHwAddress, UInt32 uIndex, UInt32 uMask, UInt32 uData)
{
UInt32 val;
if (SY_ReadDemod(uHwAddress,uIndex,1,&val) != True) return False;
val &=~uMask;
val |=(uData&uMask);
if (SY_WriteDemod(uHwAddress, uIndex, 1,&val) != True) return False;
return True;
}
Bool SY_ReadDemod(UInt32 uHwAddress, UInt32 uIndex, UInt32 uNBytes, UInt32 *puData)
{
UInt32 cnt;
UInt8 addr;
addr = (UInt8)uIndex;
//dbprintf(("SY_ReadDemod() : index is 0x%02X,uNBytes is %02d\n",uIndex,uNBytes));
if (I2C_Write(I2C1_SCL, I2C1_SDA, uHwAddress,(UInt8*)&addr,1) != 1)
return False;
if (I2C_Read(I2C1_SCL, I2C1_SDA, uHwAddress,(UInt8*)Buffer,uNBytes) != uNBytes)
return False;
for(cnt=0;cnt<uNBytes;cnt++)
puData[cnt] = (UInt32)Buffer[cnt];
return True;
}
Bool SY_WriteTuner(UInt32 uHwAddress, UInt32 uIndex, UInt32 uNBytes, UInt32 *puData)
{
UInt32 cnt;
//dbprintf(("SY_WriteTuner(): \n start 0x%x,\n Index 0x%x,\n Bytes 0x%x\n",
// uHwAddress,uIndex,uNBytes));
for(cnt=0;cnt<uNBytes;cnt++){
Buffer[cnt]=(UInt8)(puData[cnt]);
// dbprintf(("Data[%02d] = 0x%x\n", cnt,Buffer[cnt]));
}
if (I2C_Write(I2C1_SCL, I2C1_SDA, uHwAddress,(UInt8*)Buffer,uNBytes) != uNBytes)
{
dbprintf(("Error!!!\n "));
return False;
}
//dbprintf(("Successfully!!!\n"));
return True;
}
Bool SY_WriteBitTuner(UInt32 uHwAddress, UInt32 uIndex, UInt32 uMask, UInt32 uData)
{
return True;
}
Bool SY_ReadTuner(UInt32 uHwAddress, UInt32 uIndex, UInt32 uNBytes, UInt32 *puData)
{
UInt32 cnt;
//dbprintf(("SY_ReadTuner(): \n start 0x%x,\n Index 0x%x,\n Bytes 0x%x\n",
// uHwAddress,uIndex,uNBytes));
printf("here1000\n");
if (I2C_Read(I2C1_SCL, I2C1_SDA, uHwAddress,(UInt8*)Buffer,uNBytes) != uNBytes)
{
dbprintf(("Error!!!\n"));
return False;
}
printf("here1001\n");
//dbprintf(("Successfully!!!\n", uHwAddress));
for(cnt=0;cnt<uNBytes;cnt++)
puData[cnt]=(UInt32)Buffer[cnt];
return True;
}
UInt32 SY_GetTickTime(void)
{
return OS_Retrieve_Clock();
}
UInt32 SY_GetTickPeriod(void)
{
return 10; /*10ms*/
}
/*====================================Useless for stb=============================================*/
Bool SY_WriteEeprom(UInt32 uHwAddress, UInt32 uIndex, UInt32 uNBytes, UInt32 *puData)
{
return True;
}
Bool SY_WriteBitEeprom(UInt32 uHwAddress, UInt32 uIndex, UInt32 uMask, UInt32 uData)
{
return True;
}
Bool SY_ReadEeprom(UInt32 uHwAddress, UInt32 uIndex, UInt32 uNBytes, UInt32 *puData)
{
return True;
}
void IIC_Start(void)
{
return;
}
void IIC_Stop(void)
{
return;
}
UInt8 IIC_WriteByte(UInt8 bBytes)
{
return 0;
}
UInt8 IIC_ReadByte (UInt8* pbData)
{
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -