Hi, I've got 2 threads;
Brain Thread => Responsible from state machine
Terminal Thread => Responsible from Uart communication
When Brain wants to open UART communication it signals the Terminal via Event Flag, and wait till the result of "open uart operation" via Event Flag.
tx_event_flags_set (&tthd_events, OPEN_UART_EVENT, TX_OR);
// Wait till terminal thread returns the result.
if (TX_SUCCESS == tx_event_flags_get (&tthd_events, OPEN_UART_SUCCESS | OPEN_UART_FAIL, TX_OR_CLEAR, &tthd_evnts.u32byte, TX_WAIT_FOREVER))
if (1 == tthd_evnts.bits.open_uart_suc)
I can't be sure if this is the right design. Brain thread has to wait till the result of "open UART operation" therefore I have to block the application till get a result, but this time I've got lines of code for just opening the UART.
I could have done this by just simply calling the method of Terminal thread like this:
Can someone help me which one is better in terms of multithread embedded application design? I believe first one is better design, but i think there should be a better way to get the result of operation, other than waiting via another event flags.