From f473da9c3f28298d6fe628579460afb5c9df47ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Br=C3=BCggemann?= Date: Mon, 23 Aug 2021 19:37:37 +0200 Subject: [PATCH] Nr of IOs now settable using defines --- io-helper.c | 23 +++++++++++++++++------ io-helper.h | 10 +++++++--- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/io-helper.c b/io-helper.c index d9e8fe1..e819f26 100644 --- a/io-helper.c +++ b/io-helper.c @@ -1,10 +1,10 @@ #include #include "io-helper.h" -volatile uint8_t outStates[]={0,0,0,0}; -volatile uint8_t inStatesRaw[] = {0,0,0,0}; -volatile uint8_t inStates[] = {0,0,0,0}; -volatile uint8_t oldInstates[] = {0,0,0,0}; +volatile uint8_t outStates[nrOfOutputs/8]; +volatile uint8_t inStatesRaw[nrOfInputs/8]; +volatile uint8_t inStates[nrOfInputs/8]; +volatile uint8_t oldInstates[nrOfInputs/8]; /* @brief: copies a single bit from one char to another char (or arrays thereof) @@ -18,12 +18,12 @@ void ioHelperCpArb(volatile uint8_t *source, uint16_t sourceNr,volatile uint8_t } else *(target+(targetNr/8))&=~(1<<(targetNr-((targetNr/8)*8))); } -volatile uint8_t ioHelperDebounceTable[32]; +volatile uint8_t ioHelperDebounceTable[nrOfInputs]; /* debounceing: */ void ioHelperDebounce(void) { static volatile uint8_t tablePos=0; - for(uint8_t i = 0; i<16; i++) { + for(uint8_t i = 0; i -extern volatile uint8_t outStates[4]; -extern volatile uint8_t inStates[4]; -extern volatile uint8_t ioHelperDebounceTable[32]; + +#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 ioHelperReadPins(void); void ioHelperIoConf(void);