main revised

This commit is contained in:
Tristan Krause 2019-04-03 14:58:50 +02:00
parent 787fc6f784
commit cdcba456cb
4 changed files with 80 additions and 77 deletions

Binary file not shown.

View file

@ -6,8 +6,7 @@
#include "selftest.h"
#include "requests.h"
void initAll()
int main()
{
// deactivate WDT ENTIRELY!
MCUSR &= ~_BV(WDRF);
@ -28,84 +27,10 @@ void initAll()
usart.init();
usart.initRX();
}
void handleRequest()
{
const uint8_t req = usart.readByte();
wdt_reset();
switch(req)
{
case RQ_DISC:
break;
case RQ_TEST:
rqTestConnection();
break;
case RQ_INFO:
rqBoardInfo();
break;
case RQ_INT:
rqTestIntConv();
break;
case RQ_ST:
rqSelfTest();
break;
case RQ_BA0:
rqDigitalWrite0();
break;
case RQ_BA1:
rqDigitalWrite1();
break;
case RQ_BE0:
rqDigitalRead0();
break;
case RQ_BE1:
rqDigitalRead1();
break;
case RQ_DSW:
rqReadDipSwitch();
break;
case RQ_AA0:
rqAnalogWrite0();
break;
case RQ_AA1:
rqAnalogWrite1();
break;
case RQ_ADC:
rqAnalogRead();
break;
case RQ_ADC_DAC_STROKE:
rqAdcDacStroke();
break;
default:
break;
}
usart.initRX();
wdt_disable();
}
int main()
{
initAll();
// Hauptschleife, Verarbeitung der Requests
while(1)
{
if(nextRequest)

View file

@ -1,5 +1,77 @@
#include "requests.h"
void handleRequest()
{
const uint8_t req = usart.readByte();
wdt_reset();
switch(req)
{
case RQ_DISC:
break;
case RQ_TEST:
rqTestConnection();
break;
case RQ_INFO:
rqBoardInfo();
break;
case RQ_INT:
rqTestIntConv();
break;
case RQ_ST:
rqSelfTest();
break;
case RQ_BA0:
rqDigitalWrite0();
break;
case RQ_BA1:
rqDigitalWrite1();
break;
case RQ_BE0:
rqDigitalRead0();
break;
case RQ_BE1:
rqDigitalRead1();
break;
case RQ_DSW:
rqReadDipSwitch();
break;
case RQ_AA0:
rqAnalogWrite0();
break;
case RQ_AA1:
rqAnalogWrite1();
break;
case RQ_ADC:
rqAnalogRead();
break;
case RQ_ADC_DAC_STROKE:
rqAdcDacStroke();
break;
default:
break;
}
usart.initRX();
wdt_disable();
}
void rqTestConnection()
{
usart.initTX();

View file

@ -38,6 +38,12 @@ uint8_t const rq_len[] = {
/* RQ_ADC_DAC_STROKE */ 9
};
/**
* Hauptfunktion für die Verarbeitung einer neuen empfangen Request
*/
void handleRequest(void);
// spezifische Funktion für jede Request
void rqTestConnection(void);
void rqBoardInfo(void);
void rqTestIntConv(void);