Compare commits
2 Commits
7a288faddb
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c530411395 | ||
|
|
545e7f380d |
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)
|
||||||
|
|||||||
15
io-helper.h
15
io-helper.h
@@ -1,12 +1,23 @@
|
|||||||
|
#ifndef _IO_HELPER_
|
||||||
|
#define _IO_HELPER_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
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 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);
|
||||||
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);
|
||||||
|
|
||||||
//Outputs
|
//Outputs
|
||||||
//Pin | Bit in outStates
|
//Pin | Bit in outStates
|
||||||
@@ -17,3 +28,5 @@ void ioHelperDebounce(void);
|
|||||||
//Pin | Bit in inStates
|
//Pin | Bit in inStates
|
||||||
#define BitPinC1 0
|
#define BitPinC1 0
|
||||||
#define BitPinC5 1
|
#define BitPinC5 1
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user