基于STM32CT117E竞赛板(STM32f103RB)按键控制LED,单片机与LED通过M74HC57连接,我们要进行GPIO的初始化,LED灯端口为GPIOC_Pin_8-GPIOC_Pin_15脚设置为复用推挽输出,另外也要初始化与M74HC57上的LE(锁存控制端)连接的GPIOD_Pin_2脚。此程序中按键设置(按照CT117E竞赛板上的按键B1、B2、B3、B4对应程序中的N_K1、N_K2、N_K3、N_K4对应端口为GPIOA_Pin_0、GPIOA_Pin_8、GPIOB_Pin_1、GPIOB_Pin_2初始化为复用浮空输入)
要注意GPIO时钟初始化
#include "stm32f10x_gpio.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_rcc.h"#include "stm32f10x.h"#include "core_cm3.h"#include "misc.h"#define LED0 GPIO_Pin_8#define LED1 GPIO_Pin_9#define LED2 GPIO_Pin_10#define LED3 GPIO_Pin_11#define LED4 GPIO_Pin_12#define LED5 GPIO_Pin_13#define LED6 GPIO_Pin_14#define LED7 GPIO_Pin_15#define LED_ALL (LED0 | LED1 | LED2 | LED3 | LED4 | LED5 | LED6 | LED7)#define LED_PORT GPIOC#define N_LE GPIO_Pin_2#define N_LE_PORT GPIOD#define SWN 4 /*????*/#define N_K1 GPIO_Pin_0#define N_K2 GPIO_Pin_