In order to get an acknowledgment of transmission transactions on a serial driver, is it common practice to have to clear the flags and events prior to waiting only for a CHN_TRANSMISSION_END flag associated to an event mask?
It seems odd based on what I've read on events and the related examples I could find (haven't actually encounter one based on Tx end notifications), but without those previous calls I can't get it to work.
In the snippet below if the clearing calls to the write aren't there, the thread doesn't wait and it is as if the pending mask already matches the registered mask for every iteration.
Code: Select all
static THD_WORKING_AREA(waThread1, 128);
static THD_FUNCTION(Thread1, arg) {
event_listener_t listener;
chEvtRegisterMaskWithFlags (chnGetEventSource (&SD2),
&listener, EVENT_MASK (0),
CHN_TRANSMISSION_END);
while (true) {
// These clearing actions seem required
chEvtGetAndClearFlags (&listener);
chEvtGetAndClearEvents (EVENT_MASK (0));
sdWrite (&SD2, buff, sizeof (buf));
chEvtWaitOne (EVENT_MASK (0));
eventflags_t f = chEvtGetAndClearFlags (&listener);
if (f & CHN_TRANSMISSION_END)
{
// Actions after a guaranteed Tx transaction
}
}
}
Thanks