Hi,
I am struggling with the following and would like to know if the following would be possible.
The Scenario - I have a timer running and I have the ability to connect a function to the timer if it triggers. This works great but what if I want to pass to the pointer that triggered an argument as well.
For Example:
Code:
//The function have triggered by the Interrupt Timer
char Timer_Expired(char *Flag){
*Flag = True;
return *Flag;
}
Now I will use it as follows:
Code:
char Do_Something( char *Data, char Size){
char flagset = True;
SendData(Data, Size);
Hook_Function_to_Timer(&Timer_Expired(&flagset )); //This does not work
}
Code:
//Type Defs
typedef char (*ISR_FUNC_PTR)();//Something needs to change here I think.
/****************/
//Variables
static ISR_FUNC_PTR fptr;
The Interupt looks something like this:
#pragma vector=TIMERB0_VECTOR
__interrupt void timerISR(void)
{
if (fptr != NULL)
{
(*fptr)();//Something needs to change here I think.
}
__low_power_mode_off_on_exit();
}
Please can someone point me into the right direction. I basically want to pass the address of the function and the address of the variable to the interrupt that fires so to change the variable to False if the timer has trigger. I would like to stay away from global variables if possible.
Best Regards,
Gary