]> cvs.zerfleddert.de Git - rsbs2/blobdiff - bmc/bmc.c
start implementing power/reset handling as needed on PCs
[rsbs2] / bmc / bmc.c
index d7c5cdc95ec4d1c4028112f188b6547e7320b081..a7217efb263fad6b886eb9df13351024f4e30417 100644 (file)
--- a/bmc/bmc.c
+++ b/bmc/bmc.c
@@ -1,29 +1,49 @@
 #include <avr/io.h>
-#include <avr/sleep.h>
 #include <avr/interrupt.h>
+#include <avr/sleep.h>
+#include <string.h>
 #include <stdio.h>
 #include "usart.h"
 #include "i2c.h"
+#include "ipmb.h"
+#include "chassis.h"
+#include "bmc.h"
+
+#define SLEEP_MODE
 
 int main(void)
 {
-       DDRB = 0xff;
-       PORTB = 0xff;
+       unsigned char buf[24];
+       unsigned int len;
 
+       chassis_init();
        usart_init();
-       printf("\n");
-
        i2c_init();
 
-       printf("Waiting for I2C...\n");
+       set_sleep_mode(SLEEP_MODE_IDLE);
 
        sei();
 
-       PORTB = 0xff;
-
        while(1) {
-#if 1
-               sleep_mode();
+               cli();
+               while (i2c_done) {
+                       len = i2c_len;
+                       memcpy(buf, (unsigned char*)i2c_databuf, len);
+                       i2c_done = 0x00;
+                       sei();
+
+                       decode_ipmb_pkt(buf, len);
+
+                       cli();
+               }
+
+#ifdef SLEEP_MODE
+               sleep_enable();
+#endif
+               sei();
+#ifdef SLEEP_MODE
+               sleep_cpu();
+               sleep_disable();
 #endif
        }
 
Impressum, Datenschutz