Compare commits

..

2 Commits

Author SHA1 Message Date
Max Nowka
c530411395 add edge detection code 2021-08-22 17:06:20 +02:00
Max Nowka
545e7f380d add headerguards 2021-08-22 00:16:42 +02:00
3 changed files with 2292 additions and 2502 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -3,22 +3,13 @@
#include <stdint.h> #include <stdint.h>
#define LEVEL 0 extern volatile uint8_t outStates[4];
#define EDGE 1 extern volatile uint8_t inStates[4];
#define RISING 2 extern volatile uint8_t ioHelperDebounceTable[32];
#define FALLING 3 extern volatile uint8_t oldInstates[4];
extern volatile uint8_t inStatesBothEdges[4];
#define OFF 0 extern volatile uint8_t inStatesRisingEdge[4];
#define ON 1 extern volatile uint8_t inStatesFallingEdge[4];
#define BLINK 2
#define TOGGLE 3
#define nrOfOutputs 32 //must be multiple of 8
#define nrOfInputs 32 //must be multiple of 8
extern volatile uint8_t outStates[nrOfOutputs/8];
extern volatile uint8_t inStates[nrOfInputs/8];
extern volatile uint8_t ioHelperDebounceTable[nrOfInputs];
void ioHelperSetOuts(void); void ioHelperSetOuts(void);
void ioHelperReadPins(void); void ioHelperReadPins(void);
@@ -27,10 +18,6 @@ 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 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

View File

@@ -1,97 +1,92 @@
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)
#endif #endif
#ifdef BitPA1 #ifdef BitPA1
|(1<<1) |(1<<1)
#endif #endif
#ifdef BitPA2 #ifdef BitPA2
|(1<<2) |(1<<2)
#endif #endif
#ifdef BitPA3 #ifdef BitPA3
|(1<<3) |(1<<3)
#endif #endif
#ifdef BitPA4 #ifdef BitPA4
|(1<<4) |(1<<4)
#endif #endif
#ifdef BitPA5 #ifdef BitPA5
|(1<<5) |(1<<5)
#endif #endif
#ifdef BitPA6 #ifdef BitPA6
|(1<<6) |(1<<6)
#endif #endif
#ifdef BitPA7 #ifdef BitPA7
|(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)
#endif #endif
#ifdef BitPA1 #ifdef BitPA1
|(getBit1(BitPA1)<<1) |(getBit1(BitPA1)<<1)
#endif #endif
#ifdef BitPA2 #ifdef BitPA2
|(getBit1(BitPA2)<<2) |(getBit1(BitPA2)<<2)
#endif #endif
#ifdef BitPA3 #ifdef BitPA3
|(getBit1(BitPA3)<<3) |(getBit1(BitPA3)<<3)
#endif #endif
#ifdef BitPA4 #ifdef BitPA4
|(getBit1(BitPA4)<<4) |(getBit1(BitPA4)<<4)
#endif #endif
#ifdef BitPA5 #ifdef BitPA5
|(getBit1(BitPA5)<<5) |(getBit1(BitPA5)<<5)
#endif #endif
#ifdef BitPA6 #ifdef BitPA6
|(getBit1(BitPA6)<<6) |(getBit1(BitPA6)<<6)
#endif #endif
#ifdef BitPA7 #ifdef BitPA7
|(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)
#endif #endif
#ifdef BitPA1 #ifdef BitPA1
|(getBit0(BitPA1)<<1) |(getBit0(BitPA1)<<1)
#endif #endif
#ifdef BitPA2 #ifdef BitPA2
|(getBit0(BitPA2)<<2) |(getBit0(BitPA2)<<2)
#endif #endif
#ifdef BitPA3 #ifdef BitPA3
|(getBit0(BitPA3)<<3) |(getBit0(BitPA3)<<3)
#endif #endif
#ifdef BitPA4 #ifdef BitPA4
|(getBit0(BitPA4)<<4) |(getBit0(BitPA4)<<4)
#endif #endif
#ifdef BitPA5 #ifdef BitPA5
|(getBit0(BitPA5)<<5) |(getBit0(BitPA5)<<5)
#endif #endif
#ifdef BitPA6 #ifdef BitPA6
|(getBit0(BitPA6)<<6) |(getBit0(BitPA6)<<6)
#endif #endif
#ifdef BitPA7 #ifdef BitPA7
|(getBit0(BitPA7)<<7) |(getBit0(BitPA7)<<7)
#endif #endif
|0); |0);
}
#endif #endif
""" """