matrixr 2.0.0.0
matrixr.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
34// ----------------------------------------------------------------------------
35
36#ifndef MATRIXR_H
37#define MATRIXR_H
38
39#include "drv_digital_out.h"
40#include "drv_digital_in.h"
41#include "drv_spi_master.h"
42
43
44// -------------------------------------------------------------- PUBLIC MACROS
45
56#define MATRIXR_MAP_MIKROBUS( cfg, mikrobus ) \
57 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
58 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
59 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
60 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
61 cfg.csn = MIKROBUS( mikrobus, MIKROBUS_AN );
68#define MATRIXR_RETVAL uint8_t
69
70#define MATRIXR_OK 0x00
71#define MATRIXR_INIT_ERROR 0xFF
78#define MATRIXR_DECODE_MODE_REG 0x09
79#define MATRIXR_INTENSITY_REG 0x0A
80#define MATRIXR_SCAN_LIMIT_REG 0x0B
81#define MATRIXR_SHUTDOWN_REG 0x0C
82#define MATRIXR_DISPLAY_TEST_REG 0x0F
89#define MATRIXR_NO_DECODE 0x00
90#define MATRIXR_DECODE_DIGIT_0 0x01
91#define MATRIXR_DECODE_DIGIT_3_0 0x0F
92#define MATRIXR_DECODE_DIGIT_7 0xFF
99#define MATRIXR_INTEN_LVL_0 0x00
100#define MATRIXR_INTEN_LVL_1 0x03
101#define MATRIXR_INTEN_LVL_2 0x06
102#define MATRIXR_INTEN_LVL_3 0x09
103#define MATRIXR_INTEN_LVL_4 0x0C
104#define MATRIXR_INTEN_LVL_5 0x0F
111#define MATRIXR_DISPLAY_DIGIT_0 0x00
112#define MATRIXR_DISPLAY_DIGIT_0_1 0x01
113#define MATRIXR_DISPLAY_DIGIT_0_2 0x02
114#define MATRIXR_DISPLAY_DIGIT_0_3 0x03
115#define MATRIXR_DISPLAY_DIGIT_0_4 0x04
116#define MATRIXR_DISPLAY_DIGIT_0_5 0x05
117#define MATRIXR_DISPLAY_DIGIT_0_6 0x06
118#define MATRIXR_DISPLAY_DIGIT_0_7 0x07
125#define MATRIXR_SHUTDOWN_MODE 0x00
126#define MATRIXR_NORMAL_OPERATION 0x01
127
132#define MATRIXR_DISPLAY_NORMAL_OPERATION 0x00
133#define MATRIXR_DISPLAY_TEST_MODE 0X01 // End group macro
137
138// --------------------------------------------------------------- PUBLIC TYPES
139
148typedef struct
149{
150 // Output pins
151
152 digital_out_t csn;
153 digital_out_t cs;
154
155 // Modules
156
157 spi_master_t spi;
158 pin_name_t chip_select;
159
160} matrixr_t;
161
165typedef struct
166{
167 // Communication gpio pins
168
169 pin_name_t miso;
170 pin_name_t mosi;
171 pin_name_t sck;
172 pin_name_t cs;
173
174 // Additional gpio pins
175
176 pin_name_t csn;
177
178 // static variable
179
180 uint32_t spi_speed;
181 spi_master_mode_t spi_mode;
182 spi_master_chip_select_polarity_t cs_polarity;
183
184
186 // End types group
188
189// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
190
195#ifdef __cplusplus
196extern "C"{
197#endif
198
208
217
226
236void matrixr_display_characters ( matrixr_t *ctx, uint8_t left_char, uint8_t right_char );
237
247void matrixr_write_reg ( matrixr_t *ctx, uint8_t address, uint8_t input_data );
248
257
266
267#ifdef __cplusplus
268}
269#endif
270#endif // _MATRIXR_H_
271 // End public_function group
274
275// ------------------------------------------------------------------------- END
#define MATRIXR_RETVAL
Definition: matrixr.h:68
void matrixr_write_reg(matrixr_t *ctx, uint8_t address, uint8_t input_data)
Register write function.
void matrixr_set_csn_high(matrixr_t *ctx)
Set CSN pin to high function.
void matrixr_cfg_setup(matrixr_cfg_t *cfg)
Config Object Initialization function.
MATRIXR_RETVAL matrixr_init(matrixr_t *ctx, matrixr_cfg_t *cfg)
Initialization function.
void matrixr_default_cfg(matrixr_t *ctx)
Click Default Configuration function.
void matrixr_set_csn_low(matrixr_t *ctx)
Set CSN pin to low function.
void matrixr_display_characters(matrixr_t *ctx, uint8_t left_char, uint8_t right_char)
Display characters function.
Click configuration structure definition.
Definition: matrixr.h:166
pin_name_t csn
Definition: matrixr.h:176
spi_master_chip_select_polarity_t cs_polarity
Definition: matrixr.h:182
pin_name_t sck
Definition: matrixr.h:171
spi_master_mode_t spi_mode
Definition: matrixr.h:181
pin_name_t mosi
Definition: matrixr.h:170
uint32_t spi_speed
Definition: matrixr.h:180
pin_name_t miso
Definition: matrixr.h:169
pin_name_t cs
Definition: matrixr.h:172
Click ctx object definition.
Definition: matrixr.h:149
digital_out_t cs
Definition: matrixr.h:153
spi_master_t spi
Definition: matrixr.h:157
digital_out_t csn
Definition: matrixr.h:152
pin_name_t chip_select
Definition: matrixr.h:158