zoukankan      html  css  js  c++  java
  • 【分享】通过MIO接入外设中断.md

    Zynq-7000和MPSoC有很多MIO管脚。如果外设有中断,也可以通过MIO驱动。

    GPIO中断控制器

    按下列模式,在GPIO的设备树里声明为中断控制器

    &gpio0 {
            #interrupt-cells = <2>;
            interrupt-controller;
    };
    

    外设使用GPIO中断控制器

    外设的设备树里,添加下列行,声明gpio0为自己的中断控制器,并声明对应的MIO引脚和中断内心。

    touchscreen@0 {
        interrupt-parent = <&gpio0>;
        interrupts = <52 2>;          /* MIO 52, falling edge */
    };
    

    检查结果

    单板启动后,可以检查启动信息和中断信息。

    # dmesg | grep ads
    ads7846 spi32766.0: touchscreen, irq 148
     
    # cat /proc/interrupts
    CPU0 CPU1
    148: 21 1 zynq-gpio 52 ads7846
    

    文档

    GPIO的中断说明,在Linux的文件Documentation/devicetree/bindings/gpio/gpio-zynq.txt里。

    中断的相关信息如下:

    - interrupt-controller   : Marks the device node as an interrupt controller.
    - #interrupt-cells : Should be 2.  The first cell is the GPIO number.
                           The second cell bits[3:0] is used to specify trigger type and level flags:
                               1 = low-to-high edge triggered.
                               2 = high-to-low edge triggered.
                               4 = active high level-sensitive.
                               8 = active low level-sensitive.
    

    参考文档

    https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842482/Device+Tree+Tips

  • 相关阅读:
    PAT 1018. 锤子剪刀布
    PAT 1017. A除以B
    PAT 1016. 部分A+B
    PAT 1015. 德才论
    PAT 1014. 福尔摩斯的约会
    PAT 1013. 数素数
    PAT 1012. 数字分类
    PAT 1011. A+B和C
    292. Nim Game
    412. Fizz Buzz
  • 原文地址:https://www.cnblogs.com/hankfu/p/14049600.html
Copyright © 2011-2022 走看看