From: Michael Gernoth Date: Sun, 22 Aug 2010 16:31:35 +0000 (+0200) Subject: working i2c connection to RSBS2-card X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/rsbs2/commitdiff_plain/7f52e04004f9e6147790d674600e0eed5a5e8448 working i2c connection to RSBS2-card --- diff --git a/bmc/Makefile b/bmc/Makefile index 8adc53d..6f8b4dd 100644 --- a/bmc/Makefile +++ b/bmc/Makefile @@ -1,9 +1,13 @@ -CC=avr-gcc -CFLAGS=-mmcu=atmega16 -DF_CPU=8000000UL -Wall -g -OBJCOPY=avr-objcopy PROG=dragon_jtag PORT=usb PMCU=m16 +GCCMCU=atmega16 + +CPUFLAG=-mmcu=$(GCCMCU) +CC=avr-gcc +CFLAGS=$(CPUFLAG) -DF_CPU=8000000UL -Wall -g +LDFLAGS=$(CPUFLAG) +OBJCOPY=avr-objcopy all: bmc.bin diff --git a/bmc/bmc.c b/bmc/bmc.c index c786032..d7c5cdc 100644 --- a/bmc/bmc.c +++ b/bmc/bmc.c @@ -1,4 +1,5 @@ #include +#include #include #include #include "usart.h" @@ -6,27 +7,24 @@ int main(void) { - uint8_t pb = 0x00; - int8_t dir = 1; - volatile uint16_t i; - DDRB = 0xff; + PORTB = 0xff; usart_init(); + printf("\n"); + i2c_init(); + printf("Waiting for I2C...\n"); + sei(); - printf("Hallo!\n"); + PORTB = 0xff; while(1) { - pb += dir; - PORTB = pb; - - for (i = 0; i < (pb<<5); i++) {} - - if ((pb == 0) || (pb == 0xff)) - dir = -dir; +#if 1 + sleep_mode(); +#endif } return 0; diff --git a/bmc/i2c.c b/bmc/i2c.c index 992d6ce..214d410 100644 --- a/bmc/i2c.c +++ b/bmc/i2c.c @@ -9,18 +9,21 @@ void i2c_init() { - TWAR = BMC_ADDR; - TWCR &= ~(1<