led.c 1.1 KB

123456789101112131415161718192021222324252627282930
  1. #include "led.h"
  2. void LED_Init(void)
  3. {
  4. GPIO_InitTypeDef GPIO_InitStructure;
  5. RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB, ENABLE); //使能端口时钟
  6. // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15|GPIO_Pin_5; // 端口配置
  7. // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
  8. // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO口速度为50MHz
  9. // GPIO_Init(GPIOC, &GPIO_InitStructure); //根据设定参数初始化GPIO
  10. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15; // 端口配置
  11. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
  12. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO口速度为50MHz
  13. GPIO_Init(GPIOC, &GPIO_InitStructure); //根据设定参数初始化GPIO
  14. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11|GPIO_Pin_7; // 端口配置
  15. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
  16. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO口速度为50MHz
  17. GPIO_Init(GPIOA, &GPIO_InitStructure); //根据设定参数初始化GPIOC13
  18. }