Thread parameter - struct
Posted: Tue May 22, 2018 7:43 am
Hello!
I'm trying to pass parameters in the thread.
I already understood that this requires a structure, but then I stopped
I'm getting a compiler error
I'm trying to pass parameters in the thread.
I already understood that this requires a structure, but then I stopped
Code: Select all
/*
* Поток мигания светодиодом
*/
static THD_WORKING_AREA(waThreadBlink, 128);
static msg_t ThreadBlink(void *arg) {
(void)arg;
chRegSetThreadName("blinker");
palSetPadMode(GPIOC, GPIOC_LED, PAL_MODE_OUTPUT_PUSHPULL);
while (TRUE)
{
palTogglePad(GPIOC, GPIOC_LED);
chThdSleepMilliseconds(arg->time2);
}
return (msg_t) 0;
}
Code: Select all
struct OWStruct
{
uint32_t timer;
uint32_t time2;
}OWStruct;
Code: Select all
OWStruct.time2=100;
chThdCreateStatic(waThreadBlink, sizeof(waThreadBlink), NORMALPRIO, ThreadBlink,&OWStruct);
I'm getting a compiler error
error: request for member 'time2' in something not a structure or union