Re: UART Flow Control

bon-1JbLm1bU5j5ZIx36JBfelj3+ndqKAYMe9FMPySWZwLkb1SvskN2V4Q@public.gmane.org Thu, 5 Mar 2020 21:00:17 +0100
Newsgroups gmane.comp.hardware.microcontrollers.ethernut
Message-ID <[email protected]>
Du=B9an writes:
> Hi guys,
> =

> we are working on a Nut/OS port for NXP Kinetis MK64F (LQFP100 - 144, =

> ethernet).
> Actual state can be seen here: https://github.com/dferbas/ethernut
> =

> Once tested, I plan to merge it with Nut.
> It does not use the NutUseCritical() macros.
> =

> ------------------------
> We have an issue with USART driver.
> We use the UART_SETFLOWCONTROL to set half duplex or full duplex and =

> also loopback modes.
> All this is done with RE, DE signals to 2 RS485 transceivers, nicely =

> hidden from an application through the ioctl.
> =

> The [r4163] <https://sourceforge.net/p/ethernut/code/4163/> added =

> XONXOFF only, which was later removed at
>
> [r4584] <https://sourceforge.net/p/ethernut/code/4584/> with following =

> remark:
> Do not fix flow control to XON/XOFF handshake.
> See =

> http://lists.egnite.de/pipermail/en-nut-discussion/2012-August/013821.html
> =

> ---
> As the dcb->dcb_modeflags should be hidden from an application,
> what was the intention to leave it as it is now?
> =

> What about to simply stay with the old version (#2555 - #4116):
>  =A0=A0=A0 case UART_SETFLOWCONTROL:
>  =A0=A0=A0 =A0=A0=A0 rc =3D (*dcb->dcb_set_flow_control) (lv);
>  =A0=A0=A0 =A0=A0=A0 break;
> =

> This allows everything to be passed from an application.

I recently also implemented XON/XOFF for STM32 and have following
patch not yet pushed to sourceforge:
commit 60a551843e2dd5cb4846939d50b03aaf0d50ce4e
Author: Uwe Bonnes <bon-1JbLm1bU5j5ZIx36JBfelj3+ndqKAYMe9FMPySWZwLkb1SvskN2V4Q@public.gmane.org>
Date:   Wed Feb 19 20:27:47 2020 +0100

    usart.c: We must relay XONXOFF to the dcb_modeflags.
    =

    Only relay dcb_modeflags. See http://lists.egnite.de/pipermail/en-nut-d=
iscussion/2012-August/013821.html.

diff --git a/nut/dev/usart.c b/nut/dev/usart.c
index a8228ef87..008dd036d 100644
--- a/nut/dev/usart.c
+++ b/nut/dev/usart.c
@@ -834,6 +834,11 @@ int UsartIOCtl(NUTDEVICE * dev, int req, void *conf)
 =

     case UART_SETFLOWCONTROL:
         lv =3D dcb->dcb_modeflags;
+        if (bv & USART_MF_XONXOFF) {
+            lv |=3D USART_MF_XONXOFF;
+        } else {
+            lv &=3D ~USART_MF_XONXOFF;
+        }
         rc =3D (dcb->dcb_set_flow_control) (lv);
         if (rc =3D=3D 0) {
             dcb->dcb_modeflags =3D lv;

This only changes XONXOFF, but keeps other settings, e.g. half-duplex etc.

What do you think of my solution?

As neither Harald nor Ole seem to lurk, the original intention of the
modification is probably lost.

Should I put up my nutos repo on github?

Bye
-- =

Uwe Bonnes                bon-1JbLm1bU5j5ZIx36JBfelj3+ndqKAYMe9FMPySWZwLkb1SvskN2V4Q@public.gmane.org

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 1623569 ------- Fax. 06151 1623305 ---------
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion