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_cancel
is set. In the latter case,i2c_cancel
is cleared. Returnsfalse
in case of bus contention, or ifneed_ack
was set and the transfer was not acknowledged,true
otherwise. TheBERR
bit in theI2CS
register should be checked iffalse
is returned.Note that
i2c_wait
is not meant to be used directly; it is documented to explain the behavior ofi2c_start
,i2c_write
andi2c_read
.
-
bool i2c_start(uint8_t chip)¶
This function generates a start condition and writes the address
chip
to the bus. Seei2c_wait
for description of return value.
-
bool i2c_stop()¶
This function generates a stop condition.
-
bool i2c_write(const uint8_t *buf, uint16_t len)¶
This function writes
len
bytes frombuf
to the I2C bus. Seei2c_wait
for description of return value.
-
bool i2c_read(uint8_t *buf, uint16_t len)¶
This function reads
len
bytes tobuf
from the I2C bus, responds with NAK to the last byte read, and generates a stop condition. Seei2c_wait
for description of return value.
Variables
-
bool i2c_cancel¶
A flag that terminates the current I2C transfer.