]> git.zerfleddert.de Git - rsbs2/commitdiff
fix lost wakeup and activate sleep mode
authorMichael Gernoth <michael@gernoth.net>
Mon, 23 Aug 2010 09:58:08 +0000 (11:58 +0200)
committerMichael Gernoth <michael@gernoth.net>
Mon, 23 Aug 2010 09:58:08 +0000 (11:58 +0200)
bmc/bmc.c

index c96cf6a0bf4a867682535408ac99733cf970b8d7..a7217efb263fad6b886eb9df13351024f4e30417 100644 (file)
--- a/bmc/bmc.c
+++ b/bmc/bmc.c
@@ -9,9 +9,10 @@
 #include "chassis.h"
 #include "bmc.h"
 
+#define SLEEP_MODE
+
 int main(void)
 {
-       uint8_t old_SREG;
        unsigned char buf[24];
        unsigned int len;
 
@@ -19,24 +20,31 @@ int main(void)
        usart_init();
        i2c_init();
 
+       set_sleep_mode(SLEEP_MODE_IDLE);
+
        sei();
 
        while(1) {
-#if 0
-               sleep_mode();
-#endif
-               old_SREG = SREG;
                cli();
-               if (i2c_done) {
+               while (i2c_done) {
                        len = i2c_len;
                        memcpy(buf, (unsigned char*)i2c_databuf, len);
                        i2c_done = 0x00;
-                       SREG = old_SREG;
+                       sei();
 
                        decode_ipmb_pkt(buf, len);
-               } else {
-                       SREG = old_SREG;
+
+                       cli();
                }
+
+#ifdef SLEEP_MODE
+               sleep_enable();
+#endif
+               sei();
+#ifdef SLEEP_MODE
+               sleep_cpu();
+               sleep_disable();
+#endif
        }
 
        return 0;
Impressum, Datenschutz