led.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #pragma once
  2. #ifndef LED_H
  3. #define LED_H
  4. // time to show one led digit, ms
  5. #define LED_ONE_PERIOD 2
  6. #define LED_DIGITS_NUM 8
  7. /* LED
  8. AAA
  9. F B
  10. F B
  11. GGG
  12. E C
  13. E C
  14. DDD P
  15. */
  16. #define LED_SEG1_PORT GPIOA
  17. #define LED_SEG1_PINS GPIO_PIN_3
  18. #define LED_SEG_DP GPIO_PIN_3
  19. #define LED_SEG3_PORT GPIOC
  20. #define LED_SEG3_PINS (GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_3 | GPIO_PIN_5)
  21. #define LED_SEG_A GPIO_PIN_3
  22. #define LED_SEG_F GPIO_PIN_4
  23. #define LED_SEG_B GPIO_PIN_5
  24. #define LED_SEG_E GPIO_PIN_6
  25. #define LED_SEG_G GPIO_PIN_7
  26. #define LED_SEG2_PORT GPIOD
  27. #define LED_SEG2_PINS (GPIO_PIN_1 | GPIO_PIN_4)
  28. #define LED_SEG_C GPIO_PIN_1
  29. #define LED_SEG_D GPIO_PIN_4
  30. #define LED_OUT_OFF {LED_SEG1_PORT->ODR |= LED_SEG1_PINS; LED_SEG2_PORT->ODR |= LED_SEG2_PINS; LED_SEG3_PORT->ODR |= LED_SEG3_PINS;}
  31. #define LED_OUT_DP GPIOA->ODR &= ~LED_SEG_DP
  32. #define LED_OUT_MM GPIOC->ODR &= ~LED_SEG_G
  33. #define LED_OUT_0 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_E|LED_SEG_F); GPIOD->ODR &= ~(LED_SEG2_PINS)
  34. #define LED_OUT_1 GPIOC->ODR &= ~(LED_SEG_B); GPIOD->ODR &= ~(LED_SEG_C)
  35. #define LED_OUT_2 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_E|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG_D)
  36. #define LED_OUT_3 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG2_PINS)
  37. #define LED_OUT_4 GPIOC->ODR &= ~(LED_SEG_B|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG_C)
  38. #define LED_OUT_5 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG2_PINS)
  39. #define LED_OUT_6 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_E|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG2_PINS)
  40. #define LED_OUT_7 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B); GPIOD->ODR &= ~(LED_SEG_C)
  41. #define LED_OUT_8 GPIOC->ODR &= ~(LED_SEG3_PINS); GPIOD->ODR &= ~(LED_SEG2_PINS)
  42. #define LED_OUT_9 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG2_PINS)
  43. #define LED_OUT_H GPIOC->ODR &= ~(LED_SEG_B|LED_SEG_E|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG_C)
  44. #define LED_OUT_PL GPIOC->ODR &= ~(LED_SEG_B|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG_C)
  45. #define LED_OUT_O GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_F|LED_SEG_G);
  46. /* shift register control pins */
  47. #define SPI_PORT GPIOA
  48. #define SPI_SCK GPIO_PIN_1
  49. #define SPI_DATA GPIO_PIN_2
  50. typedef enum {
  51. led_Plus = 0xa,
  52. led_Minus = 0xb,
  53. led_H = 0xc,
  54. led_O = 0xd,
  55. led_Off = 0xff
  56. } led_sym_t;
  57. extern uint8_t LedDigits[];
  58. extern uint8_t LedPoint[];
  59. void led_OutputValue(void);
  60. #endif // LED_H