Hello,
I'm used to creating objects in C++ and returning the value of private variables using public functions for other tasks to access.
Since I'm working in C, I am trying to do something similar. I realize I could just use a global variable to pass to other tasks, but using a function to return the value makes things easier to understand where the value is coming from for someone else viewing the code (in my opinion at least).
I am using a function that solely returns a value a global pointer is pointing to.
Code:
u8 Get_Go_State(void)
{
return (Global_Button_State_Pointer->Rocker_GO);
}
This is how I declare the structure and pointer.
Code:
// .h
typedef struct Rocker_Switch {
u8 Rocker_GO;
u8 Rocker_STOP;
} Rocker_STOP_GO;
extern Rocker_STOP_GO *Global_Button_State_Pointer;
//.c
Rocker_STOP_GO *Global_Button_State_Pointer;
void Button_Task_Run (void)
{
Rocker_STOP_GO Rocker_State;
Global_Button_State_Pointer = &Rocker_State;
...
}
While in the button task, I receive the proper values when I run the return function, but when I'm in a different task, I only get a 4 when the return function is called. How do I get the actual value stored in Rocker_State.Rocker_GO to a different task?
I've tried searching for solutions, but found none.