]> git.zerfleddert.de Git - rsbs2/blobdiff - bmc/bmc.c
module configs now need .conf
[rsbs2] / bmc / bmc.c
index 4a7f02f489b2f45df33fee5e7ecf5876fc28efce..e3690a47b5eef72f953e745e0cc88248bacb36af 100644 (file)
--- a/bmc/bmc.c
+++ b/bmc/bmc.c
@@ -1,39 +1,48 @@
 #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"
 
-void decode_bmc_cmd(unsigned char *buf, int len)
-{
-       int i;
-
-       for(i = 0; i < len; i++) {
-               printf("0x%02x ", buf[i]);
-       }
-
-       printf("\n");
-}
+#undef SLEEP_MODE
 
 int main(void)
 {
-       DDRB = 0xff;
-       PORTB = 0xff;
+       unsigned char buf[24];
+       unsigned int len;
 
-       usart_init();
-       printf("\n");
+       set_sleep_mode(SLEEP_MODE_IDLE);
 
+       chassis_init();
+       usart_init();
+       sei();
        i2c_init();
 
-       printf("Waiting for I2C...\n");
+       while(1) {
+               cli();
+               while (i2c_done) {
+                       len = i2c_len;
+                       memcpy(buf, (unsigned char*)i2c_databuf, len);
+                       i2c_done = 0x00;
+                       sei();
 
-       sei();
+                       decode_ipmb_pkt(buf, len);
 
-       while(1) {
-#if 1
-               sleep_mode();
+                       cli();
+               }
+
+#ifdef SLEEP_MODE
+               sleep_enable();
+#endif
+               sei();
+#ifdef SLEEP_MODE
+               sleep_cpu();
+               sleep_disable();
 #endif
        }
 
Impressum, Datenschutz