]> git.zerfleddert.de Git - rsbs2/commitdiff
ipmb messages from RSBS2 card
authorMichael Gernoth <michael@gernoth.net>
Sun, 22 Aug 2010 18:19:29 +0000 (20:19 +0200)
committerMichael Gernoth <michael@gernoth.net>
Sun, 22 Aug 2010 18:19:29 +0000 (20:19 +0200)
bmc/bmc.c
bmc/i2c.c
bmc/ipmb-messages.txt [new file with mode: 0644]

index d7c5cdc95ec4d1c4028112f188b6547e7320b081..4a7f02f489b2f45df33fee5e7ecf5876fc28efce 100644 (file)
--- a/bmc/bmc.c
+++ b/bmc/bmc.c
@@ -4,6 +4,18 @@
 #include <stdio.h>
 #include "usart.h"
 #include "i2c.h"
+#include "bmc.h"
+
+void decode_bmc_cmd(unsigned char *buf, int len)
+{
+       int i;
+
+       for(i = 0; i < len; i++) {
+               printf("0x%02x ", buf[i]);
+       }
+
+       printf("\n");
+}
 
 int main(void)
 {
@@ -19,8 +31,6 @@ int main(void)
 
        sei();
 
-       PORTB = 0xff;
-
        while(1) {
 #if 1
                sleep_mode();
index 214d410158ee3dea10e1fbb4059c24fceb736278..7104758551a25b280296ea999091638557a56f00 100644 (file)
--- a/bmc/i2c.c
+++ b/bmc/i2c.c
@@ -2,11 +2,15 @@
 #include <avr/interrupt.h>
 #include <stdio.h>
 #include "i2c.h"
+#include "bmc.h"
 
 #define TWCR_ACK TWCR = (1<<TWEN)|(1<<TWIE)|(1<<TWINT)|(1<<TWEA)|(0<<TWSTA)|(0<<TWSTO)|(0<<TWWC);  
 #define TWCR_NACK TWCR = (1<<TWEN)|(1<<TWIE)|(1<<TWINT)|(0<<TWEA)|(0<<TWSTA)|(0<<TWSTO)|(0<<TWWC);
 #define TWCR_RESET TWCR = (1<<TWEN)|(1<<TWIE)|(1<<TWINT)|(1<<TWEA)|(0<<TWSTA)|(1<<TWSTO)|(0<<TWWC);  
 
+static volatile unsigned char databuf[12];
+static volatile uint8_t pos = 0x00;
+
 void i2c_init()
 {
        TWAR = BMC_ADDR & 0xfe;
@@ -19,11 +23,43 @@ void i2c_init()
 
 ISR (TWI_vect, ISR_BLOCK)
 {
-       printf("Interrupt, Status: 0x%02x, Data: 0x%02x!\n", TW_STATUS, TWDR);
-
        switch (TW_STATUS) {
-               default:
+               case TW_SR_SLA_ACK:
+#ifdef DEBUG
+                       printf("I2C: Slave 0x%02x adressed\n", TWDR);
+#endif
+                       pos = 0x00;
+                       TWCR_ACK;
+                       break;
+
+               case TW_SR_DATA_ACK:
+#ifdef DEBUG
+                       printf("I2C: Data received: 0x%02x\n", TWDR);
+#endif
+                       databuf[pos] = TWDR;
+                       pos++;
+                       TWCR_ACK;
+                       break;
+
+               case TW_SR_STOP:
+#ifdef DEBUG
+                       printf("I2C: STOP received\n");
+#endif
+                       decode_bmc_cmd((unsigned char*)databuf, pos);
+                       pos = 0x00;
+                       TWCR_RESET;
+                       break;
+
+               case TW_ST_SLA_ACK:
+               case TW_ST_DATA_ACK:
+                       printf("I2C: Data requested\n");
+                       TWDR = 0x00;
                        TWCR_ACK;
                        break;
+
+               default:
+                       printf("I2C: Unimplemented status 0x%02x\n", TW_STATUS);
+                       TWCR_RESET;
+                       break;
        }
 }
diff --git a/bmc/ipmb-messages.txt b/bmc/ipmb-messages.txt
new file mode 100644 (file)
index 0000000..2f948f8
--- /dev/null
@@ -0,0 +1,16 @@
+Power OFF:
+       0x00 0xdc 0x28 0x04 0x02 0x00 0xd2 
+       0x00 0xdc 0x28 0x08 0x02 0x00 0xce 
+
+Hard Reset:
+       0x00 0xdc 0x28 0x04 0x02 0x03 0xcf 
+
+Power ON:
+       0x00 0xdc 0x28 0x04 0x02 0x01 0xd1 
+       0x00 0xdc 0x28 0x08 0x02 0x01 0xcd 
+
+Unknown (periodic messages):
+       0x18 0xc4 0x28 0x04 0x25 0xaf 
+       0x18 0xc4 0x28 0x04 0x01 0xd3 
+       0x18 0xc4 0x28 0x08 0x25 0xab 
+       0x18 0xc4 0x28 0x08 0x01 0xcf 
Impressum, Datenschutz