You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
751 B

#ifndef I2C_SIMPLE_H
#define I2C_SIMPLE_H
/* initializes i2c interface (master, 400kHz) */
void i2c_init();
/* reads len bytes from the i2c device addr into data */
/* returns the number of bytes read */
uint8_t i2c_read(uint8_t addr, uint8_t len, uint8_t *data);
/* writes to an i2c device */
/* returns the number of bytes written. if abitration was lost within a byte or it was followed by a NAK that byte is NOT counted */
uint8_t i2c_write(uint8_t addr, uint8_t len, uint8_t *data);
/* writes, followed by a repeated start and a read */
/* returns the number of bytes read. if 0 is returned the write might have failed */
uint8_t i2c_write_read(uint8_t addr, uint8_t writelen, uint8_t *writedata, uint8_t readlen, uint8_t *readdata);
#endif