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
35#include "drv_digital_out.h"
36#include "drv_spi_master.h"
37
58#define UTM7SEGR_DOT_LEFT 0x02
59#define UTM7SEGR_DOT_RIGHT 0x01
60#define UTM7SEGR_DOT_LEFT_RIGHT 0x03
61#define UTM7SEGR_NO_DOT 0x00
62
63#define UTM7SEGR_DISPLAY_ON 0x01
64#define UTM7SEGR_DISPLAY_OFF 0x00
65 // utm7segr_set
67
82#define UTM7SEGR_MAP_MIKROBUS( cfg, mikrobus ) \
83 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
84 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
85 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
86 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
87 cfg.oe = MIKROBUS( mikrobus, MIKROBUS_PWM )
88 // utm7segr_map // utm7segr
91
98typedef struct
99{
100 // Output pins
101
102 digital_out_t oe;
104 // Modules
105
106 spi_master_t spi;
108 pin_name_t chip_select;
110} utm7segr_t;
111
116typedef struct
117{
118 // Communication gpio pins
119
120 pin_name_t miso;
121 pin_name_t mosi;
122 pin_name_t sck;
123 pin_name_t cs;
125 // Additional gpio pins
126
127 pin_name_t oe;
129 // static variable
130
131 uint32_t spi_speed;
132 spi_master_mode_t spi_mode;
133 spi_master_chip_select_polarity_t cs_polarity;
136
141typedef enum
142{
144 UTM7SEGR_ERROR = -1
145
147
164
180
193
207err_t utm7segr_generic_write ( utm7segr_t *ctx, uint8_t *data_in );
208
221void utm7segr_display_state ( utm7segr_t *ctx, uint8_t state ) ;
222
237err_t utm7segr_display_number ( utm7segr_t *ctx, uint8_t number, uint8_t dot_pos );
238
239#ifdef __cplusplus
240}
241#endif
242#endif // UTM7SEGR_H
243 // utm7segr
245
246// ------------------------------------------------------------------------ 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:117
spi_master_chip_select_polarity_t cs_polarity
Definition: utm7segr.h:133
pin_name_t sck
Definition: utm7segr.h:122
pin_name_t oe
Definition: utm7segr.h:127
spi_master_mode_t spi_mode
Definition: utm7segr.h:132
pin_name_t mosi
Definition: utm7segr.h:121
uint32_t spi_speed
Definition: utm7segr.h:131
pin_name_t miso
Definition: utm7segr.h:120
pin_name_t cs
Definition: utm7segr.h:123
UT-M 7-SEG R Click context object.
Definition: utm7segr.h:99
spi_master_t spi
Definition: utm7segr.h:106
digital_out_t oe
Definition: utm7segr.h:102
pin_name_t chip_select
Definition: utm7segr.h:108
utm7segr_return_value_t
UT-M 7-SEG R Click return value data.
Definition: utm7segr.h:142
@ UTM7SEGR_OK
Definition: utm7segr.h:143
@ UTM7SEGR_ERROR
Definition: utm7segr.h:144