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