b15f/main.cpp

79 lines
1 KiB
C++
Raw Normal View History

#include <avr/io.h>
2019-03-25 12:00:22 +00:00
#include <avr/interrupt.h>
#include <util/delay.h>
2019-03-25 14:02:24 +00:00
#include <avr/wdt.h>
2019-03-26 07:44:30 +00:00
#include "global_vars.h"
2019-03-25 15:15:00 +00:00
#include "selftest.h"
2019-03-26 14:02:58 +00:00
#include "requests.h"
2019-03-25 12:00:22 +00:00
2019-03-26 07:44:30 +00:00
#define LED PB0
2019-03-25 14:02:24 +00:00
ISR(WDT_vect)
{
while(1)
{
2019-03-26 07:44:30 +00:00
PORTB ^= _BV(LED);
2019-03-25 14:02:24 +00:00
_delay_ms(200);
}
WDTCSR |= _BV(WDIE);
}
2019-03-25 15:15:00 +00:00
void initAll()
2019-03-25 14:02:24 +00:00
{
2019-03-25 12:00:22 +00:00
spi.init();
2019-03-25 15:15:00 +00:00
2019-03-25 12:42:32 +00:00
beba0.setDirA(0x00); // alle Ausgang
beba0.setDirB(0xFF); // alle Eingang
2019-03-25 15:15:00 +00:00
beba1.setDirA(0x00); // alle Ausgang
beba1.setDirB(0xFF); // alle Eingang
2019-03-25 14:02:24 +00:00
sw.setDirB(0xFF); // alle Eingang
2019-03-25 14:40:36 +00:00
adu.init();
2019-03-26 10:35:41 +00:00
usart.init();
}
void handleRequest()
{
const uint8_t req = usart.readByte();
2019-03-26 14:02:58 +00:00
switch(req)
{
case RQ_DISC:
break;
case RQ_TEST:
rqTestConnection();
break;
case RQ_INFO:
rqBoardInfo();
break;
case RQ_INT:
rqTestIntConv();
break;
default:
break;
}
2019-03-25 15:15:00 +00:00
}
int main()
{
/*WDTCSR = _BV(WDIE) | _BV(WDP3) | _BV(WDP0);
2019-03-26 07:44:30 +00:00
DDRB |= _BV(LED);
PORTB &= ~_BV(LED);
2019-03-25 15:15:00 +00:00
wdt_reset();
sei();*/
initAll();
2019-03-25 12:00:22 +00:00
2019-03-25 14:02:24 +00:00
while(1)
{
2019-03-26 10:35:41 +00:00
handleRequest();
2019-03-25 12:00:22 +00:00
}
2019-03-22 14:51:52 +00:00
return 0;
}