T113-S3 RS485驱动实现
-
首先按照T527 BSP内核增加RS485驱动代码
https://github.com/chainsx/linux-t527/blob/main/bsp/drivers/uart/sunxi-uart.c
修改完成后,增加设备树:&uart3 { pinctrl-names = "default", "sleep"; pinctrl-0 = <&uart3_pins_a>; pinctrl-1 = <&uart3_pins_b>; status = "okay"; sunxi,uart-rs485 = <1>; sunxi,uart-485fl = <0>; sunxi,uart-485oe-gpios = <&pio PE 10 GPIO_ACTIVE_HIGH>; }; &uart5 { pinctrl-names = "default", "sleep"; pinctrl-0 = <&uart5_pins_a>; pinctrl-1 = <&uart5_pins_b>; status = "okay"; sunxi,uart-rs485 = <1>; sunxi,uart-485fl = <0>; sunxi,uart-485oe-gpios = <&pio PE 11 GPIO_ACTIVE_HIGH>; };
sunxi,uart-rs485 是否开启rs485
sunxi,uart-485fl 485 DR线极性
sunxi,uart-485oe-gpios 485 DR线IO口
配置完成后修改menuconfig,打开minicom,编译,烧录
输入minicom -s,选择设备树中配置的串口,务必关闭硬件流控
修改完选择Save setup as dfl,然后Exit,修改完成,此时可实现自收发,方向线由驱动层自动控制
Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号