Event not regigistered

Discussions and support about ChibiOS/RT, the free embedded RTOS.
youcann
Posts: 1
Joined: Sun Jul 22, 2018 4:21 pm
Has thanked: 1 time

Event not regigistered

Postby youcann » Sun Jul 22, 2018 4:26 pm

Hello,

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);
}

User avatar
Giovanni
Site Admin
Posts: 12178
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 570 times
Been thanked: 487 times
Contact:

Re: Event not regigistered

Postby Giovanni » Sun Jul 22, 2018 5:35 pm

Hi,

You have two event sources "es1", the macro creates and (statically) initialize a new variable, it does not initialize an existing one.

Giovanni


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 1 guest