0

次のように関数に渡されるポインターがあります。

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;
}

そして、上記のポインターに渡す必要があるデータを収集する割り込みがあります。私がしたいのは、グローバルダミー変数を作成し、元のポインター (bufF) アドレスをこのグローバル変数にコピーすることです。そのため、割り込み内でアクセスできるグローバル変数にデータを書き込むとき (元のポインターを渡すことができないため)元のポインタの値も更新します。

私の例は、私がやりたいことの基礎を示していますが、ポインター構文はありません。誰かがこれを行う方法を教えてください。

4

1 に答える 1

2

あなたの質問は完全に明確ではありません。あなたがやろうとしていることについての私の最初の解釈は、次のようなものです。

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
}

一方、単にこれを意味することもできます:

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
}
于 2013-07-11T22:35:09.513 に答える