0
点赞
收藏
分享

微信扫一扫

STM32MP157A驱动开发 | 01- 板载LED作为系统心跳指示灯


一、板载LED

STM32MP157A驱动开发 | 01- 板载LED作为系统心跳指示灯_设备树


此用户LED连接到PA13。

二、pinctrl描述

绑定文档:Documentation/devicetree/bindings/pinctrl/st,stm32-pinctrl.yaml。

必要的属性:

- compatible
- '#address-cells'
- '#size-cells'
- ranges
- pins-are-numbered

可用值如下:

:
enum:
- st,stm32f429-pinctrl
- st,stm32f469-pinctrl
- st,stm32f746-pinctrl
- st,stm32f769-pinctrl
- st,stm32h743-pinctrl
- st,stm32mp157-pinctrl
- st,stm32mp157-z-pinctrl

'#address-cells':
const: 1
'#size-cells':
const: 1

ranges: true
pins-are-numbered:

文档里给出了一个描述串口引脚的示例:

{
usart1_pins_a: usart1-0 {
pins1 {
pinmux = <STM32_PINMUX('A', 9, AF7)>;
bias-disable;
drive-push-pull;
slew-rate = <0>;
};
pins2 {
pinmux = <STM32_PINMUX('A', 10, AF7)>;
bias-disable;
};
};
};

usart1 {
pinctrl-0 = <&usart1_pins_a>;
pinctrl-names = "default";
};

二、作为用户LED

1. 设备树描述

添加pinctrl描述,将PA13作为普通gpio:

&pinctrl {
led_pins_a: led-0 {
pins {
pinmux = <STM32_PINMUX('A', 13, GPIO)>; /* USER_LED */
};
};
};

添加led节点描述:

{
compatible = "gpio-leds";
pinctrl-0 = <&led_pins_a>;

blue {
label = "blue";
gpios = <&gpioa 13 GPIO_ACTIVE_LOW>;
default-state = "off";
};
};

2. 测试

重新编译设备树,启动。

STM32MP157A驱动开发 | 01- 板载LED作为系统心跳指示灯_stm32_02

三、作为系统心跳LED

{
compatible = "gpio-leds";
pinctrl-0 = <&led_pins_a>;

heartled {
label = "heartled";
gpios = <&gpioa 13 GPIO_ACTIVE_LOW>;
linux,default-trigger = "heartbeat";
default-state = "off";
};
};


举报

相关推荐

0 条评论