mux.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #ifndef __MUX_H
  2. #define __MUX_H
  3. #include <stdbool.h>
  4. //
  5. #define LINE_0_SET GPIOE->scr = GPIO_PINS_3
  6. #define LINE_0_RESET GPIOE->clr = GPIO_PINS_3
  7. #define LINE_1_SET GPIOE->scr = GPIO_PINS_2
  8. #define LINE_1_RESET GPIOE->clr = GPIO_PINS_2
  9. #define LINE_2_SET GPIOB->scr = GPIO_PINS_9
  10. #define LINE_2_RESET GPIOB->clr = GPIO_PINS_9
  11. #define COL_1_SET GPIOD->scr = GPIO_PINS_6
  12. #define COL_1_RESET GPIOD->clr = GPIO_PINS_6
  13. #define COL_2_SET GPIOD->scr = GPIO_PINS_7
  14. #define COL_2_RESET GPIOD->clr = GPIO_PINS_7
  15. #define COL_3_SET GPIOB->scr = GPIO_PINS_6
  16. #define COL_3_RESET GPIOB->clr = GPIO_PINS_6
  17. #define COL_4_SET GPIOB->scr = GPIO_PINS_7
  18. #define COL_4_RESET GPIOB->clr = GPIO_PINS_7
  19. /* -------------------------------------------------------------------------- */
  20. #if defined (MDIO_88)
  21. #define LED_NUMBER 28
  22. typedef enum
  23. {
  24. INP_1 = 0,
  25. INP_2,
  26. INP_3,
  27. INP_4,
  28. INP_5,
  29. INP_6,
  30. INP_7,
  31. INP_8,
  32. OUT_1_G,
  33. OUT_2_G,
  34. OUT_3_G,
  35. OUT_4_G,
  36. OUT_1_R,
  37. OUT_2_R,
  38. OUT_3_R,
  39. OUT_4_R,
  40. STATUS_G,
  41. STATUS_R,
  42. RX_G,
  43. TX_R,
  44. OUT_5_R,
  45. OUT_6_R,
  46. OUT_7_R,
  47. OUT_8_R,
  48. OUT_5_G,
  49. OUT_6_G,
  50. OUT_7_G,
  51. OUT_8_G,
  52. } led_t;
  53. /* -------------------------------------------------------------------------- */
  54. #elif defined (MAI_12)
  55. #define LED_NUMBER 28
  56. typedef enum
  57. {
  58. IO_1_G = 0,
  59. IO_1_R,
  60. IO_2_G,
  61. IO_2_R,
  62. IO_3_G,
  63. IO_3_R,
  64. IO_4_G,
  65. IO_4_R,
  66. IO_5_G,
  67. IO_5_R,
  68. IO_6_G,
  69. IO_6_R,
  70. STATUS_G,
  71. STATUS_R,
  72. RX_G,
  73. TX_R,
  74. IO_7_G,
  75. IO_7_R,
  76. IO_8_G,
  77. IO_8_R,
  78. IO_9_G,
  79. IO_9_R,
  80. IO_10_G,
  81. IO_10_R,
  82. IO_11_G,
  83. IO_11_R,
  84. IO_12_G,
  85. IO_12_R,
  86. } led_t;
  87. #endif
  88. /* -------------------------------------------------------------------------- */
  89. typedef enum
  90. {
  91. LED_OFF = 0,
  92. LED_ON,
  93. LED_BLINK,
  94. } led_state_t;
  95. typedef struct
  96. {
  97. led_t name;
  98. uint8_t line[3]; // [line_0, line_1, line_2]
  99. led_state_t state;
  100. uint32_t cnt;
  101. } mux_channel_t;
  102. //
  103. void mux_led_init(mux_channel_t *ch);
  104. //
  105. void mux_gpio_init(void);
  106. //
  107. void mux_led_proc(void);
  108. //
  109. void mux_led_blink(void);
  110. //
  111. void mux_led_test_init(void);
  112. //
  113. void mux_led_test_toggle(void);
  114. //
  115. void mux_led_status(bool state);
  116. extern mux_channel_t leds[];
  117. #endif // __MUX_H