[an error occurred while processing this directive]
[an error occurred while processing this directive]
|
/*
* I2C functions for Fujitsu FFMC-16LX Softune C - master mode only
*//* 10100001 */
#define EEP_Addr_Rd 0xA1
/* 10100000 */
#define EEP_Addr_Wr 0xA0#define Delay_4us __wait_nop(); __wait_nop(); __wait_nop(); \
__wait_nop(); __wait_nop(); __wait_nop(); \
__wait_nop(); __wait_nop(); __wait_nop(); \
__wait_nop(); __wait_nop(); __wait_nop(); \
__wait_nop(); __wait_nop(); __wait_nop();
/* *********************************************************************
* Send stop condition
* - data low-high while clock high
*/void i2c_Int_Stop(void)
{
SDA_0;
Delay_4us;
SCL_1;
Delay_4us;
SDA_In;
}/* *************************************************************************
* Send start condition
* - ensure data is high then issue a start condition
*/void i2c_Int_Start(void)
{
SCL_1;
Delay_4us;
SDA_In;
Delay_4us;
SDA_0;
Delay_4us;
Delay_4us;
SCL_0;
}/* *******************************************************************
* Send a byte to the slave
* - returns true on error
*/void i2c_Int_SendByte(char DATA)
{
char i;for(i=0; i<8; i++) {
if (DATA & 0x80)
SDA_In;
else
SDA_0;
Delay_4us;
Delay_4us;
SCL_1;
Delay_4us;
DATA <<= 1;
SCL_0;
}// ACK ************************************
Delay_4us;
SDA_In;
Delay_4us;
Delay_4us;
SCL_1;
Delay_4us;
SCL_0;
}/* **************************************************************************
* Read a byte from the slave
* - returns the byte, or I2C_ERROR if a bus error
*/char i2c_Int_ReadByte(void)
{
char i, DATA;SDA_In;
DATA = 0;
Delay_4us;for(i=0; i<8; i++) {
SCL_1;
DATA <<= 1;
if (SDA_Pin) DATA |= 1;
SCL_0;
Delay_4us;
}return DATA;
}/* **************************************************************************
* ACK/NACK (after READ )
* - returns the byte, or I2C_ERROR if a bus error
*/void i2c_Int_ACK(void)
{
SDA_0;
Delay_4us;
SCL_1;
Delay_4us;
SCL_0;
}void i2c_Int_NACK(void)
{
SDA_In;
Delay_4us;
SCL_1;
Delay_4us;
SCL_0;
}
E-mail: info@telesys.ru