Ben F

sharing function pointers (s12x and xgate)

Discussion created by Ben F on Feb 12, 2007
Latest reply on Feb 14, 2007 by CompilerGuru
hi
i'm having some trouble sharing a function pointer from s12x to the xgate.
so far i have the following:
  • a s12x funktion wich fills a buffer with a pointer to the function the xgate is supposed to call
  • an xgate isr to trigger the xgate and perform the actual function call
  • the xgate function which is to be called

i have a simple scheduler on the xgate, and an a simple 'instruction queue' which is filled via the isr. whenever a new 'command' from the s12x is issued, an xgate isr is called which copies the buffer into an queue. in addition, every 10ms an xgate isr is called (the simple scheduler) which looksup the queue and performs the commands. everything works as intended except the adress translation. '&function' gives the right logical adress of my xgate function, but i'd need the xgate adress. is there an easy way to share function pointers? i could construct the right xgate adress from the logical adress, but that would be somewhat messy in the code. i hope you understand what i mean :smileywink:

here the (non-functional) code:

Code:

typedef void (* fkt_ptr_char)(char);struct xgate_shared_data { fkt_ptr_char fkt; unsigned char data;};//XGATE function prototypesinterrupt void Copy_Command(int value); //copies command into an queueinterrupt void PIT1(int value); //runs queued commands, every 10msvoid CallMe(char value); //the function to be called//S12X function prototypesbool issue_XGATE_command(fkt_ptr_char fkt, char data); //calls Copy_Command, fkt_ptr is correct logical adress, but not xgate adress//call somewhere in the s12x codeissue_XGATE_command( &__X_CallMe, 0x1);


 

Message Edited by benni on 2007-02-1212:56 PM

Message Edited by benni on 2007-02-1212:56 PM

Outcomes