X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/rsbs2/blobdiff_plain/7f52e04004f9e6147790d674600e0eed5a5e8448..99f916c4f2f21a5e41464b3b9455f4442ce5069e:/bmc/bmc.c diff --git a/bmc/bmc.c b/bmc/bmc.c index d7c5cdc..e3690a4 100644 --- a/bmc/bmc.c +++ b/bmc/bmc.c @@ -1,29 +1,48 @@ #include -#include #include +#include +#include #include #include "usart.h" #include "i2c.h" +#include "ipmb.h" +#include "chassis.h" +#include "bmc.h" + +#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); - PORTB = 0xff; + cli(); + } - while(1) { -#if 1 - sleep_mode(); +#ifdef SLEEP_MODE + sleep_enable(); +#endif + sei(); +#ifdef SLEEP_MODE + sleep_cpu(); + sleep_disable(); #endif }