serial driver with event

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
deadlyboy
Posts: 27
Joined: Wed Nov 26, 2014 9:27 am

serial driver with event

Post 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
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: serial driver with event

Post 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
deadlyboy
Posts: 27
Joined: Wed Nov 26, 2014 9:27 am

Re: serial driver with event

Post by deadlyboy »

thanks giovanni ,

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