add edge detection code
This commit is contained in:
13
io-helper.c
13
io-helper.c
@@ -4,7 +4,20 @@
|
|||||||
volatile uint8_t outStates[]={0,0,0,0};
|
volatile uint8_t outStates[]={0,0,0,0};
|
||||||
volatile uint8_t inStatesRaw[] = {0,0,0,0};
|
volatile uint8_t inStatesRaw[] = {0,0,0,0};
|
||||||
volatile uint8_t inStates[] = {0,0,0,0};
|
volatile uint8_t inStates[] = {0,0,0,0};
|
||||||
|
|
||||||
volatile uint8_t oldInstates[] = {0,0,0,0};
|
volatile uint8_t oldInstates[] = {0,0,0,0};
|
||||||
|
volatile uint8_t inStatesBothEdges[] = {0,0,0,0};
|
||||||
|
volatile uint8_t inStatesRisingEdge[] = {0,0,0,0};
|
||||||
|
volatile uint8_t inStatesFallingEdge[] = {0,0,0,0};
|
||||||
|
|
||||||
|
void ioHelperEdgeDetector(void){
|
||||||
|
for (uint8_t i = 0; i < 4; i++){
|
||||||
|
inStatesBothEdges[i] = oldInstates[i] ^ inStates[i];
|
||||||
|
inStatesRisingEdge[i] = inStatesBothEdges[i] & inStates[i];
|
||||||
|
inStatesFallingEdge[i] = inStatesBothEdges[i] & oldInstates[i];
|
||||||
|
oldInstates[i] = inStates[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)
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
extern volatile uint8_t outStates[4];
|
extern volatile uint8_t outStates[4];
|
||||||
extern volatile uint8_t inStates[4];
|
extern volatile uint8_t inStates[4];
|
||||||
extern volatile uint8_t ioHelperDebounceTable[32];
|
extern volatile uint8_t ioHelperDebounceTable[32];
|
||||||
|
extern volatile uint8_t oldInstates[4];
|
||||||
|
extern volatile uint8_t inStatesBothEdges[4];
|
||||||
|
extern volatile uint8_t inStatesRisingEdge[4];
|
||||||
|
extern volatile uint8_t inStatesFallingEdge[4];
|
||||||
|
|
||||||
void ioHelperSetOuts(void);
|
void ioHelperSetOuts(void);
|
||||||
void ioHelperReadPins(void);
|
void ioHelperReadPins(void);
|
||||||
@@ -13,7 +17,7 @@ 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);
|
||||||
|
|
||||||
//Outputs
|
//Outputs
|
||||||
//Pin | Bit in outStates
|
//Pin | Bit in outStates
|
||||||
|
|||||||
Reference in New Issue
Block a user