[En-Nut-Discussion] BugFix: Usart half duplex mode doesn't toggle pin

Damian Slee damian at commtech.com.au
Tue Feb 17 10:45:23 CET 2004


Transmit complete interrupt which is required, is only enabled if
halfduplex mode is enabled before the uart is initialised.

Normally one would open the device, the call SETFLOWCONTROL, in which
case transmit complete interrupt never gets enabled.

static int AvrUsartSetFlowControl(u_long flags)
{
...
#ifdef UART_HDX_BIT
    /*
     * Set half duplex mode.
     */
    if (flags & USART_MF_HALFDUPLEX) {
        /* Register transmit complete interrupt. */
        if (NutRegisterIrqHandler(&sig_UART_TRANS, AvrUsartTxComplete,
&dcb_usart.dcb_rx_rbf)) {
            return -1;
        }
        /* Initially enable the receiver. */
        cbi(UART_HDX_PORT, UART_HDX_BIT);
        sbi(UART_HDX_DDR, UART_HDX_BIT);
        hdx_control = 1;
//----->
        /* Enable transmit complete interrupt. */
        sbi(UCSRnB, TXCIE);
//<-----
    } else if (hdx_control) {
        hdx_control = 0;
//----->
		/* disable transmit complete interrupt */
		cbi(UCSRnB, TXCIE);
//<-----
        /* Deregister transmit complete interrupt. */
        NutRegisterIrqHandler(&sig_UART_TRANS, 0, 0);
        cbi(UART_HDX_DDR, UART_HDX_BIT);
    }
#endif
...
}




More information about the En-Nut-Discussion mailing list