|
@@ -1,136 +1,142 @@
|
|
-/* MAX7219 Header file
|
|
|
|
- * ---------------------------
|
|
|
|
- * For more information see
|
|
|
|
- * http://www.adnbr.co.uk/articles/max7219-and-7-segment-displays
|
|
|
|
|
|
+/* MAX7219 Header file
|
|
|
|
+ * ---------------------------
|
|
|
|
+ * For more information see
|
|
|
|
+ * http://www.adnbr.co.uk/articles/max7219-and-7-segment-displays
|
|
* ----------------------------------------------------------------------------
|
|
* ----------------------------------------------------------------------------
|
|
* "THE BEER-WARE LICENSE" (Revision 42):
|
|
* "THE BEER-WARE LICENSE" (Revision 42):
|
|
* <shilow@ukr.net> wrote this file. As long as you retain this notice you
|
|
* <shilow@ukr.net> wrote this file. As long as you retain this notice you
|
|
* can do whatever you want with this stuff. If we meet some day, and you think
|
|
* can do whatever you want with this stuff. If we meet some day, and you think
|
|
* this stuff is worth it, you can buy me a beer in return. Shilov V.N.
|
|
* this stuff is worth it, you can buy me a beer in return. Shilov V.N.
|
|
* ----------------------------------------------------------------------------
|
|
* ----------------------------------------------------------------------------
|
|
- */
|
|
|
|
-
|
|
|
|
-/* Define to prevent recursive inclusion -------------------------------------*/
|
|
|
|
-#pragma once
|
|
|
|
-#ifndef __MAX7219_H
|
|
|
|
-#define __MAX7219_H
|
|
|
|
-
|
|
|
|
-/* Includes ------------------------------------------------------------------*/
|
|
|
|
-#include "stm8l15x.h"
|
|
|
|
-
|
|
|
|
-/* Exported defines ----------------------------------------------------------*/
|
|
|
|
-// соответсвие бит сегментам
|
|
|
|
-#define SEG_A 1
|
|
|
|
-#define SEG_B 3
|
|
|
|
-#define SEG_C 2
|
|
|
|
-#define SEG_D 5
|
|
|
|
-#define SEG_E 6
|
|
|
|
-#define SEG_F 0
|
|
|
|
-#define SEG_G 7
|
|
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+/* Define to prevent recursive inclusion -------------------------------------*/
|
|
|
|
+#pragma once
|
|
|
|
+#ifndef __MAX7219_H
|
|
|
|
+#define __MAX7219_H
|
|
|
|
+
|
|
|
|
+/* Includes ------------------------------------------------------------------*/
|
|
|
|
+#include "stm8l15x.h"
|
|
|
|
+
|
|
|
|
+/* Exported defines ----------------------------------------------------------*/
|
|
|
|
+// соответсвие бит сегментам
|
|
|
|
+#define SEG_A 1
|
|
|
|
+#define SEG_B 3
|
|
|
|
+#define SEG_C 2
|
|
|
|
+#define SEG_D 5
|
|
|
|
+#define SEG_E 6
|
|
|
|
+#define SEG_F 0
|
|
|
|
+#define SEG_G 7
|
|
#define SEG_DP 4
|
|
#define SEG_DP 4
|
|
-
|
|
|
|
-// symbols
|
|
|
|
-// Для BCD
|
|
|
|
-#define MAX7219_CHAR_BLANK 0x0F
|
|
|
|
-#define MAX7219_CHAR_FULL 0x88
|
|
|
|
-// без кодирования
|
|
|
|
-#define SYM_0 0x6F
|
|
|
|
-#define SYM_1 0x0C
|
|
|
|
-#define SYM_2 0xEA
|
|
|
|
-#define SYM_3 0xAE
|
|
|
|
-#define SYM_4 0x8D
|
|
|
|
-#define SYM_5 0xA7
|
|
|
|
-#define SYM_6 0xE7
|
|
|
|
-#define SYM_7 0x0E
|
|
|
|
-#define SYM_8 0xEF
|
|
|
|
-#define SYM_9 0xAF
|
|
|
|
-#define SYM_A 0xCF
|
|
|
|
-#define SYM_b 0xE5
|
|
|
|
-#define SYM_c 0xE0
|
|
|
|
-#define SYM_C 0x63
|
|
|
|
-#define SYM_d 0xEC
|
|
|
|
-#define SYM_E 0xE3
|
|
|
|
-#define SYM_F 0xC3
|
|
|
|
-#define SYM_P 0xCB
|
|
|
|
-#define SYM_Gradus 0x8B
|
|
|
|
-#define SYM_LGradus 0xE4
|
|
|
|
-#define SYM_Temp 0xE1
|
|
|
|
-#define SYM_Minus 0x80
|
|
|
|
-#define SYM_Plus 0xD1
|
|
|
|
-#define SYM_BLANK 0x00
|
|
|
|
-#define SYM_FULL 0xFF
|
|
|
|
-#define SYM_DOT 0x10
|
|
|
|
-
|
|
|
|
-#define MAX7219_ON 0x01
|
|
|
|
-#define MAX7219_OFF 0x00
|
|
|
|
-#define MAX7219_BRIGHT 0x08
|
|
|
|
|
|
+
|
|
|
|
+// symbols
|
|
|
|
+// Для BCD
|
|
|
|
+#define MAX7219_CHAR_BLANK 0x0F
|
|
|
|
+#define MAX7219_CHAR_FULL 0x88
|
|
|
|
+// без кодирования
|
|
|
|
+#define SYM_0 0x6F
|
|
|
|
+#define SYM_1 0x0C
|
|
|
|
+#define SYM_2 0xEA
|
|
|
|
+#define SYM_3 0xAE
|
|
|
|
+#define SYM_4 0x8D
|
|
|
|
+#define SYM_5 0xA7
|
|
|
|
+#define SYM_6 0xE7
|
|
|
|
+#define SYM_7 0x0E
|
|
|
|
+#define SYM_8 0xEF
|
|
|
|
+#define SYM_9 0xAF
|
|
|
|
+#define SYM_A 0xCF
|
|
|
|
+#define SYM_b 0xE5
|
|
|
|
+#define SYM_c 0xE0
|
|
|
|
+#define SYM_C 0x63
|
|
|
|
+#define SYM_d 0xEC
|
|
|
|
+#define SYM_E 0xE3
|
|
|
|
+#define SYM_F 0xC3
|
|
|
|
+#define SYM_H 0xCD
|
|
|
|
+#define SYM_h 0xC5
|
|
|
|
+#define SYM_P 0xCB
|
|
|
|
+#define SYM_t 0xE1
|
|
|
|
+#define SYM_Gradus 0x8B
|
|
|
|
+#define SYM_LGradus 0xE4
|
|
|
|
+#define SYM_Temp 0xE1
|
|
|
|
+#define SYM_Minus 0x80
|
|
|
|
+#define SYM_Plus 0xD1
|
|
|
|
+#define SYM_BLANK 0x00
|
|
|
|
+#define SYM_FULL 0xFF
|
|
|
|
+#define SYM_DOT 0x10
|
|
|
|
+
|
|
|
|
+#define MAX7219_ON 0x01
|
|
|
|
+#define MAX7219_OFF 0x00
|
|
|
|
+#define MAX7219_BRIGHT 0x08
|
|
|
|
|
|
// used LED digits - 1
|
|
// used LED digits - 1
|
|
-#define MAX7219_DIGITS 7
|
|
|
|
-
|
|
|
|
-/* Exported types ------------------------------------------------------------*/
|
|
|
|
|
|
+#define MAX7219_DIGITS 7
|
|
|
|
+
|
|
|
|
+/* Exported types ------------------------------------------------------------*/
|
|
typedef enum _max7219_reg {
|
|
typedef enum _max7219_reg {
|
|
- RegNoOp = 0x00,
|
|
|
|
- RegDigit0 = 0x03,
|
|
|
|
- RegDigit1 = 0x08,
|
|
|
|
- RegDigit2 = 0x02,
|
|
|
|
- RegDigit3 = 0x01,
|
|
|
|
- RegDigit4 = 0x07,
|
|
|
|
- RegDigit5 = 0x04,
|
|
|
|
- RegDigit6 = 0x06,
|
|
|
|
- RegDigit7 = 0x05,
|
|
|
|
- RegDecodeMode = 0x09,
|
|
|
|
- RegIntensity = 0x0A,
|
|
|
|
- RegScanLimit = 0x0B,
|
|
|
|
- RegPower = 0x0C,
|
|
|
|
- RegTest = 0x0F
|
|
|
|
-} max7219_reg_t;
|
|
|
|
|
|
+ RegNoOp = 0x00,
|
|
|
|
+ RegDigit0 = 0x03,
|
|
|
|
+ RegDigit1 = 0x08,
|
|
|
|
+ RegDigit2 = 0x02,
|
|
|
|
+ RegDigit3 = 0x01,
|
|
|
|
+ RegDigit4 = 0x07,
|
|
|
|
+ RegDigit5 = 0x04,
|
|
|
|
+ RegDigit6 = 0x06,
|
|
|
|
+ RegDigit7 = 0x05,
|
|
|
|
+ RegDecodeMode = 0x09,
|
|
|
|
+ RegIntensity = 0x0A,
|
|
|
|
+ RegScanLimit = 0x0B,
|
|
|
|
+ RegPower = 0x0C,
|
|
|
|
+ RegTest = 0x0F
|
|
|
|
+} max7219_reg_t;
|
|
|
|
|
|
typedef enum _max7219_seg {
|
|
typedef enum _max7219_seg {
|
|
- SegA = SEG_A,
|
|
|
|
- SegB = SEG_B,
|
|
|
|
- SegC = SEG_C,
|
|
|
|
- SegD = SEG_D,
|
|
|
|
- SegE = SEG_E,
|
|
|
|
- SegF = SEG_F,
|
|
|
|
- SegG = SEG_G,
|
|
|
|
- SegDP = SEG_DP,
|
|
|
|
-} max7219_seg_t;
|
|
|
|
|
|
+ SegA = SEG_A,
|
|
|
|
+ SegB = SEG_B,
|
|
|
|
+ SegC = SEG_C,
|
|
|
|
+ SegD = SEG_D,
|
|
|
|
+ SegE = SEG_E,
|
|
|
|
+ SegF = SEG_F,
|
|
|
|
+ SegG = SEG_G,
|
|
|
|
+ SegDP = SEG_DP,
|
|
|
|
+} max7219_seg_t;
|
|
|
|
|
|
typedef enum _max7219_sym {
|
|
typedef enum _max7219_sym {
|
|
- Sym_0 = SYM_0,
|
|
|
|
- Sym_1 = SYM_1,
|
|
|
|
- Sym_2 = SYM_2,
|
|
|
|
- Sym_3 = SYM_3,
|
|
|
|
- Sym_4 = SYM_4,
|
|
|
|
- Sym_5 = SYM_5,
|
|
|
|
- Sym_6 = SYM_6,
|
|
|
|
- Sym_7 = SYM_7,
|
|
|
|
- Sym_8 = SYM_8,
|
|
|
|
- Sym_9 = SYM_9,
|
|
|
|
- Sym_A = SYM_A,
|
|
|
|
- Sym_b = SYM_b,
|
|
|
|
- Sym_c = SYM_c,
|
|
|
|
- Sym_C = SYM_C,
|
|
|
|
- Sym_d = SYM_d,
|
|
|
|
- Sym_E = SYM_E,
|
|
|
|
- Sym_F = SYM_F,
|
|
|
|
- Sym_P = SYM_P,
|
|
|
|
- Sym_Gradus = SYM_Gradus,
|
|
|
|
- Sym_LGradus = SYM_LGradus,
|
|
|
|
- Sym_Temp = SYM_Temp,
|
|
|
|
- Sym_Minus = SYM_Minus,
|
|
|
|
- Sym_Plus = SYM_P,
|
|
|
|
- Sym_BLANK = SYM_BLANK,
|
|
|
|
- Sym_FULL = SYM_FULL,
|
|
|
|
- Sym_Dot = SYM_DOT
|
|
|
|
|
|
+ Sym_0 = SYM_0,
|
|
|
|
+ Sym_1 = SYM_1,
|
|
|
|
+ Sym_2 = SYM_2,
|
|
|
|
+ Sym_3 = SYM_3,
|
|
|
|
+ Sym_4 = SYM_4,
|
|
|
|
+ Sym_5 = SYM_5,
|
|
|
|
+ Sym_6 = SYM_6,
|
|
|
|
+ Sym_7 = SYM_7,
|
|
|
|
+ Sym_8 = SYM_8,
|
|
|
|
+ Sym_9 = SYM_9,
|
|
|
|
+ Sym_A = SYM_A,
|
|
|
|
+ Sym_b = SYM_b,
|
|
|
|
+ Sym_c = SYM_c,
|
|
|
|
+ Sym_C = SYM_C,
|
|
|
|
+ Sym_d = SYM_d,
|
|
|
|
+ Sym_E = SYM_E,
|
|
|
|
+ Sym_h = SYM_h,
|
|
|
|
+ Sym_H = SYM_H,
|
|
|
|
+ Sym_F = SYM_F,
|
|
|
|
+ Sym_P = SYM_P,
|
|
|
|
+ Sym_t = SYM_t,
|
|
|
|
+ Sym_Gradus = SYM_Gradus,
|
|
|
|
+ Sym_LGradus = SYM_LGradus,
|
|
|
|
+ Sym_Temp = SYM_Temp,
|
|
|
|
+ Sym_Minus = SYM_Minus,
|
|
|
|
+ Sym_Plus = SYM_P,
|
|
|
|
+ Sym_BLANK = SYM_BLANK,
|
|
|
|
+ Sym_FULL = SYM_FULL,
|
|
|
|
+ Sym_Dot = SYM_DOT
|
|
} max7219_sym_t;
|
|
} max7219_sym_t;
|
|
-
|
|
|
|
-/* Exported constants --------------------------------------------------------*/
|
|
|
|
-/* Exported macro ------------------------------------------------------------*/
|
|
|
|
-/* Exported variables --------------------------------------------------------*/
|
|
|
|
-/* Exported functions --------------------------------------------------------*/
|
|
|
|
-void MAX7219_Config(void);
|
|
|
|
-void MAX7219_WriteData(max7219_reg_t reg, uint8_t data);
|
|
|
|
-
|
|
|
|
-#endif /* __MAX7219_H */
|
|
|
|
|
|
+
|
|
|
|
+/* Exported constants --------------------------------------------------------*/
|
|
|
|
+/* Exported macro ------------------------------------------------------------*/
|
|
|
|
+/* Exported variables --------------------------------------------------------*/
|
|
|
|
+/* Exported functions --------------------------------------------------------*/
|
|
|
|
+void MAX7219_Config(void);
|
|
|
|
+void MAX7219_WriteData(max7219_reg_t reg, uint8_t data);
|
|
|
|
+
|
|
|
|
+#endif /* __MAX7219_H */
|