I've written a SC16IS752IPW driver (2ch UART expander) for ChibiOS 2.x some time ago.
Todo I've tried it out with ChibiOS 3.x trunk.
It uses a custom SerialDriver object. New incoming bytes cause an event flag notification in the RX/TX thread.
When I use the 2.x code, I trigger this assertion:
Code: Select all
/* The following condition can be triggered by the use of i-class functions
in a critical section not followed by a chSchResceduleS(), this means
that the current thread has a lower priority than the next thread in
the ready list.*/
chDbgAssert((ch.rlist.r_queue.p_next == (thread_t *)&ch.rlist.r_queue) ||
(ch.rlist.r_current->p_prio >= ch.rlist.r_queue.p_next->p_prio),
"priority violation, missing reschedule");
I had to modify my code like this:
Code: Select all
static void txQueueNotifyA(io_queue_t* q) {
(void)q;
chEvtSignalI(sc16Thread, EVENT_TXA);
//Since ChibiOS 3
chSchRescheduleS();
}
I believe the manual reschedule call should not really be neccessary. Just like with chEvtSignal(), chEvtSignalI() should automatically reschedule. Maybe this is a corner case that has not been considered yet. As far as I know there are no tests (I searched the testhal and test folder) involving sdObjectInit().
Is there a better way to solve this?
Best regards, Uli