hard_led.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef __HARD_LED_H
  2. #define __HARD_LED_H
  3. #include "stm32f1xx_hal.h"
  4. #define Red 0
  5. #define Blue 2
  6. #define Green 1
  7. #define Purple 3
  8. #define Yellow 4
  9. #define Cyan 5
  10. #define White 6
  11. #define ON 0xff
  12. #define OFF 0x00
  13. // LEDs LED
  14. //
  15. /*
  16. red
  17. green
  18. blue
  19. purple
  20. yellow
  21. cyan
  22. white
  23. */
  24. //
  25. #define LEDRed_ON() HAL_GPIO_WritePin(GPIOB,LED_R_Pin,GPIO_PIN_SET)
  26. #define LEDRed_OFF() HAL_GPIO_WritePin(GPIOB,LED_R_Pin,GPIO_PIN_RESET)
  27. //
  28. #define LEDGreen_ON() HAL_GPIO_WritePin(GPIOB,LED_G_Pin,GPIO_PIN_SET)
  29. #define LEDGreen_OFF() HAL_GPIO_WritePin(GPIOB,LED_G_Pin,GPIO_PIN_RESET)
  30. //
  31. #define LEDBlue_ON() HAL_GPIO_WritePin(GPIOB,LED_B_Pin,GPIO_PIN_SET)
  32. #define LEDBlue_OFF() HAL_GPIO_WritePin(GPIOB,LED_B_Pin,GPIO_PIN_RESET)
  33. //
  34. #define LEDPurple_ON() HAL_GPIO_WritePin(GPIOB,LED_R_Pin | LED_B_Pin,GPIO_PIN_SET)
  35. #define LEDPurple_OFF() HAL_GPIO_WritePin(GPIOB,LED_R_Pin | LED_B_Pin,GPIO_PIN_RESET)
  36. //
  37. #define LEDYellow_ON() HAL_GPIO_WritePin(GPIOB,LED_R_Pin | LED_G_Pin,GPIO_PIN_SET)
  38. #define LEDYellow_OFF() HAL_GPIO_WritePin(GPIOB,LED_R_Pin | LED_G_Pin,GPIO_PIN_RESET)
  39. //
  40. #define LEDCyan_ON() HAL_GPIO_WritePin(GPIOB,LED_B_Pin | LED_G_Pin,GPIO_PIN_SET)
  41. #define LEDCyan_OFF() HAL_GPIO_WritePin(GPIOB,LED_B_Pin | LED_G_Pin,GPIO_PIN_RESET)
  42. //
  43. #define LEDWhite_ON() HAL_GPIO_WritePin(GPIOB,LED_B_Pin | LED_G_Pin | LED_R_Pin,GPIO_PIN_SET)
  44. #define LEDWhite_OFF() HAL_GPIO_WritePin(GPIOB,LED_B_Pin | LED_G_Pin | LED_R_Pin,GPIO_PIN_RESET)
  45. void led_set_blink( uint8_t, uint8_t, uint8_t, uint8_t );
  46. void led_blink_repeat( void );
  47. void Update_LED_Time( void );
  48. typedef struct
  49. {
  50. uint8_t status;
  51. uint32_t on_time_ms;
  52. uint32_t off_time_ms;
  53. uint32_t repeat;
  54. uint32_t time;
  55. } LED_Red, LED_Blue, LED_Green, LED_Purple, LED_Cyan, LED_Yellow, LED_White;
  56. extern LED_Red L_red;
  57. extern LED_Blue L_blue;
  58. extern LED_Green L_green;
  59. extern LED_Purple L_purple;
  60. extern LED_Cyan L_cyan;
  61. extern LED_Yellow L_yellow;
  62. extern LED_White L_white;
  63. #endif