Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    rs485的设备树怎么修改

    其它全志芯片讨论区
    4
    6
    4457
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Z
      ZiFeiYu LV 5 last edited by

      本人新手,想做一个485通信的实验。修改了board.dts设备树如图
      8c28b411-83e7-4f09-b8ee-e466da2cddee-image.png
      c73b1c48-750d-4a9a-957c-0eb2d3a4225b-image.png
      a8454423-41c1-43a1-b5d8-dfa0a9d5635e-image.png

      但是485端口链接usb转485设备,设备提示灯都不亮,不知道哪里出了问题

      A 1 Reply Last reply Reply Quote Share 0
      • A
        awwwwa LV 8 @ZiFeiYu last edited by awwwwa

        @zifeiyu

        DE和RO为使能管脚。DE为低电平、RE为低电平时为接收;DE为高电平、RE为高电平时为发送;RO和DI为数据管脚。RO为接收,DI为发送;因此我们经常将DE和RE直接连接,用一个IO口控制。

        需要添加以下三个成员:

        • sunxi,uart-rs485
          • 0:485模式关闭
          • 1:485模式使能
        • sunxi,uart-485fl
          • 0:485 gpio管脚数值为0时表示发送状态
          • 1:485 gpio管脚数值为1时表示发送状态
        • sunxi,uart-485oe-gpios
          • 用于外部转换芯片使能信号的gpio引脚,GPIO_ACTIVE_HIGH含义为默认为高电平

        示例:

        uart1: uart@2500400 {
        			...
        			status = "okay";
        			//添加以下三行
        			sunxi,uart-rs485 = <1>;
        			sunxi,uart-485fl = <1>;
        			sunxi,uart-485oe-gpios = <&pio PG 8 GPIO_ACTIVE_HIGH>;
        };
        

        A40I 5.10 内核:

        uart5_pins_a: uart5_pins@0 {
        	pins = "PH6", "PH7";
        	function = "uart5";
        };
        
        uart5_pins_b: uart5_pins@1 {
        	pins = "PH6", "PH7";
        	function = "gpio_in";
        };
        
        &uart5 {
        	pinctrl-names = "default", "sleep";
        	pinctrl-0 = <&uart5_pins_a>;
        	pinctrl-1 = <&uart5_pins_b>;
        	rs485-enable = <0>;
        	rs485-mode = <0>;   /* defalut 0:rx 1:tx */
        	rs485-mode-pin = <&pio PH 8 GPIO_ACTIVE_LOW>;
        	status = "disabled";
        };
        
        Z Q 2 Replies Last reply Reply Quote Share 0
        • Z
          ZiFeiYu LV 5 @awwwwa last edited by

          @awwwwa 949cfc3a-704f-4864-825a-2d5479fee5d7-image.png
          这里直接连接了电源,设备树中还要加sunxi,uart-485oe-gpios这个属性吗,还是说这种情况有其他写法

          J 1 Reply Last reply Reply Quote Share 1
          • Q
            qqqlb LV 7 @awwwwa last edited by

            @awwwwa 你好。这两种设备树的485定义,我在5.4内核和5.10内核中都没有找到响应的定义,请问这是在哪个驱动代码里面实现的呢?我在a40-i的5.10内核,甚至没有找到sunxi-uart.c这个文件,这个正常吗?

            J 1 Reply Last reply Reply Quote Share 0
            • J
              Jingyan LV 6 @qinlinbin last edited by

              @qinlinbin 直接拉高就不需要这三个dts配置了,不过也只能实现单向通行,无法自动切换方向

              1 Reply Last reply Reply Quote Share 0
              • J
                Jingyan LV 6 @ZiFeiYu last edited by

                @zifeiyu max13487这款IC带自动方向识别,可以不需要这些dts配置,按照正常使用就可以

                1 Reply Last reply Reply Quote Share 0
                • 1 / 1
                • First post
                  Last post

                Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

                行为准则 | 用户协议 | 隐私权政策