DESK-MX6-L/Pheripherals/UART

From DAVE Developer's Wiki
< DESK-MX6-L
Revision as of 15:19, 27 May 2022 by U0007 (talk | contribs)

(diff) ← Older revision | Approved revision (diff) | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
History
Version Issue Date Notes

1.0.0

Oct 2020 First DESK release

2.0.0

Feb 2022 DESK 3.0.0 release
2.0.1 Apr 2022 Add RS282/RS485 setting mode


Peripheral UART[edit | edit source]

Device tree configuration[edit | edit source]

Here below an example of device tree configuration used on standard DAVE's kit for the AXELLite SOM:

From imx6qdl-sbcx-revb-common.dtsi:

&uart2 {
	fsl,uart-has-rtscts;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_dwm_uart2_1>;
	status = "okay";
};

From imx6qdl-axelcommon.dtsi:

    uart2 {
        pinctrl_dwm_uart2_1: dwm_uart2_grp-1 {
            fsl,pins = <
                MX6QDL_PAD_SD3_DAT4__UART2_RX_DATA 0x1b0b1
                MX6QDL_PAD_SD3_DAT5__UART2_TX_DATA 0x1b0b1
                MX6QDL_PAD_SD3_CMD__UART2_CTS_B 0x1b0b1
                MX6QDL_PAD_SD3_CLK__UART2_RTS_B 0x1b0b1
            >;
        };

Accessing the peripheral[edit | edit source]

Linux messages at boot time[edit | edit source]

...
...
[    1.010016] 21e8000.serial: ttymxc1 at MMIO 0x21e8000 (irq = 78, base_baud = 5000000) is a IMX
[    1.011009] 21ec000.serial: ttymxc2 at MMIO 0x21ec000 (irq = 79, base_baud = 5000000) is a IMX
[    2.198543] 21f0000.serial: ttymxc3 at MMIO 0x21f0000 (irq = 80, base_baud = 5000000) is a IMX
[    2.208297] 21f4000.serial: ttymxc4 at MMIO 0x21f4000 (irq = 81, base_baud = 5000000) is a IMX
...
...
root@imx6qxelk:~#

Configuring the RS232/RS485 mode[edit | edit source]

When the UART5 (aka /dev/ttymxc4 device in Linux) is properly configured using the hardware jumpers (see Interfaces and Connectors - UART5 EVK page), the MultiProtocol transceiver pins has to be initialized for setting the related user selectable modes: the RS232 or RS485 mode can be selected with the gpio-leds class and the led rs232_on.

From imx6q-sbcx-cb0012.dts or imx6dl-sbcx-cb0012.dts:

    leds {
	compatible = "gpio-leds";
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_rs232_485_422_1>;

	rs232_485_422 {
		gpios = <&gpio7 13 GPIO_ACTIVE_HIGH>;
		linux,default-trigger = "default-on";
	};

	rs232_on {
		gpios = <&gpio5 29 GPIO_ACTIVE_LOW>;
		linux,default-trigger = "default-on";
	};
    };
RS232 mode[edit | edit source]

This is the default protocol mode; this can be also activated (when different) using the following command:

root@desk-mx6:~# echo 0 > /sys/class/leds/rs232_on/brightness
RS485 mode[edit | edit source]

This mode can be activated using the following command:

root@desk-mx6:~# echo 255 > /sys/class/leds/rs232_on/brightness

Usage with stty[edit | edit source]

N.B. UART mapping respect to ttymxcX is the following one:

UART1 <-> ttymxc0
UART2 <-> ttymxc1
UART3 <-> ttymxc2
UART4 <-> ttymxc3
...
root@desk-mx6:~# stty -F /dev/ttymxc3 115200 -echo
root@desk-mx6:~# cat /dev/ttymxc3 &
[2] 555
root@desk-mx6:~# echo "Test loopback" > /dev/ttymxc3
root@desk-mx6:~# Test loopback

Additional information[edit | edit source]

Serial ports can be used through the standard serial programming API.

For detailed information, please refer to the Serial Programming HOWTO at Serial-Programming-HOWTO