led.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef __LED_H
  2. #define __LED_H
  3. #include "stm32f2xx.h"
  4. //引脚定义
  5. /*******************************************************/
  6. #define LED_PIN GPIO_Pin_6
  7. #define LED_GPIO_PORT GPIOF
  8. #define LED_GPIO_CLK RCC_AHB1Periph_GPIOF
  9. #define NET_STATUS_LED_PIN GPIO_Pin_8
  10. #define NET_STATUS_LED_GPIO_PORT GPIOF
  11. #define NET_STATUS_LED_GPIO_CLK RCC_AHB1Periph_GPIOF
  12. #define STATUS_LED_PIN GPIO_Pin_7
  13. #define STATUS_LED_GPIO_PORT GPIOF
  14. #define STATUS_LED_GPIO_CLK RCC_AHB1Periph_GPIOF
  15. /************************************************************/
  16. /** 控制LED灯亮灭的宏,
  17. * LED低电平亮,设置ON=0,OFF=1
  18. * 若LED高电平亮,把宏设置成ON=1 ,OFF=0 即可
  19. */
  20. #define ON 1
  21. #define OFF 0
  22. /* 带参宏,可以像内联函数一样使用 */
  23. #define LED(a) if (a) \
  24. GPIO_SetBits(LED_GPIO_PORT,LED_PIN);\
  25. else \
  26. GPIO_ResetBits(LED_GPIO_PORT,LED_PIN)
  27. #define NET_STATUS_LED(a) if (a) \
  28. GPIO_SetBits(NET_STATUS_LED_GPIO_PORT,NET_STATUS_LED_PIN);\
  29. else \
  30. GPIO_ResetBits(NET_STATUS_LED_GPIO_PORT,NET_STATUS_LED_PIN)
  31. #define STATUS_LED(a) if (a) \
  32. GPIO_SetBits(STATUS_LED_GPIO_PORT,STATUS_LED_PIN);\
  33. else \
  34. GPIO_ResetBits(STATUS_LED_GPIO_PORT,STATUS_LED_PIN)
  35. void LED_GPIO_Config(void);
  36. void NET_STATUS_LED_Config(void);
  37. void STATUS_LED_Config(void);
  38. int hd_netledOpen(void);
  39. int hd_netledClose(void);
  40. void hd_netledSetOpenTime(int tms);
  41. #endif