Compare commits

..

No commits in common. '7a288faddb086f2a7a694bda215a01aa4a867668' and 'e2f55b4284ee2c7a7158a71084c9dd0a296d0749' have entirely different histories.

@ -1,78 +1,11 @@
#include <avr/io.h> #include <avr/io.h>
#include <util/atomic.h>
#include "io-helper.h" #include "io-helper.h"
volatile uint8_t outStates[nrOfOutputs/8]; volatile uint8_t outStates[nrOfOutputs/8];
volatile uint8_t inStatesRaw[nrOfInputs/8]; volatile uint8_t inStatesRaw[nrOfInputs/8];
volatile uint8_t inStates[nrOfInputs/8]; volatile uint8_t inStates[nrOfInputs/8];
volatile uint8_t outStatesBlinking[nrOfOutputs/8];
volatile uint8_t oldInstates[nrOfInputs/8]; volatile uint8_t oldInstates[nrOfInputs/8];
volatile uint8_t inStatesBothEdges[nrOfInputs/8];
volatile uint8_t inStatesRisingEdge[nrOfInputs/8];
volatile uint8_t inStatesFallingEdge[nrOfInputs/8];
uint8_t read_Input(uint8_t nr, uint8_t type) {
uint8_t state = 0;
switch (type) {
case LEVEL:
state = ioHelperReadBit(inStates, nr);
break;
case EDGE:
state = ioHelperReadBit(inStatesBothEdges, nr);
ioHelperSetBit(inStatesBothEdges, nr, 0);
break;
case RISING:
state = ioHelperReadBit(inStatesRisingEdge, nr);
ioHelperSetBit(inStatesRisingEdge, nr, 0);
break;
case FALLING:
state = ioHelperReadBit(inStatesFallingEdge, nr);
ioHelperSetBit(inStatesFallingEdge, nr, 0);
break;
}
return state;
}
void set_Output(uint8_t nr, uint8_t state) {
switch (state) {
case BLINK:
ioHelperSetBit(outStatesBlinking, nr, ON);
break;
case TOGGLE:
ioHelperSetBit(outStatesBlinking, nr, OFF);
if (ioHelperReadBit(outStates, nr)) {
ioHelperSetBit(outStates, nr, OFF);
} else {
ioHelperSetBit(outStates, nr, ON);
}
break;
case ON:
ioHelperSetBit(outStates, nr, ON);
ioHelperSetBit(outStatesBlinking, nr, OFF);
break;
case OFF:
ioHelperSetBit(outStates, nr, OFF);
ioHelperSetBit(outStatesBlinking, nr, OFF);
break;
}
}
void ioHelperEdgeDetector(void){
for (uint8_t i = 0; i < nrOfInputs/8; i++){
inStatesBothEdges[i] = oldInstates[i] ^ inStates[i];
inStatesRisingEdge[i] = inStatesBothEdges[i] & inStates[i];
inStatesFallingEdge[i] = inStatesBothEdges[i] & oldInstates[i];
oldInstates[i] = inStates[i];
}
}
void ioHelperBlinkOuts(){
for(uint8_t i=0; i<nrOfOutputs/8; i++)
outStates[i] ^= outStatesBlinking[i];
}
/* @brief: copies a single bit from one char to another char (or arrays thereof) /* @brief: copies a single bit from one char to another char (or arrays thereof)
* *
@ -148,7 +81,6 @@ void ioHelperIoConf(void) {
} }
#ifdef DDRA #ifdef DDRA
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRA|=0 DDRA|=0
#ifdef BitPA0 #ifdef BitPA0
|(1<<0) |(1<<0)
@ -175,12 +107,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRB #ifdef DDRB
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRB|=0 DDRB|=0
#ifdef BitPB0 #ifdef BitPB0
|(1<<0) |(1<<0)
@ -207,12 +138,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRC #ifdef DDRC
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRC|=0 DDRC|=0
#ifdef BitPC0 #ifdef BitPC0
|(1<<0) |(1<<0)
@ -239,12 +169,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRD #ifdef DDRD
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRD|=0 DDRD|=0
#ifdef BitPD0 #ifdef BitPD0
|(1<<0) |(1<<0)
@ -271,12 +200,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRE #ifdef DDRE
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRE|=0 DDRE|=0
#ifdef BitPE0 #ifdef BitPE0
|(1<<0) |(1<<0)
@ -303,12 +231,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRF #ifdef DDRF
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRF|=0 DDRF|=0
#ifdef BitPF0 #ifdef BitPF0
|(1<<0) |(1<<0)
@ -335,12 +262,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRG #ifdef DDRG
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRG|=0 DDRG|=0
#ifdef BitPG0 #ifdef BitPG0
|(1<<0) |(1<<0)
@ -367,12 +293,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRH #ifdef DDRH
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRH|=0 DDRH|=0
#ifdef BitPH0 #ifdef BitPH0
|(1<<0) |(1<<0)
@ -399,12 +324,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRI #ifdef DDRI
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRI|=0 DDRI|=0
#ifdef BitPI0 #ifdef BitPI0
|(1<<0) |(1<<0)
@ -431,12 +355,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRJ #ifdef DDRJ
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRJ|=0 DDRJ|=0
#ifdef BitPJ0 #ifdef BitPJ0
|(1<<0) |(1<<0)
@ -463,12 +386,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRK #ifdef DDRK
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRK|=0 DDRK|=0
#ifdef BitPK0 #ifdef BitPK0
|(1<<0) |(1<<0)
@ -495,12 +417,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRL #ifdef DDRL
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRL|=0 DDRL|=0
#ifdef BitPL0 #ifdef BitPL0
|(1<<0) |(1<<0)
@ -527,12 +448,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRM #ifdef DDRM
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRM|=0 DDRM|=0
#ifdef BitPM0 #ifdef BitPM0
|(1<<0) |(1<<0)
@ -559,12 +479,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRN #ifdef DDRN
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRN|=0 DDRN|=0
#ifdef BitPN0 #ifdef BitPN0
|(1<<0) |(1<<0)
@ -591,12 +510,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRO #ifdef DDRO
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRO|=0 DDRO|=0
#ifdef BitPO0 #ifdef BitPO0
|(1<<0) |(1<<0)
@ -623,12 +541,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRP #ifdef DDRP
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRP|=0 DDRP|=0
#ifdef BitPP0 #ifdef BitPP0
|(1<<0) |(1<<0)
@ -655,12 +572,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRQ #ifdef DDRQ
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRQ|=0 DDRQ|=0
#ifdef BitPQ0 #ifdef BitPQ0
|(1<<0) |(1<<0)
@ -687,12 +603,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRR #ifdef DDRR
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRR|=0 DDRR|=0
#ifdef BitPR0 #ifdef BitPR0
|(1<<0) |(1<<0)
@ -719,12 +634,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRS #ifdef DDRS
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRS|=0 DDRS|=0
#ifdef BitPS0 #ifdef BitPS0
|(1<<0) |(1<<0)
@ -751,12 +665,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRT #ifdef DDRT
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRT|=0 DDRT|=0
#ifdef BitPT0 #ifdef BitPT0
|(1<<0) |(1<<0)
@ -783,12 +696,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRU #ifdef DDRU
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRU|=0 DDRU|=0
#ifdef BitPU0 #ifdef BitPU0
|(1<<0) |(1<<0)
@ -815,12 +727,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRV #ifdef DDRV
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRV|=0 DDRV|=0
#ifdef BitPV0 #ifdef BitPV0
|(1<<0) |(1<<0)
@ -847,12 +758,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRW #ifdef DDRW
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRW|=0 DDRW|=0
#ifdef BitPW0 #ifdef BitPW0
|(1<<0) |(1<<0)
@ -879,12 +789,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRX #ifdef DDRX
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRX|=0 DDRX|=0
#ifdef BitPX0 #ifdef BitPX0
|(1<<0) |(1<<0)
@ -911,12 +820,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRY #ifdef DDRY
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRY|=0 DDRY|=0
#ifdef BitPY0 #ifdef BitPY0
|(1<<0) |(1<<0)
@ -943,12 +851,11 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
#ifdef DDRZ #ifdef DDRZ
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRZ|=0 DDRZ|=0
#ifdef BitPZ0 #ifdef BitPZ0
|(1<<0) |(1<<0)
@ -975,14 +882,15 @@ void ioHelperIoConf(void) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
} }
void ioHelperSetOuts(void) { void ioHelperSetOuts(void) {
#ifdef PORTA #ifdef PORTA
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTA|=0 PORTA|=0
#ifdef BitPA0 #ifdef BitPA0
|(getBit1(BitPA0)<<0) |(getBit1(BitPA0)<<0)
@ -1009,9 +917,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPA7)<<7) |(getBit1(BitPA7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTA&=~(0 PORTA&=~(0
#ifdef BitPA0 #ifdef BitPA0
|(getBit0(BitPA0)<<0) |(getBit0(BitPA0)<<0)
@ -1038,13 +944,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPA7)<<7) |(getBit0(BitPA7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTB #ifdef PORTB
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTB|=0 PORTB|=0
#ifdef BitPB0 #ifdef BitPB0
|(getBit1(BitPB0)<<0) |(getBit1(BitPB0)<<0)
@ -1071,9 +975,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPB7)<<7) |(getBit1(BitPB7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTB&=~(0 PORTB&=~(0
#ifdef BitPB0 #ifdef BitPB0
|(getBit0(BitPB0)<<0) |(getBit0(BitPB0)<<0)
@ -1100,13 +1002,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPB7)<<7) |(getBit0(BitPB7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTC #ifdef PORTC
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTC|=0 PORTC|=0
#ifdef BitPC0 #ifdef BitPC0
|(getBit1(BitPC0)<<0) |(getBit1(BitPC0)<<0)
@ -1133,9 +1033,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPC7)<<7) |(getBit1(BitPC7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTC&=~(0 PORTC&=~(0
#ifdef BitPC0 #ifdef BitPC0
|(getBit0(BitPC0)<<0) |(getBit0(BitPC0)<<0)
@ -1162,13 +1060,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPC7)<<7) |(getBit0(BitPC7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTD #ifdef PORTD
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTD|=0 PORTD|=0
#ifdef BitPD0 #ifdef BitPD0
|(getBit1(BitPD0)<<0) |(getBit1(BitPD0)<<0)
@ -1195,9 +1091,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPD7)<<7) |(getBit1(BitPD7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTD&=~(0 PORTD&=~(0
#ifdef BitPD0 #ifdef BitPD0
|(getBit0(BitPD0)<<0) |(getBit0(BitPD0)<<0)
@ -1224,13 +1118,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPD7)<<7) |(getBit0(BitPD7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTE #ifdef PORTE
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTE|=0 PORTE|=0
#ifdef BitPE0 #ifdef BitPE0
|(getBit1(BitPE0)<<0) |(getBit1(BitPE0)<<0)
@ -1257,9 +1149,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPE7)<<7) |(getBit1(BitPE7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTE&=~(0 PORTE&=~(0
#ifdef BitPE0 #ifdef BitPE0
|(getBit0(BitPE0)<<0) |(getBit0(BitPE0)<<0)
@ -1286,13 +1176,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPE7)<<7) |(getBit0(BitPE7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTF #ifdef PORTF
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTF|=0 PORTF|=0
#ifdef BitPF0 #ifdef BitPF0
|(getBit1(BitPF0)<<0) |(getBit1(BitPF0)<<0)
@ -1319,9 +1207,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPF7)<<7) |(getBit1(BitPF7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTF&=~(0 PORTF&=~(0
#ifdef BitPF0 #ifdef BitPF0
|(getBit0(BitPF0)<<0) |(getBit0(BitPF0)<<0)
@ -1348,13 +1234,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPF7)<<7) |(getBit0(BitPF7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTG #ifdef PORTG
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTG|=0 PORTG|=0
#ifdef BitPG0 #ifdef BitPG0
|(getBit1(BitPG0)<<0) |(getBit1(BitPG0)<<0)
@ -1381,9 +1265,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPG7)<<7) |(getBit1(BitPG7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTG&=~(0 PORTG&=~(0
#ifdef BitPG0 #ifdef BitPG0
|(getBit0(BitPG0)<<0) |(getBit0(BitPG0)<<0)
@ -1410,13 +1292,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPG7)<<7) |(getBit0(BitPG7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTH #ifdef PORTH
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTH|=0 PORTH|=0
#ifdef BitPH0 #ifdef BitPH0
|(getBit1(BitPH0)<<0) |(getBit1(BitPH0)<<0)
@ -1443,9 +1323,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPH7)<<7) |(getBit1(BitPH7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTH&=~(0 PORTH&=~(0
#ifdef BitPH0 #ifdef BitPH0
|(getBit0(BitPH0)<<0) |(getBit0(BitPH0)<<0)
@ -1472,13 +1350,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPH7)<<7) |(getBit0(BitPH7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTI #ifdef PORTI
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTI|=0 PORTI|=0
#ifdef BitPI0 #ifdef BitPI0
|(getBit1(BitPI0)<<0) |(getBit1(BitPI0)<<0)
@ -1505,9 +1381,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPI7)<<7) |(getBit1(BitPI7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTI&=~(0 PORTI&=~(0
#ifdef BitPI0 #ifdef BitPI0
|(getBit0(BitPI0)<<0) |(getBit0(BitPI0)<<0)
@ -1534,13 +1408,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPI7)<<7) |(getBit0(BitPI7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTJ #ifdef PORTJ
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTJ|=0 PORTJ|=0
#ifdef BitPJ0 #ifdef BitPJ0
|(getBit1(BitPJ0)<<0) |(getBit1(BitPJ0)<<0)
@ -1567,9 +1439,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPJ7)<<7) |(getBit1(BitPJ7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTJ&=~(0 PORTJ&=~(0
#ifdef BitPJ0 #ifdef BitPJ0
|(getBit0(BitPJ0)<<0) |(getBit0(BitPJ0)<<0)
@ -1596,13 +1466,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPJ7)<<7) |(getBit0(BitPJ7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTK #ifdef PORTK
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTK|=0 PORTK|=0
#ifdef BitPK0 #ifdef BitPK0
|(getBit1(BitPK0)<<0) |(getBit1(BitPK0)<<0)
@ -1629,9 +1497,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPK7)<<7) |(getBit1(BitPK7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTK&=~(0 PORTK&=~(0
#ifdef BitPK0 #ifdef BitPK0
|(getBit0(BitPK0)<<0) |(getBit0(BitPK0)<<0)
@ -1658,13 +1524,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPK7)<<7) |(getBit0(BitPK7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTL #ifdef PORTL
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTL|=0 PORTL|=0
#ifdef BitPL0 #ifdef BitPL0
|(getBit1(BitPL0)<<0) |(getBit1(BitPL0)<<0)
@ -1691,9 +1555,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPL7)<<7) |(getBit1(BitPL7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTL&=~(0 PORTL&=~(0
#ifdef BitPL0 #ifdef BitPL0
|(getBit0(BitPL0)<<0) |(getBit0(BitPL0)<<0)
@ -1720,13 +1582,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPL7)<<7) |(getBit0(BitPL7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTM #ifdef PORTM
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTM|=0 PORTM|=0
#ifdef BitPM0 #ifdef BitPM0
|(getBit1(BitPM0)<<0) |(getBit1(BitPM0)<<0)
@ -1753,9 +1613,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPM7)<<7) |(getBit1(BitPM7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTM&=~(0 PORTM&=~(0
#ifdef BitPM0 #ifdef BitPM0
|(getBit0(BitPM0)<<0) |(getBit0(BitPM0)<<0)
@ -1782,13 +1640,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPM7)<<7) |(getBit0(BitPM7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTN #ifdef PORTN
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTN|=0 PORTN|=0
#ifdef BitPN0 #ifdef BitPN0
|(getBit1(BitPN0)<<0) |(getBit1(BitPN0)<<0)
@ -1815,9 +1671,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPN7)<<7) |(getBit1(BitPN7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTN&=~(0 PORTN&=~(0
#ifdef BitPN0 #ifdef BitPN0
|(getBit0(BitPN0)<<0) |(getBit0(BitPN0)<<0)
@ -1844,13 +1698,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPN7)<<7) |(getBit0(BitPN7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTO #ifdef PORTO
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTO|=0 PORTO|=0
#ifdef BitPO0 #ifdef BitPO0
|(getBit1(BitPO0)<<0) |(getBit1(BitPO0)<<0)
@ -1877,9 +1729,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPO7)<<7) |(getBit1(BitPO7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTO&=~(0 PORTO&=~(0
#ifdef BitPO0 #ifdef BitPO0
|(getBit0(BitPO0)<<0) |(getBit0(BitPO0)<<0)
@ -1906,13 +1756,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPO7)<<7) |(getBit0(BitPO7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTP #ifdef PORTP
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTP|=0 PORTP|=0
#ifdef BitPP0 #ifdef BitPP0
|(getBit1(BitPP0)<<0) |(getBit1(BitPP0)<<0)
@ -1939,9 +1787,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPP7)<<7) |(getBit1(BitPP7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTP&=~(0 PORTP&=~(0
#ifdef BitPP0 #ifdef BitPP0
|(getBit0(BitPP0)<<0) |(getBit0(BitPP0)<<0)
@ -1968,13 +1814,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPP7)<<7) |(getBit0(BitPP7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTQ #ifdef PORTQ
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTQ|=0 PORTQ|=0
#ifdef BitPQ0 #ifdef BitPQ0
|(getBit1(BitPQ0)<<0) |(getBit1(BitPQ0)<<0)
@ -2001,9 +1845,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPQ7)<<7) |(getBit1(BitPQ7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTQ&=~(0 PORTQ&=~(0
#ifdef BitPQ0 #ifdef BitPQ0
|(getBit0(BitPQ0)<<0) |(getBit0(BitPQ0)<<0)
@ -2030,13 +1872,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPQ7)<<7) |(getBit0(BitPQ7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTR #ifdef PORTR
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTR|=0 PORTR|=0
#ifdef BitPR0 #ifdef BitPR0
|(getBit1(BitPR0)<<0) |(getBit1(BitPR0)<<0)
@ -2063,9 +1903,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPR7)<<7) |(getBit1(BitPR7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTR&=~(0 PORTR&=~(0
#ifdef BitPR0 #ifdef BitPR0
|(getBit0(BitPR0)<<0) |(getBit0(BitPR0)<<0)
@ -2092,13 +1930,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPR7)<<7) |(getBit0(BitPR7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTS #ifdef PORTS
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTS|=0 PORTS|=0
#ifdef BitPS0 #ifdef BitPS0
|(getBit1(BitPS0)<<0) |(getBit1(BitPS0)<<0)
@ -2125,9 +1961,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPS7)<<7) |(getBit1(BitPS7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTS&=~(0 PORTS&=~(0
#ifdef BitPS0 #ifdef BitPS0
|(getBit0(BitPS0)<<0) |(getBit0(BitPS0)<<0)
@ -2154,13 +1988,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPS7)<<7) |(getBit0(BitPS7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTT #ifdef PORTT
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTT|=0 PORTT|=0
#ifdef BitPT0 #ifdef BitPT0
|(getBit1(BitPT0)<<0) |(getBit1(BitPT0)<<0)
@ -2187,9 +2019,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPT7)<<7) |(getBit1(BitPT7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTT&=~(0 PORTT&=~(0
#ifdef BitPT0 #ifdef BitPT0
|(getBit0(BitPT0)<<0) |(getBit0(BitPT0)<<0)
@ -2216,13 +2046,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPT7)<<7) |(getBit0(BitPT7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTU #ifdef PORTU
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTU|=0 PORTU|=0
#ifdef BitPU0 #ifdef BitPU0
|(getBit1(BitPU0)<<0) |(getBit1(BitPU0)<<0)
@ -2249,9 +2077,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPU7)<<7) |(getBit1(BitPU7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTU&=~(0 PORTU&=~(0
#ifdef BitPU0 #ifdef BitPU0
|(getBit0(BitPU0)<<0) |(getBit0(BitPU0)<<0)
@ -2278,13 +2104,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPU7)<<7) |(getBit0(BitPU7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTV #ifdef PORTV
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTV|=0 PORTV|=0
#ifdef BitPV0 #ifdef BitPV0
|(getBit1(BitPV0)<<0) |(getBit1(BitPV0)<<0)
@ -2311,9 +2135,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPV7)<<7) |(getBit1(BitPV7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTV&=~(0 PORTV&=~(0
#ifdef BitPV0 #ifdef BitPV0
|(getBit0(BitPV0)<<0) |(getBit0(BitPV0)<<0)
@ -2340,13 +2162,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPV7)<<7) |(getBit0(BitPV7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTW #ifdef PORTW
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTW|=0 PORTW|=0
#ifdef BitPW0 #ifdef BitPW0
|(getBit1(BitPW0)<<0) |(getBit1(BitPW0)<<0)
@ -2373,9 +2193,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPW7)<<7) |(getBit1(BitPW7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTW&=~(0 PORTW&=~(0
#ifdef BitPW0 #ifdef BitPW0
|(getBit0(BitPW0)<<0) |(getBit0(BitPW0)<<0)
@ -2402,13 +2220,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPW7)<<7) |(getBit0(BitPW7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTX #ifdef PORTX
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTX|=0 PORTX|=0
#ifdef BitPX0 #ifdef BitPX0
|(getBit1(BitPX0)<<0) |(getBit1(BitPX0)<<0)
@ -2435,9 +2251,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPX7)<<7) |(getBit1(BitPX7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTX&=~(0 PORTX&=~(0
#ifdef BitPX0 #ifdef BitPX0
|(getBit0(BitPX0)<<0) |(getBit0(BitPX0)<<0)
@ -2464,13 +2278,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPX7)<<7) |(getBit0(BitPX7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTY #ifdef PORTY
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTY|=0 PORTY|=0
#ifdef BitPY0 #ifdef BitPY0
|(getBit1(BitPY0)<<0) |(getBit1(BitPY0)<<0)
@ -2497,9 +2309,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPY7)<<7) |(getBit1(BitPY7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTY&=~(0 PORTY&=~(0
#ifdef BitPY0 #ifdef BitPY0
|(getBit0(BitPY0)<<0) |(getBit0(BitPY0)<<0)
@ -2526,13 +2336,11 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPY7)<<7) |(getBit0(BitPY7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
#ifdef PORTZ #ifdef PORTZ
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTZ|=0 PORTZ|=0
#ifdef BitPZ0 #ifdef BitPZ0
|(getBit1(BitPZ0)<<0) |(getBit1(BitPZ0)<<0)
@ -2559,9 +2367,7 @@ void ioHelperSetOuts(void) {
|(getBit1(BitPZ7)<<7) |(getBit1(BitPZ7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTZ&=~(0 PORTZ&=~(0
#ifdef BitPZ0 #ifdef BitPZ0
|(getBit0(BitPZ0)<<0) |(getBit0(BitPZ0)<<0)
@ -2588,10 +2394,10 @@ void ioHelperSetOuts(void) {
|(getBit0(BitPZ7)<<7) |(getBit0(BitPZ7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
} }

@ -1,17 +1,7 @@
#ifndef _IO_HELPER_ #ifndef _IO_HELPER_
#define _IO_HELPER_ #define _IO_HELPER_
#include <stdint.h> #include <avr/io.h>
#define LEVEL 0
#define EDGE 1
#define RISING 2
#define FALLING 3
#define OFF 0
#define ON 1
#define BLINK 2
#define TOGGLE 3
#define nrOfOutputs 32 //must be multiple of 8 #define nrOfOutputs 32 //must be multiple of 8
#define nrOfInputs 32 //must be multiple of 8 #define nrOfInputs 32 //must be multiple of 8
@ -19,18 +9,13 @@
extern volatile uint8_t outStates[nrOfOutputs/8]; extern volatile uint8_t outStates[nrOfOutputs/8];
extern volatile uint8_t inStates[nrOfInputs/8]; extern volatile uint8_t inStates[nrOfInputs/8];
extern volatile uint8_t ioHelperDebounceTable[nrOfInputs]; extern volatile uint8_t ioHelperDebounceTable[nrOfInputs];
void ioHelperSetOuts(void); void ioHelperSetOuts(void);
void ioHelperReadPins(void); void ioHelperReadPins(void);
void ioHelperIoConf(void); void ioHelperIoConf(void);
void ioHelperSetBit(volatile uint8_t *list, uint8_t nr, uint8_t state); void ioHelperSetBit(volatile uint8_t *list, uint8_t nr, uint8_t state);
unsigned char ioHelperReadBit(volatile uint8_t *list, uint8_t nr); unsigned char ioHelperReadBit(volatile uint8_t *list, uint8_t nr);
void ioHelperDebounce(void); void ioHelperDebounce(void);
void ioHelperEdgeDetector(void);
void ioHelperBlinkOuts(void);
uint8_t read_Input(uint8_t nr, uint8_t type);
void set_Output(uint8_t nr, uint8_t state);
//Outputs //Outputs
//Pin | Bit in outStates //Pin | Bit in outStates

@ -1,7 +1,6 @@
import string import string
ddr="""#ifdef DDRA ddr="""#ifdef DDRA
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
DDRA|=0 DDRA|=0
#ifdef BitPA0 #ifdef BitPA0
|(1<<0) |(1<<0)
@ -28,14 +27,13 @@ ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
|(1<<7) |(1<<7)
#endif #endif
|0; |0;
}
#endif #endif
""" """
port=""" port="""
#ifdef PORTA #ifdef PORTA
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTA|=0 PORTA|=0
#ifdef BitPA0 #ifdef BitPA0
|(getBit1(BitPA0)<<0) |(getBit1(BitPA0)<<0)
@ -62,9 +60,7 @@ ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
|(getBit1(BitPA7)<<7) |(getBit1(BitPA7)<<7)
#endif #endif
|0; |0;
}
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
PORTA&=~(0 PORTA&=~(0
#ifdef BitPA0 #ifdef BitPA0
|(getBit0(BitPA0)<<0) |(getBit0(BitPA0)<<0)
@ -91,7 +87,6 @@ ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
|(getBit0(BitPA7)<<7) |(getBit0(BitPA7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
""" """

Loading…
Cancel
Save