#include "gpio.h" void beep_init(void) { RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE); GPIO_InitTypeDef GPIO_StructInit; GPIO_StructInit.GPIO_Mode = GPIO_Mode_OUT; GPIO_StructInit.GPIO_OType = GPIO_OType_PP; GPIO_StructInit.GPIO_Speed = GPIO_Speed_100MHz; GPIO_StructInit.GPIO_PuPd = GPIO_PuPd_UP; GPIO_StructInit.GPIO_Pin = GPIO_BEEP_PIN; GPIO_Init(GPIO_BEEP_PORT, &GPIO_StructInit); } void led_init(void) { RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE); GPIO_InitTypeDef GPIO_StructInit; GPIO_StructInit.GPIO_Mode = GPIO_Mode_OUT; GPIO_StructInit.GPIO_OType = GPIO_OType_PP; GPIO_StructInit.GPIO_Speed = GPIO_Speed_100MHz; GPIO_StructInit.GPIO_PuPd = GPIO_PuPd_UP; GPIO_StructInit.GPIO_Pin = GPIO_LED1_PIN; GPIO_Init(GPIO_LED1_PORT, &GPIO_StructInit); } void key_init(void) { RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE); GPIO_InitTypeDef GPIO_StructInit; GPIO_StructInit.GPIO_Mode = GPIO_Mode_IN; GPIO_StructInit.GPIO_OType = GPIO_OType_PP; GPIO_StructInit.GPIO_Speed = GPIO_Speed_100MHz; GPIO_StructInit.GPIO_PuPd = GPIO_PuPd_UP; GPIO_StructInit.GPIO_Pin = GPIO_KEY0_PIN | GPIO_KEY1_PIN | GPIO_KEY2_PIN; GPIO_Init(GPIO_KEY0_PORT, &GPIO_StructInit); GPIO_StructInit.GPIO_PuPd = GPIO_PuPd_DOWN; GPIO_StructInit.GPIO_Pin = GPIO_KEY_UP_PIN; GPIO_Init(GPIO_KEY_UP_PORT, &GPIO_StructInit); } void gpio_init(void) { led_init(); key_init(); beep_init(); }