]> cvs.zerfleddert.de Git - rsbs2/blobdiff - bmc/bmc.c
decrease poweron and reset-time to the same value as rsbs2 fw
[rsbs2] / bmc / bmc.c
index 06a38290da134ec7f51e1ff00f3ec14a090f1a2d..dcdeb775dc2c3d9396c0882a1440ecf0e84e6fa7 100644 (file)
--- a/bmc/bmc.c
+++ b/bmc/bmc.c
@@ -1,24 +1,51 @@
-#define F_CPU 1000000UL\r
-\r
-#include <avr/io.h>\r
-\r
-int main(void)\r
-{\r
-       uint8_t pb = 0x00;\r
-       int8_t dir = 1;\r
-       volatile uint16_t i;\r
-\r
-       DDRB = 0xff;\r
-\r
-       while(1) {\r
-               pb += dir;\r
-               PORTB = pb;\r
-\r
-               for (i = 0; i < (pb<<5); i++) {}\r
-\r
-               if ((pb == 0) || (pb == 0xff))\r
-                       dir = -dir;\r
-       }\r
-\r
-       return 0;\r
-}\r
+#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)
+{
+       unsigned char buf[24];
+       unsigned int len;
+
+       chassis_init();
+       usart_init();
+       i2c_init();
+
+       set_sleep_mode(SLEEP_MODE_IDLE);
+
+       sei();
+
+       while(1) {
+               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