defined as but1 and but2 in the header file
And this is the problem. You "worked around" the link errors by declaring the variables static, but this just gave you a separate copy in each of the files that includes the header. What you should do instead is the following. In header.h:
extern LIS302 acc;
extern MobileLCD lcd;
extern Serial pc;
extern InterruptIn but1;
extern InterruptIn but2;
extern InterruptIn but3;
In main.cpp (after including header.h):
LIS302 acc(p11,p12,p13,p14); //define pinouts for accelerometer
MobileLCD lcd(p5,p6,p7,p8,p9); //define pinouts for LCD
Serial pc(USBTX,USBRX); //define pinouts for USB comms if needed
InterruptIn but1 (p21);
InterruptIn but2 (p22);
InterruptIn but3 (p23);
This way you
declare the variables in the header, so that everyone can access them, but
define them in one file, so you get a single instance of each variable in the program.
I've written a program with a number of different graphical functions nested within different component files. My 'main' code directs the program to a menu system, which by using 2 seperate interrupts (defined as but1 and but2 in the header file), scrolls through the menu options and allows selection of one of the functions. This works fine.
The problem emerges when I attempt to link back to the menu from one of the graphical functions using one of the same interrupts, I'll write something like:
but1.fall(&menuscreen);
But the interrupt will not respond. I've tried a huge amount of different combinations of functions and rising & falling edge triggers, defining new interrupts on new pins, but after the first function with interrupts present, they will not work in any other function!
Can someone shed any light on this?
TIA,
Auberon