binary Clock
|
High level I2C functions to interface with an I2C driver. More...
Macros | |
#define | WRITE_MASK 0x00 |
Mask for writing to a chip. More... | |
#define | READ_MASK 0x01 |
Mask for reading from a chip. More... | |
Functions | |
retval_t | i2c_init (void) |
retval_t | i2c_write_byte (uint8_t chip_addr, uint8_t reg_addr, uint8_t data) |
retval_t | i2c_write (uint8_t chip_addr, uint8_t start_adr, uint8_t *data_to_write_ptr, uint8_t data_len) |
retval_t | i2c_read_byte (uint8_t chip_addr, uint8_t start_adr, uint8_t *data_out_ptr) |
retval_t | i2c_read (uint8_t chip_addr, uint8_t start_adr, uint8_t *data_out_ptr, uint8_t data_len) |
High level I2C functions to interface with an I2C driver.
#define READ_MASK 0x01 |
Mask for reading from a chip.
#define WRITE_MASK 0x00 |
Mask for writing to a chip.
retval_t i2c_init | ( | void | ) |
Initializes the I2C driver.
[out] | retval | (retval_t): Returns the initialization status of the I2C driver. |
retval_t i2c_read | ( | uint8_t | chip_addr, |
uint8_t | start_adr, | ||
uint8_t * | data_out_ptr, | ||
uint8_t | data_len | ||
) |
Reads N bytes from a chip. Handles starting and stopping of communication.
[in] | chip_addr | (uint8_t): The address of the chip to be read from. |
[in] | start_adr | (uint8_t): The starting register of the read. |
[in] | data_out_ptr | (uint8_t *): Location to store the read values. |
[in] | data_len | (uint8_t): amount of bytes to read. |
[out] | retval | (retval_t): Returns the success or failure of starting communication & reading the byte. |
retval_t i2c_read_byte | ( | uint8_t | chip_addr, |
uint8_t | start_adr, | ||
uint8_t * | data_out_ptr | ||
) |
Reads a byte from a chip. Handles starting and stopping of communication.
[in] | chip_addr | (uint8_t): The address of the chip to be read from. |
[in] | start_adr | (uint8_t): The starting register of the read. |
[in] | data_out_ptr | (uint8_t *): Location to store the read value. |
[out] | retval | (retval_t): Returns the success or failure of starting communication & reading the byte. |
retval_t i2c_write | ( | uint8_t | chip_addr, |
uint8_t | start_adr, | ||
uint8_t * | data_to_write_ptr, | ||
uint8_t | data_len | ||
) |
Starts communication with a chip and writes N bytes to the chip. Handles starting and ending communication as well.
[in] | chip_addr | (uint8_t): The address of the chip to be written to. |
[in] | start_adr | (uint8_t): The starting register of the write. |
[in] | data_to_write_ptr | (uint8_t *): The data to be written array. |
[in] | data_len | (uint8_t): How many bytes to be written. |
[out] | retval | (retval_t): Returns the success or failure of starting communication and writing to the device. |
retval_t i2c_write_byte | ( | uint8_t | chip_addr, |
uint8_t | reg_addr, | ||
uint8_t | data | ||
) |
Writes a byte to a chip. Handles starting and stopping of communication.
[in] | chip_addr | (uint8_t): The chip's address without the read/write bit set. |
[in] | reg_addr | (uint8_t): Address of the register you want to write to. |
[in] | data | (uint8_t): Data you want to write. |
[out] | retval | (retval_t): Returns the success or failure of starting communication & sending the byte. |