led.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 segments pins
  8. AAA
  9. F B
  10. F B
  11. GGG
  12. E C
  13. E C
  14. DDD P
  15. */
  16. /* LED
  17. AAA
  18. F B
  19. F B
  20. GGG
  21. E C
  22. E C
  23. DDD P
  24. */
  25. #define LED_SEG1_PORT GPIOA
  26. #define LED_SEG1_PINS GPIO_PIN_3
  27. #define LED_SEG_DP GPIO_PIN_3
  28. #define LED_SEG3_PORT GPIOC
  29. #define LED_SEG3_PINS (GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_3 | GPIO_PIN_5)
  30. #define LED_SEG_A GPIO_PIN_3
  31. #define LED_SEG_F GPIO_PIN_4
  32. #define LED_SEG_B GPIO_PIN_5
  33. #define LED_SEG_E GPIO_PIN_6
  34. #define LED_SEG_G GPIO_PIN_7
  35. #define LED_SEG2_PORT GPIOD
  36. #define LED_SEG2_PINS (GPIO_PIN_1 | GPIO_PIN_4)
  37. #define LED_SEG_C GPIO_PIN_1
  38. #define LED_SEG_D GPIO_PIN_4
  39. #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;}
  40. #define LED_OUT_DP GPIOA->ODR &= ~LED_SEG_DP
  41. #define LED_OUT_MM GPIOC->ODR &= ~LED_SEG_G
  42. #define LED_OUT_0 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_E|LED_SEG_F); GPIOD->ODR &= ~(LED_SEG2_PINS)
  43. #define LED_OUT_1 GPIOC->ODR &= ~(LED_SEG_B); GPIOD->ODR &= ~(LED_SEG_C)
  44. #define LED_OUT_2 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_E|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG_D)
  45. #define LED_OUT_3 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG2_PINS)
  46. #define LED_OUT_4 GPIOC->ODR &= ~(LED_SEG_B|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG_C)
  47. #define LED_OUT_5 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG2_PINS)
  48. #define LED_OUT_6 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_E|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG2_PINS)
  49. #define LED_OUT_7 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B); GPIOD->ODR &= ~(LED_SEG_C)
  50. #define LED_OUT_8 GPIOC->ODR &= ~(LED_SEG3_PINS); GPIOD->ODR &= ~(LED_SEG2_PINS)
  51. #define LED_OUT_9 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG2_PINS)
  52. /* shift register control pins */
  53. #define SPI_PORT GPIOA
  54. #define SPI_SCK GPIO_PIN_1
  55. #define SPI_DATA GPIO_PIN_2
  56. typedef enum {
  57. led_A = 0xa,
  58. led_B = 0xb,
  59. led_C = 0xc,
  60. led_D = 0xd,
  61. led_E = 0xe,
  62. led_F = 0xf,
  63. led_H = 0x11,
  64. led_U = 0x12,
  65. led_Plus = 0x21,
  66. led_Minus = 0x22,
  67. led_O = 0x23, /* gradus */
  68. led_Off = 0xff
  69. } led_sym_t;
  70. extern uint8_t LedDigits[];
  71. extern uint8_t LedPoint[];
  72. void led_OutputValue(void);
  73. #endif // LED_H