Reputation: 583
I have a pointer which is being passed into a function like so:
unsigned char globalvar;
int functionexp(unsigned char *buff){
globalvar = buff;
//start interrupt
//wait for end of interrupt
//pass original pointer back with updated results
}
void __attribute__((interrupt, no_auto_psv)) _DMA2Interrupt(void) {
globalvar = somedata;
}
And I have an interrupt which collects data that I need to pass into said pointer. What I want to do is create a global dummy variable and copy the original pointer (bufF) address into this global variable, so when I write data to the global variable which I can access within the interrupt (as I can't pass the original pointer into the interrupt) it also updates the values in the original pointer.
My example shows the basis of what I want to do, but without the pointer syntax. Could someone please show me how to do this, please!
Upvotes: 0
Views: 820
Reputation: 456
Your question isn't entirely clear. My first interpretation of what I thought you're trying to do, it would be something like this:
unsigned char **buffptr;
int functionexp(unsigned char *buff){
buffptr = &buff;
//start interrupt
//wait for end of interrupt
//pass original pointer back with updated results
// after this point, the value of buffptr is completely useless,
// since buff doesn't exist any more!
}
void __attribute__((interrupt, no_auto_psv)) _DMA2Interrupt(void) {
*buffptr = somedata;
// this changes the 'buff' variable in functionexp
}
On the other hand you could simply mean this:
unsigned char *globalbuff;
int functionexp(unsigned char *buff){
globalbuff = buff;
//start interrupt
//wait for end of interrupt
//pass original pointer back with updated results
}
void __attribute__((interrupt, no_auto_psv)) _DMA2Interrupt(void) {
globalbuff[0] = somedata;
// this changes data inside the buffer pointed to by the 'buff'
// variable in functionexp
}
Upvotes: 2