fx2i2c.h
The fx2i2c.h header contains I2C and EEPROM routines for the Cypress FX2 series. When using this header, the fx2 library must be linked in.
Reference
Functions
-
bool i2c_wait(bool need_ack)
This function waits until the current I2C transfer terminates, or until
i2c_cancelis set. In the latter case,i2c_cancelis cleared. Returnsfalsein case of bus contention, or ifneed_ackwas set and the transfer was not acknowledged,trueotherwise. TheBERRbit in theI2CSregister should be checked iffalseis returned.Note that
i2c_waitis not meant to be used directly; it is documented to explain the behavior ofi2c_start,i2c_writeandi2c_read.
-
bool i2c_start(uint8_t chip)
This function generates a start condition and writes the address
chipto the bus. Seei2c_waitfor description of return value.
-
bool i2c_stop(void)
This function generates a stop condition.
-
bool i2c_write(const uint8_t *buf, uint16_t len)
This function writes
lenbytes frombufto the I2C bus. Seei2c_waitfor description of return value.
-
bool i2c_read(uint8_t *buf, uint16_t len)
This function reads
lenbytes tobuffrom the I2C bus, responds with NAK to the last byte read, and generates a stop condition. Seei2c_waitfor description of return value.
Variables
-
volatile bool i2c_cancel
A flag that terminates the current I2C transfer.