From 99e4226b74acd4286b735b5da275853701dcacf0 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Sun, 22 Aug 2010 16:28:20 +0200 Subject: [PATCH] beginning i2c --- bmc/Makefile | 2 +- bmc/bmc.c | 5 +++++ bmc/i2c.c | 26 ++++++++++++++++++++++++++ bmc/i2c.h | 3 +++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 bmc/i2c.c create mode 100644 bmc/i2c.h diff --git a/bmc/Makefile b/bmc/Makefile index 7915e96..8adc53d 100644 --- a/bmc/Makefile +++ b/bmc/Makefile @@ -7,7 +7,7 @@ PMCU=m16 all: bmc.bin -bmc: bmc.o usart.o +bmc: bmc.o usart.o i2c.o bmc.bin: bmc $(OBJCOPY) -j .text -j .data -O binary $^ $@ diff --git a/bmc/bmc.c b/bmc/bmc.c index a0387b3..c786032 100644 --- a/bmc/bmc.c +++ b/bmc/bmc.c @@ -1,6 +1,8 @@ #include +#include #include #include "usart.h" +#include "i2c.h" int main(void) { @@ -11,6 +13,9 @@ int main(void) DDRB = 0xff; usart_init(); + i2c_init(); + + sei(); printf("Hallo!\n"); diff --git a/bmc/i2c.c b/bmc/i2c.c new file mode 100644 index 0000000..992d6ce --- /dev/null +++ b/bmc/i2c.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include "i2c.h" + +#define TWCR_ACK TWCR = (1<