123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- /* MAX7219 Header file
- * ---------------------------
- * For more information see
- * http://www.adnbr.co.uk/articles/max7219-and-7-segment-displays
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <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
- * 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 "stm8s.h"
- #include "board.h"
- /* Exported defines ----------------------------------------------------------*/
- #define MAX7219_ON 0x01
- #define MAX7219_OFF 0x00
- #define MAX7219_BRIGHT 0x08
- // used LED digits - 1
- #define MAX7219_DIGITS 7
- /* Exported types ------------------------------------------------------------*/
- typedef enum _max7219_reg {
- RegNoOp = 0x00,
- RegDigit0 = 0x01,
- RegDigit1 = 0x07,
- RegDigit2 = 0x03,
- RegDigit3 = 0x06,
- RegDigit4 = 0x05,
- RegDigit5 = 0x04,
- RegDigit6 = 0x08,
- RegDigit7 = 0x02,
- RegDecodeMode = 0x09,
- RegIntensity = 0x0A,
- RegScanLimit = 0x0B,
- RegPower = 0x0C,
- RegTest = 0x0F
- } max7219_reg_t;
- // соответсвие бит сегментам
- typedef enum _max7219_seg {
- SegA = (uint8_t)(1 << 2),
- SegB = (uint8_t)(1 << 6),
- SegC = (uint8_t)(1 << 5),
- SegD = (uint8_t)(1 << 7),
- SegE = (uint8_t)(1 << 3),
- SegF = (uint8_t)(1 << 4),
- SegG = (uint8_t)(1 << 1),
- SegDP = (uint8_t)(1 << 0),
- } max7219_seg_t;
- // symbols без кодирования
- typedef enum _max7219_sym {
- Sym_0 = SegA | SegB | SegC | SegD | SegE | SegF,
- Sym_1 = SegB | SegC,
- Sym_2 = SegA | SegB | SegD | SegE | SegG,
- Sym_3 = SegA | SegB | SegC | SegD | SegG,
- Sym_4 = SegB | SegC | SegF | SegG,
- Sym_5 = SegA | SegC | SegD | SegF | SegG,
- Sym_6 = SegA | SegC | SegD | SegE | SegF | SegG,
- Sym_7 = SegA | SegB | SegC,
- Sym_8 = SegA | SegB | SegC | SegD | SegE | SegF | SegG,
- Sym_9 = SegA | SegB | SegC | SegD | SegF | SegG,
- Sym_A = SegA | SegB | SegC | SegE | SegF | SegG,
- Sym_b = SegC | SegD | SegE | SegF | SegG,
- Sym_c = SegD | SegE | SegG,
- Sym_C = SegA | SegD | SegE | SegF,
- Sym_d = SegB | SegC | SegD | SegE | SegG,
- Sym_E = SegA | SegD | SegE | SegF | SegG,
- Sym_F = SegA | SegE | SegF | SegG,
- Sym_i = SegC,
- Sym_h = SegC | SegE | SegF | SegG,
- Sym_H = SegB | SegC | SegE | SegF | SegG,
- Sym_n = SegC | SegE | SegG,
- Sym_o = SegC | SegD | SegE | SegG,
- Sym_P = SegA | SegB | SegE | SegF | SegG,
- Sym_t = SegD | SegE | SegF | SegG,
- Sym_u = SegC | SegD | SegE,
- Sym_U = SegB | SegC | SegD | SegE | SegF,
- Sym_Gradus = SegA | SegB | SegF | SegG,
- Sym_Minus = SegG,
- Sym_BLANK = 0x00,
- Sym_FULL = 0xFF,
- Sym_Dot = SegDP
- } 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 */
|