diff --git a/Control/firmware/uart_echo/main.c b/Control/firmware/uart_echo/main.c index 4c02925..ffec580 100755 --- a/Control/firmware/uart_echo/main.c +++ b/Control/firmware/uart_echo/main.c @@ -110,6 +110,85 @@ void timer_init() } +enum I2C +{ + I2C_START = 0x08, + I2C_REPEATED_START = 0x10, + I2C_SLA_ACK = 0x18, + I2C_SLA_NACK = 0x20, + I2C_DATA_ACK = 0x28, + I2C_DATA_NACK = 0x30, + I2C_LOST = 0x38, + I2C_READ = 0x01, + I2C_WRITE = 0x00 +}; + +void i2c_init() +{ + TWBR = 0xFF; + TWSR = 0x03; +} + +void i2c_send(uint8_t addr, uint8_t rw, uint8_t *data, size_t size) +{ + TWCR = (1<