/***********************头文件****************************/ #include "led.h" /***********************LED IO初始化****************************/ void LED_Init(void) { /**************初始化GPIOF、GPIOI******************* PF6 -> Q0 PF8 -> Q1 PF7 -> Q2 PF9 -> Q3 PF11 -> Q16 PI8 -> Q4 ***************************************************/ GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE);//使能GPIOF时钟 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 |GPIO_Pin_8 |GPIO_Pin_9 |GPIO_Pin_11 ;//LED0/1/2/3对应IO口 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//普通输出模式 GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;//开漏输出 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//50MHz GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉 GPIO_Init(GPIOF, &GPIO_InitStructure);//初始化GPIO GPIO_SetBits(GPIOF,GPIO_Pin_6 | GPIO_Pin_8); GPIO_SetBits(GPIOF,GPIO_Pin_7 | GPIO_Pin_9 |GPIO_Pin_11); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOI, ENABLE);//使能GPIOI时钟 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 ;//LED4对应IO口 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//普通输出模式 GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;//开漏输出 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//50MHz GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//下拉 GPIO_Init(GPIOI, &GPIO_InitStructure);//初始化GPIO GPIO_SetBits(GPIOI,GPIO_Pin_8); /**************初始化GPIOE、GPIOG、GPIOH******************* PE6 -> Q5 PE5 -> Q6 PE4 -> Q7 PG7 -> Q10 PG6 -> Q11 PH9 -> Q12 PH8 -> Q13 PH7 -> Q14 PH6 -> Q15 PH5 -> Q20 **********************************************************/ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_GPIOG| RCC_AHB1Periph_GPIOH, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_5 |GPIO_Pin_4 ;//LED5 LED6 LED7对应IO口 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//普通输出模式 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//开漏输出 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//50MHz GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉 GPIO_Init(GPIOE, &GPIO_InitStructure);//初始化GPIO GPIO_SetBits(GPIOE,GPIO_Pin_6 | GPIO_Pin_5 |GPIO_Pin_4); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_6 ;//LED7 LED8 对应IO口 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//普通输出模式 GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;//开漏输出 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//50MHz GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉 GPIO_Init(GPIOG, &GPIO_InitStructure);//初始化GPIO GPIO_SetBits(GPIOG,GPIO_Pin_7 | GPIO_Pin_6); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_8 |GPIO_Pin_7 |GPIO_Pin_6 |GPIO_Pin_5 ;//LED9 LED10 LED11 LED12 对应IO口 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//普通输出模式 GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;//开漏输出 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//50MHz GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉 GPIO_Init(GPIOH, &GPIO_InitStructure);//初始化GPIO GPIO_SetBits(GPIOH,GPIO_Pin_9 | GPIO_Pin_8 |GPIO_Pin_7 |GPIO_Pin_6 |GPIO_Pin_5); }