测试路径:zephyr\samples\hello_world
1. nrf5340dk_nrf5340_cpuapp.overlay文件的修改
/ {
buttons {
compatible = "gpio-keys";
/*p0.23*/
M_BUTTON1: m_button1 {
gpios = <&gpio0 23 (GPIO_PULL_UP|GPIO_ACTIVE_LOW)>;
label = "M_BUTTON1";
};
/*p*/
M_BUTTON2: m_button2 {
gpios = <&gpio1 6 (GPIO_PULL_UP|GPIO_ACTIVE_LOW)>;
label = "M_BUTTON2";
};
};
/*gpio 的引脚设置*/
m_gpio {
compatible = "gpio-leds";
M_GPIO1: m_gpio1 {
gpios = <&gpio0 26 (GPIO_PULL_UP|GPIO_ACTIVE_LOW)>;
label = "M_GPIO1";
};
};
};
2.prj.conf文件的修改
CONFIG_GPIO=y
3.main.c文件的修改
#include <drivers/gpio.h>
#include <hal/nrf_gpio.h>
#define gpio_1_PORT DT_GPIO_LABEL(DT_NODELABEL(m_gpio1), gp