X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/rsbs2/blobdiff_plain/d7bda89e596d43e5a9920269612f992e92d5ada3..99922f0bbaa2b7304136fa3bdb46996ce2beee0f:/bmc/bmc.c diff --git a/bmc/bmc.c b/bmc/bmc.c index 06a3829..e3690a4 100644 --- a/bmc/bmc.c +++ b/bmc/bmc.c @@ -1,24 +1,50 @@ -#define F_CPU 1000000UL - -#include - -int main(void) -{ - uint8_t pb = 0x00; - int8_t dir = 1; - volatile uint16_t i; - - DDRB = 0xff; - - while(1) { - pb += dir; - PORTB = pb; - - for (i = 0; i < (pb<<5); i++) {} - - if ((pb == 0) || (pb == 0xff)) - dir = -dir; - } - - return 0; -} +#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) +{ + unsigned char buf[24]; + unsigned int len; + + set_sleep_mode(SLEEP_MODE_IDLE); + + chassis_init(); + usart_init(); + sei(); + i2c_init(); + + 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; +}