Multiple tasks woken from ISR in V5.0.2?

jhenshaw wrote on Thursday, June 26, 2008:

I’m running V5.0.2 on an Atmel AT3UCA0512. The UART ISR handles both transmitter empty and receiver full interrupts by either pulling a character from a queue or posting a character to a queue. If both conditions are simultaneously true then the ISR could potentially activate TWO tasks.

Is this possible, or illegal, or what? How would I handle this? Would I detect that the 1st task has been activated and ignore the 2nd interrupt cause, leaving the IRQ to fire again and then handling the 2nd interrupt source? Or do I just note that a task was activated and let taskYIELD_FROM_ISR() figure it out?

edwards3 wrote on Thursday, June 26, 2008:

No problem.

void interrupt_routine( void )
{
int Woken = 0;

  // Do something.

  // Send to a task. Woken will be set
  // to true if this send wakes a task.
  xQueueSendFromISR(q, &Woken);

  // Do something else.

  // Send to another task. Again, Woken
  // will be set to true if this send
  // wakes a task.
  xQueueSendFromISR(q2, &Woken);

  // Two sends so you might have woken
  // two tasks. FreeRTOS will have done
  // this for you, but will always return
  // to the highest priority ready task
  // which might be one of the two tasks
  // woken in this isr, or might be the
  // task that was originally running
  // anyway.
  portYIELD_FROM_ISR(Woken);
}

jhenshaw wrote on Thursday, June 26, 2008:

Great, thanks !!!