max7219.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 "stm8s.h"
  18. /* Exported defines ----------------------------------------------------------*/
  19. #define MAX7219_ON 0x01
  20. #define MAX7219_OFF 0x00
  21. #define MAX7219_BRIGHT 0x08
  22. // used LED digits - 1
  23. #define MAX7219_DIGITS 7
  24. /* Exported types ------------------------------------------------------------*/
  25. typedef enum _max7219_reg {
  26. RegNoOp = 0x00,
  27. RegDigit0 = 0x01,
  28. RegDigit1 = 0x07,
  29. RegDigit2 = 0x03,
  30. RegDigit3 = 0x06,
  31. RegDigit4 = 0x05,
  32. RegDigit5 = 0x04,
  33. RegDigit6 = 0x08,
  34. RegDigit7 = 0x02,
  35. RegDecodeMode = 0x09,
  36. RegIntensity = 0x0A,
  37. RegScanLimit = 0x0B,
  38. RegPower = 0x0C,
  39. RegTest = 0x0F
  40. } max7219_reg_t;
  41. // соответсвие бит сегментам
  42. typedef enum _max7219_seg {
  43. SegA = 4,
  44. SegB = 0,
  45. SegC = 1,
  46. SegD = 7,
  47. SegE = 3,
  48. SegF = 2,
  49. SegG = 5,
  50. SegDP = 6,
  51. } max7219_seg_t;
  52. // symbols без кодирования
  53. typedef enum _max7219_sym {
  54. Sym_0 = 0x9F,
  55. Sym_1 = 0x03,
  56. Sym_2 = 0xB9,
  57. Sym_3 = 0xB3,
  58. Sym_4 = 0x27,
  59. Sym_5 = 0xB6,
  60. Sym_6 = 0xBe,
  61. Sym_7 = 0x13,
  62. Sym_8 = 0xBF,
  63. Sym_9 = 0xB7,
  64. Sym_A = 0x3F,
  65. Sym_b = 0xAE,
  66. Sym_c = 0xA8,
  67. Sym_C = 0x9C,
  68. Sym_d = 0xAB,
  69. Sym_E = 0xBC,
  70. Sym_F = 0x3C,
  71. Sym_h = 0x2E,
  72. Sym_H = 0x2F,
  73. Sym_o = 0xAA,
  74. Sym_P = 0x3D,
  75. Sym_t = 0xAC,
  76. Sym_u = 0x8A,
  77. Sym_U = 0x8F,
  78. Sym_Gradus = 0x35,
  79. Sym_Minus = 0x20,
  80. Sym_BLANK = 0x00,
  81. Sym_FULL = 0xFF,
  82. Sym_Dot = 0x40
  83. } max7219_sym_t;
  84. /* Exported constants --------------------------------------------------------*/
  85. /* Exported macro ------------------------------------------------------------*/
  86. /* Exported variables --------------------------------------------------------*/
  87. /* Exported functions --------------------------------------------------------*/
  88. void MAX7219_Config(void);
  89. void MAX7219_WriteData(max7219_reg_t reg, uint8_t data);
  90. #endif /* __MAX7219_H */