[En-Nut-Discussion] Questions regarding UART implementation

Thiago A. Corrêa thiago.correa at gmail.com
Tue Sep 28 16:57:23 CEST 2010


Hi Ulrich,

    Sorry for taking so long to reply. In my application we use a
couple ioctl's for the UART, like GETSTATUS, SETSTATUS, SETSPEED,
etc... But from those listed, we only use this one:

> /*! \brief UART _ioctl() command code to set the flow control mode.
>  *
>  * The configuration parameter specifies the flow control mode.
>  */
> #define UART_SETFLOWCONTROL     0x0111
>
> This option definately needs some more explanation about the parameters,
> as flow control can be...
> Hardware: RTS/CTS and DSR/DTR and may be DCD
> Software: XON/XOFF and STX/ETX


We are using the atmega128 on this one, so there is only XON/XOFF and
RTS/CTS. We use as arguments the USART_MF_* macros like this:

  // Use No Flow Control
  _ioctl( _fileno( data->serialPort ), UART_GETFLOWCONTROL, &temp );
  temp &= ~USART_MF_XONXOFF;
  temp &= ~( USART_MF_CTSSENSE | USART_MF_RTSCONTROL);
  _ioctl( _fileno( data->serialPort ), UART_SETFLOWCONTROL, &temp );


The DTR can be controled by an ioctl command, but it toggles like a
GPIO, it's never used for actual flow control. The difference here is
that I can write a serial handling routine that can toggle the DTR
signal at will without it knowing to which serial port it's talking to
and how the board is wired. That info is in the .conf file

In my app, we use the DTR to let the serial device know that there is
a TCP connection for it to talk to, which is basically what the DTR
signal was for in the old days :)

I belive those macros were all from the BSD interfaces that Nut/OS was
originally based from.

Kind Regards,
    Thiago A. Correa



More information about the En-Nut-Discussion mailing list