i've created a simple event test program. It seems like the main thread broadcasts to the event source, but this isn't registered in the 'myThread' thread. What did i miss here?
Code: Select all
#include "ch.h"
#include "hal.h"
#include "chprintf.h"
#include "include/configuration.h"
void thread_start(void);
uint16_t cycles=0;
event_source_t es1;
int main(void)
{
halInit();
chSysInit();
debugInit();
bool buttonStatus=false;
palSetPadMode(GPIOC, 13, PAL_MODE_INPUT_PULLUP);
debugStart(&DBGD1, &debug_config);
EVENTSOURCE_DECL(es1);
thread_start();
while (true) {
buttonStatus=(bool) palReadPad(GPIOC, 13);
DEBUG_LOG(true, DEBUG_LEVEL_INFO, "main: %d; %d \n\r",cycles,buttonStatus);
cycles++;
chThdSleepMilliseconds(100);
chEvtBroadcast(&es1);
}
}
static THD_WORKING_AREA(myThread_working_area, 128);
static THD_FUNCTION(my_thread, arg) {
(void)arg;
chRegSetThreadName("my_thread");
event_listener_t el1;
chEvtRegister(&es1,&el1,0);
while (true) {
chEvtWaitAny(ALL_EVENTS);
DEBUG_LOG(true, DEBUG_LEVEL_INFO, "myThread \n\r");
}
}
void thread_start(void) {
chThdCreateStatic(myThread_working_area,
sizeof(myThread_working_area), NORMALPRIO,
my_thread, NULL);
}