termios support
Eric Norum
eric at skatter.USask.Ca
Tue May 5 16:01:29 UTC 1998
Geoffroy Montel <g_montel at yahoo.com> wrote:
> But, wouldn't it be better if
> void rtems_termios_dequeue_characters (void *ttyp, int len)
> would be stg like
> int rtems_termios_dequeue_characters (void *ttyp, int len)
> and we'd return the state of the buffer ? (for instance, 0 when
> it's empty
> so that we stop the interrupts then, and 1 otherwise)
>
No, that would be redundant.
Have a look at the example write and transmit interrupt routines.
I'll show them again since they're so short....
> =============================================================
> void
> device_write_routine (int minor, char *buf, int count)
> {
> UART->output_register = *buf;
> UART->control_register |= UART_TRANSMIT_INTERRUPT_ENABLE;
> }
>
> void
> device_transmit_interrupt_routine (int vector)
> {
> UART->control_register &= ~UART_TRANSMIT_INTERRUPT_ENABLE;
> rtems_termios_dequeue_characters (device_ttyp, 1);
> }
> =============================================================
Notice that the transmit interrupt service routine disables the
transmit interrupt before calling rtems_termios_dequeue_characters().
If the termios output buffer is empty,
rtems_termios_dequeue_characters () just returns to the interrupt
handler which returns and leaves the transmit interrupt disabled.
If the termios output buffer is not empty,
rtems_termios_dequeue_characters() calls device_write_routine () to
transmit the next character and reenable the transmit interrupt. The
device_write_routine returns to rtems_termios_dequeue_characters
which in turn returns to the interrupt handler which returns and will
again be invoked when the transmitter is ready.
---
Eric Norum eric at skatter.usask.ca
Saskatchewan Accelerator Laboratory Phone: (306) 966-6308
University of Saskatchewan FAX: (306) 966-6058
Saskatoon, Canada.
More information about the users
mailing list