Page 1 of 1

serial driver with event

Posted: Sat Apr 25, 2015 4:45 pm
by deadlyboy
hi every body

i have 2 micro controller connected to each other through USART ,one(stm32f103) send data through uart driver and other stm32f407 get the data through serial driver.

as giovanni mentioned in forum to handle serial driver i created thread and put the code there.

here is my code but , there are problems

Code: Select all

static WORKING_AREA(Thread_Unit, 128);
static msg_t Thread1(void *arg) {
  (void)arg;
  chRegSetThreadName("FM");

  flagsmask_t flags;
  EventListener s4EventListener;
  chEvtRegisterMask((EventSource *)chnGetEventSource(&SD4), &s4EventListener,EVENT_MASK(1));


  int i=0;
  while (TRUE)
  {

    chEvtWaitOneTimeout(EVENT_MASK(1),MS2ST(10));

    chSysLock();
    flags = chEvtGetAndClearFlags(&s4EventListener);palSetPad(GPIOD,15);
    chSysUnlock();

    if (flags & CHN_INPUT_AVAILABLE) {
          /* Data available read here.*/
        //sdReadTimeout(&SD4, message, sizeof(message), TIME_IMMEDIATE);

    }

    if (flags & CHN_OUTPUT_EMPTY) {
          /* Data sent, you may transmit from here.*/
    }
    if (flags & (SD_PARITY_ERROR | SD_FRAMING_ERROR | SD_OVERRUN_ERROR |
                     SD_NOISE_ERROR | SD_BREAK_DETECTED)) {
          /* Some receive error happened.*/
    }
    palClearPad(GPIOD,12);
      //uartStartSend(&UARTD3,1,"b");

    chThdSleepMilliseconds(5);
  }
}


1- code stuck here after calling chEvtGetAndClearFlags function
chSysLock();
flags = chEvtGetAndClearFlags(&s4EventListener);
palSetPad(GPIOD,15);
chSysUnlock();


and 2nd - i get the error for chEvtWaitOneTimeout function : undefined reference to ' chEvtWaitOneTimeout'
but i replace that function with chEvtWaitOne without error.

CH_USE_EVENTS_TIMEOUT is true

any help please ,
thanks in advance
MA

Re: serial driver with event

Posted: Sat Apr 25, 2015 5:24 pm
by Giovanni
You are calling a normal API between lock/unlock, I assume you have the state checker enabled and it stops with an error.

Giovanni

Re: serial driver with event

Posted: Sat Apr 25, 2015 11:12 pm
by deadlyboy
thanks giovanni ,

i removed chSysLock(); and chSysUnlock() and it works well