utm7segr 2.0.0.0
utm7segr.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
28#ifndef UTM7SEGR_H
29#define UTM7SEGR_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_spi_master.h"
51
72#define UTM7SEGR_DOT_LEFT 0x02
73#define UTM7SEGR_DOT_RIGHT 0x01
74#define UTM7SEGR_DOT_LEFT_RIGHT 0x03
75#define UTM7SEGR_NO_DOT 0x00
76
77#define UTM7SEGR_DISPLAY_ON 0x01
78#define UTM7SEGR_DISPLAY_OFF 0x00
79
80 // utm7segr_set
81
96#define UTM7SEGR_MAP_MIKROBUS( cfg, mikrobus ) \
97 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
98 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
99 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
100 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
101 cfg.oe = MIKROBUS( mikrobus, MIKROBUS_PWM )
102
103 // utm7segr_map
104 // utm7segr
105
112typedef struct
113{
114 // Output pins
115
116 digital_out_t oe;
118 // Modules
119
120 spi_master_t spi;
122 pin_name_t chip_select;
124} utm7segr_t;
125
130typedef struct
131{
132 // Communication gpio pins
133
134 pin_name_t miso;
135 pin_name_t mosi;
136 pin_name_t sck;
137 pin_name_t cs;
139 // Additional gpio pins
140
141 pin_name_t oe;
143 // static variable
144
145 uint32_t spi_speed;
146 spi_master_mode_t spi_mode;
147 spi_master_chip_select_polarity_t cs_polarity;
150
155typedef enum
156{
158 UTM7SEGR_ERROR = -1
159
161
178
194
207
221err_t utm7segr_generic_write ( utm7segr_t *ctx, uint8_t *data_in );
222
235void utm7segr_display_state ( utm7segr_t *ctx, uint8_t state ) ;
236
251err_t utm7segr_display_number ( utm7segr_t *ctx, uint8_t number, uint8_t dot_pos );
252
253#ifdef __cplusplus
254}
255#endif
256#endif // UTM7SEGR_H
257
258 // utm7segr
259
260// ------------------------------------------------------------------------ END
void utm7segr_cfg_setup(utm7segr_cfg_t *cfg)
UT-M 7-SEG R configuration object setup function.
err_t utm7segr_init(utm7segr_t *ctx, utm7segr_cfg_t *cfg)
UT-M 7-SEG R initialization function.
void utm7segr_display_state(utm7segr_t *ctx, uint8_t state)
UT-M 7-SEG R display state function.
err_t utm7segr_generic_write(utm7segr_t *ctx, uint8_t *data_in)
UT-M 7-SEG R data writing function.
void utm7segr_default_cfg(utm7segr_t *ctx)
UT-M 7-SEG R default configuration function.
err_t utm7segr_display_number(utm7segr_t *ctx, uint8_t number, uint8_t dot_pos)
UT-M 7-SEG R display number function.
UT-M 7-SEG R Click configuration object.
Definition utm7segr.h:131
spi_master_chip_select_polarity_t cs_polarity
Definition utm7segr.h:147
pin_name_t sck
Definition utm7segr.h:136
pin_name_t oe
Definition utm7segr.h:141
spi_master_mode_t spi_mode
Definition utm7segr.h:146
pin_name_t mosi
Definition utm7segr.h:135
uint32_t spi_speed
Definition utm7segr.h:145
pin_name_t miso
Definition utm7segr.h:134
pin_name_t cs
Definition utm7segr.h:137
UT-M 7-SEG R Click context object.
Definition utm7segr.h:113
spi_master_t spi
Definition utm7segr.h:120
digital_out_t oe
Definition utm7segr.h:116
pin_name_t chip_select
Definition utm7segr.h:122
utm7segr_return_value_t
UT-M 7-SEG R Click return value data.
Definition utm7segr.h:156
@ UTM7SEGR_OK
Definition utm7segr.h:157
@ UTM7SEGR_ERROR
Definition utm7segr.h:158