/* * I2C.c * k4be 2022 * License: BSD */ #include #include #include "I2C.h" #include "main.h" void I2C_init(void){ TWBR = 18; TWSR |= 0; } /* two byte command (or command + value) */ unsigned int I2C_SendCommand(unsigned char address, unsigned char command, unsigned char data_byte) { unsigned int error = ERROR_I2C; for(int index = 0 ; (index < MAX_REPEAT_I2C) && (error != ERROR_NO); index++) { error = 0; TWCR = (1<