2.GPIO按键中断测试
该教程演示如何通过开发板的GPIO实现按键中断。
一、准备工作
- 准备1块BearPi-Pico H2821开发板
二、编译代码
在Windows下编译操作
点击左侧的“KConfig”,打开配置界面.
选择Support BUTTON Sample
Application ---> [*] Enable Sample. [*] Enable the Sample of peripheral. [ ] Enable all the sample of peripheral, it's just for build. [ ] Support ADC Sample. [ ] Support BLINKY Sample. [*] Support BUTTON Sample. BUTTON Sample Configuration --->
设置按键的GPIO,GPIO02为例。
BUTTON Sample Configuration ---> (2) Choose BLINKY_PIN pin. (NEW)
按下"Save"键保存配置。
编译烧录固件
参考环境搭建教程编译烧录代码
在Ubuntu下编译操作
在MobaXterm中输入:
./build.py menuconfig
选择Support BUTTON Sample
Application ---> [*] Enable Sample. [*] Enable the Sample of peripheral. [ ] Enable all the sample of peripheral, it's just for build. [ ] Support ADC Sample. [ ] Support BLINKY Sample. [*] Support BUTTON Sample. BUTTON Sample Configuration --->
设置按键的GPIO,GPIO02为例。
BUTTON Sample Configuration ---> (2) Choose BLINKY_PIN pin. (NEW)
按下"ESC"键退出并保存配置。
编译烧录固件
参考环境搭建教程编译烧录代码
三、测试
烧录固件后按下开发的复位按键,用杜邦线将GPIO02与GND短接来模拟按键按下,观察开发板的日志打印。