树莓派4B将GPIO 28-31映射到PCA9536设备树示例
时间: 2023-08-05 18:10:36 浏览: 122
树莓派+GPIO控制
好的,以下是将树莓派4B的GPIO 28-31映射到PCA9536的设备树示例代码:
```dts
/ {
// ...
i2c2 {
// ...
pca9536: pca9536@22 {
compatible = "nxp,pca9536";
reg = <0x22>;
gpio-controller;
#gpio-cells = <2>;
interrupt-parent = <&gpio>;
interrupts = <16 0>;
};
};
};
&gpio {
pca9536_int: gpio@28 {
compatible = "gpio";
gpio-controller;
#gpio-cells = <2>;
interrupt-controller;
interrupt-parent = <&gpio>;
interrupts = <16 0>;
gpio-line-names = "pca9536_int";
};
};
&i2c2 {
// ...
pca9536_0: gpio-expander@22 {
compatible = "pca9536";
reg = <0x22>;
gpio-controller;
#gpio-cells = <2>;
interrupt-parent = <&gpio>;
interrupts = <16 0>;
gpio-bank = <1>;
gpio-offset = <0>;
gpio-base = <28>;
};
};
```
这段代码中,首先在设备树中定义了 PCA9536 节点,并将其设置为 gpio-controller。接着,在 gpio 节点中定义了 PCA9536 的中断引脚,并将其设置为 interrupt-controller。最后,在 i2c2 节点中定义了 PCA9536 引脚映射的相关信息,包括 gpio-bank、gpio-offset 和 gpio-base。这样就完成了将树莓派4B的GPIO 28-31映射到PCA9536的设备树配置。
阅读全文