]> git.zerfleddert.de Git - rsbs2/blobdiff - bmc/bmc.c
add howto exception list
[rsbs2] / bmc / bmc.c
index c786032e092d235dec4240be704dae4eda4c34b6..e3690a47b5eef72f953e745e0cc88248bacb36af 100644 (file)
--- a/bmc/bmc.c
+++ b/bmc/bmc.c
@@ -1,32 +1,49 @@
 #include <avr/io.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"
+
+#undef SLEEP_MODE
 
 int main(void)
 {
-       uint8_t pb = 0x00;
-       int8_t dir = 1;
-       volatile uint16_t i;
+       unsigned char buf[24];
+       unsigned int len;
 
-       DDRB = 0xff;
+       set_sleep_mode(SLEEP_MODE_IDLE);
 
+       chassis_init();
        usart_init();
-       i2c_init();
-
        sei();
-
-       printf("Hallo!\n");
+       i2c_init();
 
        while(1) {
-               pb += dir;
-               PORTB = pb;
-
-               for (i = 0; i < (pb<<5); i++) {}
-
-               if ((pb == 0) || (pb == 0xff))
-                       dir = -dir;
+               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
        }
 
        return 0;
Impressum, Datenschutz