max7219.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. #define SYM_DOT 0x10
  20. // symbols Для BCD
  21. #define MAX7219_CHAR_BLANK 0x0F
  22. #define MAX7219_CHAR_FULL 0x88
  23. #define MAX7219_ON 0x01
  24. #define MAX7219_OFF 0x00
  25. #define MAX7219_BRIGHT 0x08
  26. // used LED digits - 1
  27. #define MAX7219_DIGITS 7
  28. /* Exported types ------------------------------------------------------------*/
  29. typedef enum _max7219_reg {
  30. RegNoOp = 0x00,
  31. RegDigit0 = 0x03,
  32. RegDigit1 = 0x08,
  33. RegDigit2 = 0x02,
  34. RegDigit3 = 0x01,
  35. RegDigit4 = 0x07,
  36. RegDigit5 = 0x04,
  37. RegDigit6 = 0x06,
  38. RegDigit7 = 0x05,
  39. RegDecodeMode = 0x09,
  40. RegIntensity = 0x0A,
  41. RegScanLimit = 0x0B,
  42. RegPower = 0x0C,
  43. RegTest = 0x0F
  44. } max7219_reg_t;
  45. // соответсвие бит сегментам
  46. typedef enum _max7219_seg {
  47. SegA = 1,
  48. SegB = 3,
  49. SegC = 2,
  50. SegD = 5,
  51. SegE = 6,
  52. SegF = 0,
  53. SegG = 7,
  54. SegDP = 4,
  55. } max7219_seg_t;
  56. // symbols без кодирования
  57. typedef enum _max7219_sym {
  58. Sym_0 = 0x6F,
  59. Sym_1 = 0x0C,
  60. Sym_2 = 0xEA,
  61. Sym_3 = 0xAE,
  62. Sym_4 = 0x8D,
  63. Sym_5 = 0xA7,
  64. Sym_6 = 0xE7,
  65. Sym_7 = 0x0E,
  66. Sym_8 = 0xEF,
  67. Sym_9 = 0xAF,
  68. Sym_A = 0xCF,
  69. Sym_b = 0xE5,
  70. Sym_c = 0xE0,
  71. Sym_C = 0x63,
  72. Sym_d = 0xEC,
  73. Sym_E = 0xE3,
  74. Sym_F = 0xC3,
  75. Sym_h = 0xC5,
  76. Sym_H = 0xCD,
  77. Sym_P = 0xCB,
  78. Sym_t = 0xE1,
  79. Sym_u = 0x64,
  80. Sym_U = 0x6D,
  81. Sym_Gradus = 0x8B,
  82. Sym_LGradus = 0xE4,
  83. Sym_Temp = 0xE1,
  84. Sym_Minus = 0x80,
  85. Sym_Plus = 0xD1,
  86. Sym_BLANK = 0x00,
  87. Sym_FULL = 0xFF,
  88. Sym_Dot = 0x10
  89. } max7219_sym_t;
  90. /* Exported constants --------------------------------------------------------*/
  91. /* Exported macro ------------------------------------------------------------*/
  92. /* Exported variables --------------------------------------------------------*/
  93. /* Exported functions --------------------------------------------------------*/
  94. void MAX7219_Config(void);
  95. void MAX7219_WriteData(max7219_reg_t reg, uint8_t data);
  96. #endif /* __MAX7219_H */