?? ti2cmid2.c.svn-base
字號:
/**
* This code and information is part of Trident DPTV API (TDAPI)
*
* Copyright (C) Trident Multimedia Technologies (Shanghai) Co., Ltd.
* 2004 All rights reserved.
*
* This file contains Middle Level I2C Routines
*
* Revision:
* 11/09/2004 Created by Archie
*
*/
#include "tdefs.h"
#include "ti2c.h"
#define _DECLARE_FASTI2C_
#include "tfasti2c.h"
#define _TRY_TIMES_ 5
Byte tdFastI2CReadByte(Byte ucSlaveAddr, Byte ucSubAddr)
{
IByte ucTryTimes = _TRY_TIMES_;
IByte ucData;
#ifdef _USE_SECOND_CC_
tdEnableI2CFlag(_I2C_BUSY_);
#endif
while (ucTryTimes--)
{
tdStart();
if(tdI2CSendByte((Byte)(ucSlaveAddr & 0xfe)) && tdI2CSendByte(ucSubAddr))
{
tdStart();
if(tdI2CSendByte((Byte)(ucSlaveAddr | 0x01)))
{
ucData = tdI2CReceiveByte();
/*send No ACK*/
tdNOACK();
tdStop();
break; /* OK, return */
}
}
tdStop();
/* WRONG, try again */
}
#ifdef _USE_SECOND_CC_
tdDisableI2CFlag(_I2C_BUSY_);
#endif
return ucData;
}
Void tdFastI2CWriteByte(Byte ucSlaveAddr, Byte ucSubAddr, Byte ucData)
{
IByte ucTryTimes = _TRY_TIMES_;
#ifdef _USE_SECOND_CC_
tdEnableI2CFlag(_I2C_BUSY_);
#endif
while (ucTryTimes--)
{
tdStart();
if(tdI2CSendByte((Byte)(ucSlaveAddr & 0xfe)) && tdI2CSendByte(ucSubAddr)
&& tdI2CSendByte(ucData))
{
tdStop();
break; /* OK, return */
}
tdStop();
/* WRONG, try again */
}
#ifdef _USE_SECOND_CC_
tdDisableI2CFlag(_I2C_BUSY_);
#endif
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -