Help....Trying to use extern / static to no avail....
I have four global variables defined before main in file1.c
Code:
boolean moreThanOneSwitch = F, moreThanOneSwitchTwoSec = F;unsigned int switchHits[12] = {0}, button = 0;
I declare these variables 'extern' in file1.h
Code:
extern unsigned int switchHits[12], button;extern boolean moreThanOneSwitchTwoSec, moreThanOneSwitch;
I place them into a struct in file1.h
Code:
struct swParams { unsigned int switchHits[12];
unsigned int button;
boolean moreThanOneSwitch;
boolean moreThanOneSwitchTwoSec;
};
file1.h also contains a declaration to a function that returns that struct so that main can act upon the results.
Code:
struct swParam swMath(unsigned int *p);
Within main I call the function which happens to exists in file2.c
This function gets called on a timer and modifies the variables
After returning from the function in main I look at these variables and decide whether or not (through logic) on how to proceed. At different points within the logic I may or may not clear the variables. (I do not want to clear them within the function)....Can someone please point me in the right direction on how to do this?? I'm very lost here.....Basically I want to initialize variables in main, call a function periodically that can modify these variables, use them in main and allow main to also possibly modify them....If I place everything in main all works fine
Thanks