From: andre Ebersold Date: Mon, 23 Oct 2023 20:46:56 +0000 (+0200) Subject: Started Devs for I2C support on AVR X-Git-Url: https://git.ebersold.fr/?a=commitdiff_plain;h=ae15c16b3485cdb600eca573c17e0a46b2f361b8;p=atmel%2Favr.git Started Devs for I2C support on AVR --- diff --git a/HAL/AVR/AvrI2C.cpp b/HAL/AVR/AvrI2C.cpp new file mode 100644 index 0000000..042213f --- /dev/null +++ b/HAL/AVR/AvrI2C.cpp @@ -0,0 +1,36 @@ +#include +#include + +#include "Utils/StdTypes.h" +#include "HAL/Abstract/II2C.h" +#include "AVR/AvrI2C.h" + +#ifndef F_CPU +#define F_CPU 16000000 +#endif +#define SCL_CLOCK 50000 + +void AvrI2C::init() +{ + uint8_t twst; + TWSR = 0; // no prescaler + TWBR = ((F_CPU/SCL_CLOCK)-16)/2; + TWCR = (1<<(TWINT))|(1<