网站登录流程图,建设我们的网站,seo网址超级外链工具,品牌网站建设哪个好本文介绍了如何使用按键控制 MCU 引脚的输出电平。
原理
由原理图可知 板载用户按键 K1 和 K2 分别与主控的 PB0 和 PB1 相连。
代码
#define _MAIN_C_#include platform.h
#include gpio_key_input.h
#include main.hint main(void)
…本文介绍了如何使用按键控制 MCU 引脚的输出电平。
原理
由原理图可知 板载用户按键 K1 和 K2 分别与主控的 PB0 和 PB1 相连。
代码
#define _MAIN_C_#include platform.h
#include gpio_key_input.h
#include main.hint main(void)
{PLATFORM_Init();GPIO_KEY_Input_Sample();while (1){}
}函数 GPIO_KEY_Input_Sample()
void GPIO_KEY_Input_Sample(void)
{static uint8_t KeyState[2] {0, 0,};static uint8_t KeyCount[2] {0, 0,};printf(\r\nTest %s, __FUNCTION__);GPIO_Configure();printf(\r\nPress KEY1 or KEY2...);while (1){KEY_FSM_Handler(KeyState[0], KeyCount[0], GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0), Bit_RESET, KEY1);KEY_FSM_Handler(KeyState[1], KeyCount[1], GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1), Bit_RESET, KEY2);PLATFORM_LED_Enable(LED1, (FunctionalState)GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0));PLATFORM_LED_Enable(LED2, (FunctionalState)GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1));PLATFORM_DelayMS(10);}
}效果
按键控制 LED 总结
本文展示了板载按键控制 LED 的项目实现。