I2C Library written in pure AVR C.
A light-weight I2C library written in C.
$ git clone https://github.com/jack-greenberg/i2c2.git
$ cd i2c2
$ make
Edit i2c.h
to update the SDA
and SCL
macros to match the pins on your MCU.
#define SDA PB2
#define SCL PB3
Then, in your file, you can use the functions.
int main(void) {
init_I2C(BITRATE_STD); // Initializes timer and interrupts at 100kHz (use BITRATE_FULL for 400kHz)
start_I2C(0x41, 0x81, WRITE); // Sends start condition and transmits address and register of secondary address
transmit_I2C('H');
transmit_I2C('e');
// ...
transmit_I2C('d');
stop_I2C();
return 0;
}
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.