接口原理图如下:
由原理图可知收发需要收UART_CTS引脚控制,高电平时接收,低电平时发送。通过查看Documentation/devicetree/bindings/serial/fsl-imx-uart.yaml和Documentation/devicetree/bindings/serial/rs485.yaml两个说明文档,修改设备树中的设置如下:
pinctrl_uart3dce: uart3dcegrp {fsl,pins = <MX6UL_PAD_UART3_TX_DATA__UART3_DCE_TX 0x1b0b1MX6UL_PAD_UART3_RX_DATA__UART3_DCE_RX 0x1b0b1MX6UL_PAD_UART3_CTS_B__UART3_DCE_CTS 0x1b0b1>;
};
&uart3 {pinctrl-names = "default";pinctrl-0 = <&pinctrl_uart3dce>;fsl,uart-has-rtscts;linux,rs485-enabled-at-boot-time;rs485-rts-active-high;rs485-rts-delay = <1 1>;status = "okay";
};
这样修改后就可以直接使用RS485接口了,不需要在应用程序中配置485功能了。
参考文档https://www.codetd.com/en/article/14965651