bargraph5  2.1.0.0
bargraph5.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 BARGRAPH5_H
29 #define BARGRAPH5_H
30 
31 #ifdef __cplusplus
32 extern "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_digital_in.h"
51 #include "drv_spi_master.h"
52 #include "spi_specifics.h"
53 
74 #define BARGRAPH5_CHANNELS_NUM 24
75 
80 #define BARGRAPH5_BRIGHTNESS_MIN 0
81 #define BARGRAPH5_BRIGHTNESS_DEFAULT 3000
82 #define BARGRAPH5_BRIGHTNESS_MAX 4095
83 
92 #define BARGRAPH5_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
93 #define BARGRAPH5_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
94  // bargraph5_set
96 
111 #define BARGRAPH5_MAP_MIKROBUS( cfg, mikrobus ) \
112  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
113  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
114  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
115  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
116  cfg.blank = MIKROBUS( mikrobus, MIKROBUS_PWM );
117  // bargraph5_map // bargraph5
120 
125 typedef struct
126 {
127  // Output pins
128  digital_out_t blank;
130  // Modules
131  spi_master_t spi;
133  pin_name_t chip_select;
135  uint16_t channels[ BARGRAPH5_CHANNELS_NUM ];
137 } bargraph5_t;
138 
143 typedef struct
144 {
145  // Communication gpio pins
146  pin_name_t miso;
147  pin_name_t mosi;
148  pin_name_t sck;
149  pin_name_t cs;
151  // Additional gpio pins
152  pin_name_t blank;
154  // static variable
155  uint32_t spi_speed;
156  spi_master_mode_t spi_mode;
157  spi_master_chip_select_polarity_t cs_polarity;
160 
165 typedef enum
166 {
173 
175 
180 typedef enum
181 {
187 
189 
194 typedef enum
195 {
197  BARGRAPH5_ERROR = -1
198 
200 
217 
232 
246 
259 
272 
284 
296 
314  bargraph5_level_t level, uint16_t brightness );
315 
316 #ifdef __cplusplus
317 }
318 #endif
319 #endif // BARGRAPH5_H
320  // bargraph5
322 
323 // ------------------------------------------------------------------------ END
BARGRAPH5_BAR_5
@ BARGRAPH5_BAR_5
Definition: bargraph5.h:172
BARGRAPH5_BAR_2
@ BARGRAPH5_BAR_2
Definition: bargraph5.h:169
bargraph5_cfg_t::mosi
pin_name_t mosi
Definition: bargraph5.h:147
bargraph5_bar_sel_t
bargraph5_bar_sel_t
BarGraph 5 Click select bar channel.
Definition: bargraph5.h:166
bargraph5_cfg_t::sck
pin_name_t sck
Definition: bargraph5.h:148
bargraph5_t::spi
spi_master_t spi
Definition: bargraph5.h:131
spi_specifics.h
This file contains SPI specific macros, functions, etc.
bargraph5_output_disable
void bargraph5_output_disable(bargraph5_t *ctx)
BarGraph 5 output disable function.
BARGRAPH5_ERROR
@ BARGRAPH5_ERROR
Definition: bargraph5.h:197
BARGRAPH5_LEVEL_2
@ BARGRAPH5_LEVEL_2
Definition: bargraph5.h:184
bargraph5_read_channels
err_t bargraph5_read_channels(bargraph5_t *ctx)
BarGraph 5 read channels function.
BARGRAPH5_BAR_4
@ BARGRAPH5_BAR_4
Definition: bargraph5.h:171
bargraph5_t::blank
digital_out_t blank
Definition: bargraph5.h:128
bargraph5_cfg_t::blank
pin_name_t blank
Definition: bargraph5.h:152
bargraph5_t::chip_select
pin_name_t chip_select
Definition: bargraph5.h:133
BARGRAPH5_LEVEL_4
@ BARGRAPH5_LEVEL_4
Definition: bargraph5.h:186
bargraph5_init
err_t bargraph5_init(bargraph5_t *ctx, bargraph5_cfg_t *cfg)
BarGraph 5 initialization function.
BARGRAPH5_OK
@ BARGRAPH5_OK
Definition: bargraph5.h:196
bargraph5_cfg_t::spi_speed
uint32_t spi_speed
Definition: bargraph5.h:155
BARGRAPH5_LEVEL_3
@ BARGRAPH5_LEVEL_3
Definition: bargraph5.h:185
BARGRAPH5_BAR_3
@ BARGRAPH5_BAR_3
Definition: bargraph5.h:170
bargraph5_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: bargraph5.h:157
bargraph5_level_t
bargraph5_level_t
BarGraph 5 Click bar level.
Definition: bargraph5.h:181
BARGRAPH5_BAR_0
@ BARGRAPH5_BAR_0
Definition: bargraph5.h:167
bargraph5_default_cfg
err_t bargraph5_default_cfg(bargraph5_t *ctx)
BarGraph 5 default configuration function.
BARGRAPH5_LEVEL_0
@ BARGRAPH5_LEVEL_0
Definition: bargraph5.h:182
bargraph5_set_bar_level
err_t bargraph5_set_bar_level(bargraph5_t *ctx, bargraph5_bar_sel_t bar_num, bargraph5_level_t level, uint16_t brightness)
BarGraph 5 set bar level function.
BARGRAPH5_BAR_1
@ BARGRAPH5_BAR_1
Definition: bargraph5.h:168
bargraph5_return_value_t
bargraph5_return_value_t
BarGraph 5 Click return value data.
Definition: bargraph5.h:195
BARGRAPH5_LEVEL_1
@ BARGRAPH5_LEVEL_1
Definition: bargraph5.h:183
BARGRAPH5_CHANNELS_NUM
#define BARGRAPH5_CHANNELS_NUM
BarGraph 5 number of output channels.
Definition: bargraph5.h:74
bargraph5_cfg_setup
void bargraph5_cfg_setup(bargraph5_cfg_t *cfg)
BarGraph 5 configuration object setup function.
bargraph5_t
BarGraph 5 Click context object.
Definition: bargraph5.h:126
bargraph5_cfg_t
BarGraph 5 Click configuration object.
Definition: bargraph5.h:144
bargraph5_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: bargraph5.h:156
bargraph5_output_enable
void bargraph5_output_enable(bargraph5_t *ctx)
BarGraph 5 output enable function.
bargraph5_cfg_t::cs
pin_name_t cs
Definition: bargraph5.h:149
bargraph5_write_channels
err_t bargraph5_write_channels(bargraph5_t *ctx)
BarGraph 5 write channels function.
bargraph5_cfg_t::miso
pin_name_t miso
Definition: bargraph5.h:146