[En-Nut-Discussion] BugFix: Usart reading Xoff doesn't stop Tx

Damian Slee damian at commtech.com.au
Tue Feb 17 09:48:21 CET 2004


Also can we get the examples changed so they use the new Usart device
driver instead of Uart ole one.
Ie change
	NutRegisterDevice(&devUart0, 0, 0);
to
	NutRegisterDevice(&devUsartAvr0, 0, 0);


Also I haven't been able to get the driver to send an Xon or Xoff yet,
so I'm not sure if this is another problem, or something not set.  I
would have thought a call to this would send an XON imediately?
lTmp = USART_MF_XONXOFF;
_ioctl(fileno, UART_SETFLOWCONTROL, &lTmp);


Usartavr.c Tx Fix
static void AvrUsartTxEmpty(void *arg)
{
    register RINGBUF *rbf = (RINGBUF *) arg;
    register u_char *cp = rbf->rbf_tail;

    /*
     * Process pending software flow controls first.
     */
    if (flow_control & (XON_PENDING | XOFF_PENDING)) {
        if (flow_control & XON_PENDING) {
            outb(UDRn, ASCII_XOFF);
            flow_control |= XOFF_SENT;
        } else {
            outb(UDRn, ASCII_XON);
            flow_control &= ~XOFF_SENT;
        }
        flow_control &= ~(XON_PENDING | XOFF_PENDING);
        return;
    }
// Addition --->
    if (flow_control & XOFF_RCVD) {
        /* 
         * If XOFF has been received, we disable the transmit interrupts
         * and return without sending anything.
         */
        cbi(UCSRnB, UDRIE);
        return;
	}
// <---- end of Addition



More information about the En-Nut-Discussion mailing list