fix indent
This commit is contained in:
54
io-helper.c
54
io-helper.c
@@ -9,50 +9,50 @@ volatile uint8_t oldInstates[nrOfInputs/8];
|
|||||||
|
|
||||||
|
|
||||||
/* @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)
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void ioHelperCpArb(volatile uint8_t *source, uint16_t sourceNr,volatile uint8_t *target, uint16_t targetNr) {
|
void ioHelperCpArb(volatile uint8_t *source, uint16_t sourceNr,volatile uint8_t *target, uint16_t targetNr) {
|
||||||
if(*(source+(sourceNr/8))&(1<<(sourceNr-((sourceNr/8)*8))))
|
if(*(source+(sourceNr/8))&(1<<(sourceNr-((sourceNr/8)*8))))
|
||||||
{
|
{
|
||||||
*(target+(targetNr/8))|=(1<<(targetNr-((targetNr/8)*8)));
|
*(target+(targetNr/8))|=(1<<(targetNr-((targetNr/8)*8)));
|
||||||
} else *(target+(targetNr/8))&=~(1<<(targetNr-((targetNr/8)*8)));
|
} else *(target+(targetNr/8))&=~(1<<(targetNr-((targetNr/8)*8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
volatile uint8_t ioHelperDebounceTable[nrOfInputs];
|
volatile uint8_t ioHelperDebounceTable[nrOfInputs];
|
||||||
|
|
||||||
/* debounceing: */
|
/* debounceing: */
|
||||||
void ioHelperDebounce(void) {
|
void ioHelperDebounce(void) {
|
||||||
static volatile uint8_t tablePos=0;
|
static volatile uint8_t tablePos=0;
|
||||||
for(uint8_t i = 0; i<nrOfInputs; i++) {
|
for(uint8_t i = 0; i<nrOfInputs; i++) {
|
||||||
ioHelperCpArb(inStatesRaw,i,ioHelperDebounceTable,i*8+tablePos);
|
ioHelperCpArb(inStatesRaw,i,ioHelperDebounceTable,i*8+tablePos);
|
||||||
if(ioHelperDebounceTable[i]==0) ioHelperSetBit(inStates,i,0);
|
if(ioHelperDebounceTable[i]==0) ioHelperSetBit(inStates,i,0);
|
||||||
else if(ioHelperDebounceTable[i]==0xFF) ioHelperSetBit(inStates,i,1);
|
else if(ioHelperDebounceTable[i]==0xFF) ioHelperSetBit(inStates,i,1);
|
||||||
}
|
}
|
||||||
if (tablePos<7) {
|
if (tablePos<7) {
|
||||||
tablePos++;
|
tablePos++;
|
||||||
} else tablePos=0;
|
} else tablePos=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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 ArC=0;
|
unsigned char ArC=0;
|
||||||
ArC=nr/8;
|
ArC=nr/8;
|
||||||
if(state) *(list+ArC)|=(1<<(nr-(ArC*8)));
|
if(state) *(list+ArC)|=(1<<(nr-(ArC*8)));
|
||||||
else *(list+ArC)&=~(1<<(nr-(ArC*8)));
|
else *(list+ArC)&=~(1<<(nr-(ArC*8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char ioHelperReadBit(volatile uint8_t *list, uint8_t nr) {
|
unsigned char ioHelperReadBit(volatile uint8_t *list, uint8_t nr) {
|
||||||
unsigned char ArC=0;
|
unsigned char ArC=0;
|
||||||
ArC=nr/8;
|
ArC=nr/8;
|
||||||
if (*(list+ArC)&(1<<(nr-(ArC*8))))
|
if (*(list+ArC)&(1<<(nr-(ArC*8))))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
} else return 0;
|
} else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ioHelperCpBit(uint8_t reg, uint8_t bi, uint8_t bo) {
|
void ioHelperCpBit(uint8_t reg, uint8_t bi, uint8_t bo) {
|
||||||
ioHelperSetBit(inStatesRaw,bo,reg&(1<<bi));
|
ioHelperSetBit(inStatesRaw,bo,reg&(1<<bi));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getBit1(uint8_t bit) {
|
uint8_t getBit1(uint8_t bit) {
|
||||||
|
|||||||
Reference in New Issue
Block a user