/*!
ZTEX Firmware Kit for EZ-USB FX2 Microcontrollers
Copyright (C) 2009-2014 ZTEX GmbH.
http://www.ztex.de
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see http://www.gnu.org/licenses/.
!*/
/*
EEPROM support an some I2C helper routines
*/
#ifndef[ZTEX_EEPROM_H]
#define[ZTEX_EEPROM_H]
#define[@CAPABILITY_EEPROM;]
#define[EEPROM_ADDR][0xA2]
/* *********************************************************************
***** global variables **********************************************
********************************************************************* */
__xdata WORD eeprom_addr;
__xdata WORD eeprom_write_bytes;
__xdata BYTE eeprom_write_checksum;
/* *********************************************************************
***** i2c_waitWrite *************************************************
********************************************************************* */
/* Do the necessary steps after writing I2DAT register. Returns 1 on error. */
BYTE i2c_waitWrite()
{
unsigned char i2csbuf,toc;
for ( toc=0; toc<255 && !(I2CS & bmBIT0); toc++ );
i2csbuf = I2CS;
if ( (i2csbuf & bmBIT2) || (!(i2csbuf & bmBIT1)) ) {
I2CS |= bmBIT6;
return 1;
}
return 0;
}
/* *********************************************************************
***** i2c_waitRead **************************************************
********************************************************************* */
/* Do the necessary steps after reading I2DAT register. Returns 1 on error. */
BYTE i2c_waitRead(void)
{
unsigned char i2csbuf, toc;
for ( toc=0; toc<255 && !(I2CS & bmBIT0); toc++ );
i2csbuf = I2CS;
if (i2csbuf & bmBIT2) {
I2CS |= bmBIT6;
return 1;
}
return 0;
}
/* *********************************************************************
***** i2c_waitStart *************************************************
********************************************************************* */
/* Do the necessary steps after start bit. Returns 1 on error. */
BYTE i2c_waitStart()
{
BYTE toc;
for ( toc=0; toc<255; toc++ ) {
if ( ! (I2CS & bmBIT2) )
return 0;
}
return 1;
}
/* *********************************************************************
***** i2c_waitStop **************************************************
********************************************************************* */
/* Do the necessary steps after stop bit. Returns 1 on error. */
BYTE i2c_waitStop()
{
BYTE toc;
for ( toc=0; toc<255; toc++ ) {
if ( ! (I2CS & bmBIT6) )
return 0;
}
return 1;
}
/* *********************************************************************
***** eeprom_select *************************************************
********************************************************************* */
/* Select the EEPROM device, i.e. send the control Byte.
diff -w -U 5 "/tmp/hSrBdo" ""
diff: : No such file or directory