You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

75 lines
3.2 KiB

  1. /***********************头文件****************************/
  2. #include "led.h"
  3. /***********************LED IO初始化****************************/
  4. void LED_Init(void)
  5. {
  6. /**************初始化GPIOF、GPIOI*******************
  7. PF6 -> Q0
  8. PF8 -> Q1
  9. PF7 -> Q2
  10. PF9 -> Q3
  11. PF11 -> Q16
  12. PI8 -> Q4
  13. ***************************************************/
  14. GPIO_InitTypeDef GPIO_InitStructure;
  15. RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE);//使能GPIOF时钟
  16. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 |GPIO_Pin_8 |GPIO_Pin_9 |GPIO_Pin_11 ;//LED0/1/2/3对应IO口
  17. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//普通输出模式
  18. GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;//开漏输出
  19. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//50MHz
  20. GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
  21. GPIO_Init(GPIOF, &GPIO_InitStructure);//初始化GPIO
  22. GPIO_SetBits(GPIOF,GPIO_Pin_6 | GPIO_Pin_8);
  23. GPIO_SetBits(GPIOF,GPIO_Pin_7 | GPIO_Pin_9 |GPIO_Pin_11);
  24. RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOI, ENABLE);//使能GPIOI时钟
  25. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 ;//LED4对应IO口
  26. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//普通输出模式
  27. GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;//开漏输出
  28. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//50MHz
  29. GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//下拉
  30. GPIO_Init(GPIOI, &GPIO_InitStructure);//初始化GPIO
  31. GPIO_SetBits(GPIOI,GPIO_Pin_8);
  32. /**************初始化GPIOE、GPIOG、GPIOH*******************
  33. PE6 -> Q5
  34. PE5 -> Q6
  35. PE4 -> Q7
  36. PG7 -> Q10
  37. PG6 -> Q11
  38. PH9 -> Q12
  39. PH8 -> Q13
  40. PH7 -> Q14
  41. PH6 -> Q15
  42. PH5 -> Q20
  43. **********************************************************/
  44. RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_GPIOG| RCC_AHB1Periph_GPIOH, ENABLE);
  45. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_5 |GPIO_Pin_4 ;//LED5 LED6 LED7对应IO口
  46. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//普通输出模式
  47. GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//开漏输出
  48. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//50MHz
  49. GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
  50. GPIO_Init(GPIOE, &GPIO_InitStructure);//初始化GPIO
  51. GPIO_SetBits(GPIOE,GPIO_Pin_6 | GPIO_Pin_5 |GPIO_Pin_4);
  52. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_6 ;//LED7 LED8 对应IO口
  53. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//普通输出模式
  54. GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;//开漏输出
  55. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//50MHz
  56. GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
  57. GPIO_Init(GPIOG, &GPIO_InitStructure);//初始化GPIO
  58. GPIO_SetBits(GPIOG,GPIO_Pin_7 | GPIO_Pin_6);
  59. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_8 |GPIO_Pin_7 |GPIO_Pin_6 |GPIO_Pin_5 ;//LED9 LED10 LED11 LED12 对应IO口
  60. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//普通输出模式
  61. GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;//开漏输出
  62. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//50MHz
  63. GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
  64. GPIO_Init(GPIOH, &GPIO_InitStructure);//初始化GPIO
  65. GPIO_SetBits(GPIOH,GPIO_Pin_9 | GPIO_Pin_8 |GPIO_Pin_7 |GPIO_Pin_6 |GPIO_Pin_5);
  66. }