b15f/main.cpp
2019-03-26 11:35:41 +01:00

60 lines
909 B
C++

#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <avr/wdt.h>
#include "global_vars.h"
#include "selftest.h"
#define LED PB0
ISR(WDT_vect)
{
while(1)
{
PORTB ^= _BV(LED);
_delay_ms(200);
}
WDTCSR |= _BV(WDIE);
}
void initAll()
{
spi.init();
beba0.setDirA(0x00); // alle Ausgang
beba0.setDirB(0xFF); // alle Eingang
beba1.setDirA(0x00); // alle Ausgang
beba1.setDirB(0xFF); // alle Eingang
sw.setDirB(0xFF); // alle Eingang
adu.init();
usart.init();
}
void handleRequest()
{
const uint8_t req = usart.readByte();
uint8_t dummy = usart.readByte();
usart.writeByte(USART::MSG_OK);
usart.writeByte(dummy);
}
int main()
{
/*WDTCSR = _BV(WDIE) | _BV(WDP3) | _BV(WDP0);
DDRB |= _BV(LED);
PORTB &= ~_BV(LED);
wdt_reset();
sei();*/
initAll();
while(1)
{
handleRequest();
}
return 0;
}