From 60797c8439f472c68f374acc11337e362a8836eb Mon Sep 17 00:00:00 2001 From: yiancar Date: Thu, 12 Jul 2018 11:50:55 +0300 Subject: Add I2C slave library - Add I2C slave library for general use. --- drivers/avr/i2c_slave.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++ drivers/avr/i2c_slave.h | 19 +++++++++ 2 files changed, 119 insertions(+) create mode 100755 drivers/avr/i2c_slave.c create mode 100755 drivers/avr/i2c_slave.h (limited to 'drivers/avr') diff --git a/drivers/avr/i2c_slave.c b/drivers/avr/i2c_slave.c new file mode 100755 index 000000000..3edf85b12 --- /dev/null +++ b/drivers/avr/i2c_slave.c @@ -0,0 +1,100 @@ +/* Library made by: g4lvanix + * Github repository: https://github.com/g4lvanix/I2C-slave-lib + */ + +#include +#include +#include + +#include "i2c_slave.h" + +void i2c_init(uint8_t address){ + // load address into TWI address register + TWAR = (address << 1); + // set the TWCR to enable address matching and enable TWI, clear TWINT, enable TWI interrupt + TWCR = (1<