Need little help with pointer
Posted: Tue Apr 25, 2017 1:01 pm
Hello everybody, i make good progress with chibios and i like it.
Now i am programming a universal button and rotary encoder driver without the use of interrupts.
I create a thread which reads the button input pins. There is my problem. I have a pointer to a struct which i want to pass to the THD_FUNCTION as argument. Now i do:
whre rotp is the struct of type ROTARYDriver .
struct ROTARYDriver {
rot_state_t state;
const ROTARYConfig *config;
};
void rotaryStart(ROTARYDriver *rotp, const ROTARYConfig *config) //Start the Rotary Driver
{
...configuration of inputs....
chThdCreateStatic(waButtonReadThread, sizeof(waButtonReadThread), NORMALPRIO + 5, ButtonReadThread, &rotp); //Start the Thread which reads the inputs
}
and in:
static THD_FUNCTION(ButtonReadThread, arg)
{
BUTTON = palReadLine(rotp->config->pinmap->BTN); // Here is the Problem. I need a connection from "arg" to "rotp" and i don't know how
}
This is basic C-Programming knowledge and not necessarily STM32 or Chibios but maybe somebody can help.
Now i am programming a universal button and rotary encoder driver without the use of interrupts.
I create a thread which reads the button input pins. There is my problem. I have a pointer to a struct which i want to pass to the THD_FUNCTION as argument. Now i do:
whre rotp is the struct of type ROTARYDriver .
struct ROTARYDriver {
rot_state_t state;
const ROTARYConfig *config;
};
void rotaryStart(ROTARYDriver *rotp, const ROTARYConfig *config) //Start the Rotary Driver
{
...configuration of inputs....
chThdCreateStatic(waButtonReadThread, sizeof(waButtonReadThread), NORMALPRIO + 5, ButtonReadThread, &rotp); //Start the Thread which reads the inputs
}
and in:
static THD_FUNCTION(ButtonReadThread, arg)
{
BUTTON = palReadLine(rotp->config->pinmap->BTN); // Here is the Problem. I need a connection from "arg" to "rotp" and i don't know how
}
This is basic C-Programming knowledge and not necessarily STM32 or Chibios but maybe somebody can help.