uts7segr 2.0.0.0
uts7segr.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 UTS7SEGR_H
29#define UTS7SEGR_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
71#define UTS7SEGR_DISPLAY_ON 0x01
72#define UTS7SEGR_DISPLAY_OFF 0x00
73
74#define UTS7SEGR_DOT_LEFT 0x02
75#define UTS7SEGR_DOT_RIGHT 0x01
76#define UTS7SEGR_DOT_LEFT_RIGHT 0x03
77#define UTS7SEGR_NO_DOT 0x00
78
79 // uts7segr_set
80
95#define UTS7SEGR_MAP_MIKROBUS( cfg, mikrobus ) \
96 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
97 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
98 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
99 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
100 cfg.oe = MIKROBUS( mikrobus, MIKROBUS_PWM );
101
102 // uts7segr_map
103 // uts7segr
104
109typedef struct
110{
111 // Output pins
112
113 digital_out_t oe;
115 // Modules
116
117 spi_master_t spi;
119 pin_name_t chip_select;
121} uts7segr_t;
122
127typedef struct
128{
129 // Communication gpio pins
130
131 pin_name_t miso;
132 pin_name_t mosi;
133 pin_name_t sck;
134 pin_name_t cs;
136 pin_name_t oe;
138 // static variable
139
140 uint32_t spi_speed;
141 spi_master_mode_t spi_mode;
142 spi_master_chip_select_polarity_t cs_polarity;
145
150typedef enum
151{
153 UTS7SEGR_ERROR = -1
154
156
173
189
202
219err_t uts7segr_generic_write ( uts7segr_t *ctx, uint8_t *data_in );
220
231void uts7segr_display_state ( uts7segr_t *ctx, uint8_t state );
232
246err_t uts7segr_display_number ( uts7segr_t *ctx, uint8_t number, uint8_t dot_pos );
247
248#ifdef __cplusplus
249}
250#endif
251#endif // UTS7SEGR_H
252
253 // uts7segr
254
255// ------------------------------------------------------------------------ END
void uts7segr_cfg_setup(uts7segr_cfg_t *cfg)
UT-S 7-SEG R configuration object setup function.
err_t uts7segr_display_number(uts7segr_t *ctx, uint8_t number, uint8_t dot_pos)
UT-S 7-SEG R display number function.
err_t uts7segr_generic_write(uts7segr_t *ctx, uint8_t *data_in)
UT-S 7-SEG R data writing function.
void uts7segr_display_state(uts7segr_t *ctx, uint8_t state)
UT-S 7-SEG R display state function.
err_t uts7segr_init(uts7segr_t *ctx, uts7segr_cfg_t *cfg)
UT-S 7-SEG R initialization function.
void uts7segr_default_cfg(uts7segr_t *ctx)
UT-S 7-SEG R default configuration function.
UT-S 7-SEG R Click configuration object.
Definition uts7segr.h:128
spi_master_chip_select_polarity_t cs_polarity
Definition uts7segr.h:142
pin_name_t sck
Definition uts7segr.h:133
pin_name_t oe
Definition uts7segr.h:136
spi_master_mode_t spi_mode
Definition uts7segr.h:141
pin_name_t mosi
Definition uts7segr.h:132
uint32_t spi_speed
Definition uts7segr.h:140
pin_name_t miso
Definition uts7segr.h:131
pin_name_t cs
Definition uts7segr.h:134
UT-S 7-SEG R Click context object.
Definition uts7segr.h:110
spi_master_t spi
Definition uts7segr.h:117
digital_out_t oe
Definition uts7segr.h:113
pin_name_t chip_select
Definition uts7segr.h:119
uts7segr_return_value_t
UT-S 7-SEG R Click return value data.
Definition uts7segr.h:151
@ UTS7SEGR_OK
Definition uts7segr.h:152
@ UTS7SEGR_ERROR
Definition uts7segr.h:153