]> cvs.zerfleddert.de Git - rsbs2/blobdiff - bmc/i2c.c
working i2c connection to RSBS2-card
[rsbs2] / bmc / i2c.c
index 992d6ce4c840f2cb6324c2067396352f631e1578..214d410158ee3dea10e1fbb4059c24fceb736278 100644 (file)
--- a/bmc/i2c.c
+++ b/bmc/i2c.c
@@ -9,18 +9,21 @@
 
 void i2c_init()
 {
-       TWAR = BMC_ADDR;
-       TWCR &= ~(1<<TWSTA)|(1<<TWSTO);
-       TWCR|= (1<<TWEA) | (1<<TWEN)|(1<<TWIE); 
+       TWAR = BMC_ADDR & 0xfe;
+       TWDR = 0x00;
+       TWCR &= ~((1<<TWSTA) | (1<<TWSTO));
+       TWCR |= ((1<<TWEA) | (1<<TWEN) | (1<<TWIE)); 
+       printf("Status: 0x%02x\n", TW_STATUS);
+       PORTC = 0x03;
 }
 
-ISR (TWI_vect)
+ISR (TWI_vect, ISR_BLOCK)
 {
-       printf("Interrupt, Status: %02x!\n", TW_STATUS);
+       printf("Interrupt, Status: 0x%02x, Data: 0x%02x!\n", TW_STATUS, TWDR);
 
        switch (TW_STATUS) {
                default:
-                       TWCR_RESET;
+                       TWCR_ACK;
                        break;
        }
 }
Impressum, Datenschutz