max7219.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* MAX7219 Header file
  2. * ---------------------------
  3. * For more information see
  4. * http://www.adnbr.co.uk/articles/max7219-and-7-segment-displays
  5. * ----------------------------------------------------------------------------
  6. * "THE BEER-WARE LICENSE" (Revision 42):
  7. * <shilow@ukr.net> wrote this file. As long as you retain this notice you
  8. * can do whatever you want with this stuff. If we meet some day, and you think
  9. * this stuff is worth it, you can buy me a beer in return. Shilov V.N.
  10. * ----------------------------------------------------------------------------
  11. */
  12. /* Define to prevent recursive inclusion -------------------------------------*/
  13. #pragma once
  14. #ifndef __MAX7219_H
  15. #define __MAX7219_H
  16. /* Includes ------------------------------------------------------------------*/
  17. #include "stm8l15x.h"
  18. /* Exported defines ----------------------------------------------------------*/
  19. // symbols Для BCD
  20. #define MAX7219_CHAR_BLANK 0x0F
  21. #define MAX7219_CHAR_FULL 0x88
  22. #define MAX7219_ON 0x01
  23. #define MAX7219_OFF 0x00
  24. #define MAX7219_BRIGHT 0x08
  25. // used LED digits - 1
  26. #define MAX7219_DIGITS 7
  27. /* Exported types ------------------------------------------------------------*/
  28. typedef enum _max7219_reg {
  29. RegNoOp = 0x00,
  30. RegDigit0 = 0x03,
  31. RegDigit1 = 0x08,
  32. RegDigit2 = 0x02,
  33. RegDigit3 = 0x01,
  34. RegDigit4 = 0x07,
  35. RegDigit5 = 0x04,
  36. RegDigit6 = 0x06,
  37. RegDigit7 = 0x05,
  38. RegDecodeMode = 0x09,
  39. RegIntensity = 0x0A,
  40. RegScanLimit = 0x0B,
  41. RegPower = 0x0C,
  42. RegTest = 0x0F
  43. } max7219_reg_t;
  44. // соответсвие бит сегментам
  45. typedef enum _max7219_seg {
  46. SegA = 1,
  47. SegB = 3,
  48. SegC = 2,
  49. SegD = 5,
  50. SegE = 6,
  51. SegF = 0,
  52. SegG = 7,
  53. SegDP = 4,
  54. } max7219_seg_t;
  55. // symbols без кодирования
  56. typedef enum _max7219_sym {
  57. Sym_0 = 0x6F,
  58. Sym_1 = 0x0C,
  59. Sym_2 = 0xEA,
  60. Sym_3 = 0xAE,
  61. Sym_4 = 0x8D,
  62. Sym_5 = 0xA7,
  63. Sym_6 = 0xE7,
  64. Sym_7 = 0x0E,
  65. Sym_8 = 0xEF,
  66. Sym_9 = 0xAF,
  67. Sym_A = 0xCF,
  68. Sym_b = 0xE5,
  69. Sym_c = 0xE0,
  70. Sym_C = 0x63,
  71. Sym_d = 0xEC,
  72. Sym_E = 0xE3,
  73. Sym_F = 0xC3
  74. Sym_h = 0xC5,
  75. Sym_H = 0xCD,
  76. Sym_P = 0xCB,
  77. Sym_t = 0xE1,
  78. Sym_u = 0x64,
  79. Sym_U = 0x6D,
  80. Sym_Gradus = 0x8B,
  81. Sym_LGradus = 0xE4,
  82. Sym_Temp = 0xE1,
  83. Sym_Minus = 0x80,
  84. Sym_Plus = 0xD1,
  85. Sym_BLANK = 0x00,
  86. Sym_FULL = 0xFF,
  87. Sym_Dot = 0x10
  88. } max7219_sym_t;
  89. /* Exported constants --------------------------------------------------------*/
  90. /* Exported macro ------------------------------------------------------------*/
  91. /* Exported variables --------------------------------------------------------*/
  92. /* Exported functions --------------------------------------------------------*/
  93. void MAX7219_Config(void);
  94. void MAX7219_WriteData(max7219_reg_t reg, uint8_t data);
  95. #endif /* __MAX7219_H */