led.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "led.h"
  2. #include "delay.h"
  3. //////////////////////////////////////////////////////////////////////////////////
  4. //本程序只供内部使用,未经作者许可,不得用于其它任何用途
  5. // STM32F103开发板
  6. //LED驱动代码
  7. //创建日期:2017/5/25
  8. //版本:V1.0
  9. //版权所有,盗版必究。
  10. //Copyright(C) 济南鲁泰电气有限公司 2014-2024
  11. //All rights reserved
  12. //////////////////////////////////////////////////////////////////////////////////
  13. //初始化PB1为输出.并使能时钟
  14. //LED IO初始化
  15. void LED_Init(void)
  16. {
  17. GPIO_InitTypeDef GPIO_Initure;
  18. __HAL_RCC_GPIOC_CLK_ENABLE(); //开启GPIOC时钟
  19. GPIO_Initure.Pin=GPIO_PIN_0|GPIO_PIN_1; //PC0、PC1 pc1:sim7600_power
  20. GPIO_Initure.Mode=GPIO_MODE_OUTPUT_PP; //推挽输出
  21. GPIO_Initure.Pull=GPIO_PULLUP; //上拉
  22. GPIO_Initure.Speed=GPIO_SPEED_FREQ_HIGH; //高速
  23. HAL_GPIO_Init(GPIOC,&GPIO_Initure);
  24. GPIO_Initure.Pin=GPIO_PIN_1; //PB1 //sim7600 reset
  25. GPIO_Initure.Mode=GPIO_MODE_OUTPUT_PP; //推挽输出
  26. GPIO_Initure.Pull=GPIO_PULLUP; //上拉
  27. GPIO_Initure.Speed=GPIO_SPEED_FREQ_HIGH; //高速
  28. HAL_GPIO_Init(GPIOB,&GPIO_Initure);
  29. HAL_GPIO_WritePin(GPIOC,GPIO_PIN_0,GPIO_PIN_RESET); //PC0置1,默认初始化后灯灭
  30. }