AVR library
i2c.h
1 #ifndef MAT_I2C_H
2 #define MAT_I2C_H
3 
4 #include <inttypes.h>
5 
6 #if F_CPU == 8000000
7  #define I2C_100K 32
8  #define I2C_50K 72
9 #endif
10 
11 #if F_CPU == 16000000
12  #define I2C_100K 72
13 #endif
14 
15 void i2c_init(uint8_t br);
16 uint8_t i2c_readbuf(const uint8_t adr, uint8_t* const data, const uint8_t len);
17 uint8_t i2c_writebuf(const uint8_t adr, uint8_t* const data, const uint8_t len);
18 
19 // convenience functions
20 inline void i2c_writebyte(const uint8_t adr, uint8_t data) { i2c_writebuf(adr, &data, 1); }
21 inline uint8_t i2c_readbyte(const uint8_t adr) { uint8_t r; i2c_readbuf(adr, &r, 1); return r; }
22 
23 #endif
uint8_t i2c_writebuf(const uint8_t adr, uint8_t *const data, const uint8_t len)
Write to I2C.
Definition: i2c.c:92
uint8_t i2c_readbuf(const uint8_t adr, uint8_t *const data, const uint8_t len)
Read from I2C.
Definition: i2c.c:139
void i2c_init(uint8_t br)
Init I2C.
Definition: i2c.c:63