I have a setup where I need to pass data to an interrupt. This is done through a global variable. But the issue I am facing is that this setup might be called from an interrupt and interrupts might nest. So I need the following setup:
- Saved current value of global variable to variable on stack.
- Call interrupt.
- Restore value from variable on stack to global variable
I implemented this as follows:
extern volatile void* intrBlockObject;
...
volatile void* storeAddr = intrBlockObject;
intrBlockObject = object;
if (increase){
CALLSUPERVISOR(SVC_multiObjectIncrease);
} else {
CALLSUPERVISOR(SVC_multiObjectDecrease);
}
intrBlockObject = storeAddr;
This CALLSUPERVISOR part is an macro which translates to an interrupt.
This works, until an optimizer gets into play. Is there a setup possible for this problem where I can explain to the optimizer what I want? I would like to do this without compiler specific instructions, just in plain C.
Aucun commentaire:
Enregistrer un commentaire