Code: Select all
#define debugU(...) chprintf((BaseSequentialStream*)&SDU1, __VA_ARGS__)
..snip..
uint32_t evt;
const eventmask_t RX_USB = EVENT_MASK(1);
const eventmask_t RX_SD1 = EVENT_MASK(2);
chprintf(chp, "[Serial Console] BAUD set to %d\r\n", baud);
sd1cfg.speed = baud;
sdStart(&SD1, &sd1cfg);
chEvtRegisterMaskWithFlags((event_source_t *)chnGetEventSource(&SDU1),
&elRxTx, RX_USB, CHN_INPUT_AVAILABLE);
chEvtRegisterMaskWithFlags((event_source_t *)chnGetEventSource(&SD1), // <-- This Line
&elRxTx, RX_SD1, CHN_INPUT_AVAILABLE);
while (1) {
debugU(","); // <-- Debug outputs
evt = chEvtWaitAny(RX_USB | RX_SD1);
debugU("."); // <-- Debug outputs
chEvtGetAndClearFlags(&elRxTx);
if (evt == RX_USB) {
from = chpu;
to = chp1;
}
else if (evt == RX_SD1) {
from = chp1;
to = chpu;
}
else {
cbuf = Q_RESET;
}
while (cbuf != Q_TIMEOUT && cbuf != Q_RESET) {
cbuf = chnGetTimeout(from, TIME_IMMEDIATE);
chnPutTimeout(to, cbuf, TIME_IMMEDIATE);
}
cbuf = 0;
}
The line marked with comment is somewhat problematic. If I comment out that line, I can receive events when typing in serial console. No problem -- the debug shows "," and ".". However, if I put in that line(i.e. listening to both serial devices), the program seems to block at event waiting -- only "," is displayed, no matter what I type in the console. I tried chEvtRegister, but it is the same.
The block of code is snipped from a shell function.