bargraph4  2.0.0.0
bargraph4.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 BARGRAPH4_H
29 #define BARGRAPH4_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 
78 #define BARGRAPH4_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
79 #define BARGRAPH4_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
80  // bargraph4_set
82 
97 #define BARGRAPH4_MAP_MIKROBUS( cfg, mikrobus ) \
98  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
99  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
100  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
101  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
102  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST );
103  // bargraph4_map // bargraph4
106 
111 typedef struct
112 {
113  // Output pins
114  digital_out_t rst;
116  // Modules
117  spi_master_t spi;
119  pin_name_t chip_select;
121 } bargraph4_t;
122 
127 typedef struct
128 {
129  // Communication gpio pins
130  pin_name_t miso;
131  pin_name_t mosi;
132  pin_name_t sck;
133  pin_name_t cs;
135  // Additional gpio pins
136  pin_name_t rst;
138  // static variable
139  uint32_t spi_speed;
140  spi_master_mode_t spi_mode;
141  spi_master_chip_select_polarity_t cs_polarity;
144 
149 typedef enum
150 {
152  BARGRAPH4_ERROR = -1
153 
155 
160 typedef enum
161 {
166 
168 
173 typedef enum
174 {
180 
182 
199 
215 
228 err_t bargraph4_set_output ( bargraph4_t *ctx, uint16_t ch_mask );
229 
242 err_t bargraph4_read_output ( bargraph4_t *ctx, uint16_t *ch_mask );
243 
253 
263 
280 
281 #ifdef __cplusplus
282 }
283 #endif
284 #endif // BARGRAPH4_H
285  // bargraph4
287 
288 // ------------------------------------------------------------------------ END
BARGRAPH4_CHANNEL_C
@ BARGRAPH4_CHANNEL_C
Definition: bargraph4.h:164
bargraph4_level_t
bargraph4_level_t
BarGraph 4 Click bar level.
Definition: bargraph4.h:174
bargraph4_cfg_t::sck
pin_name_t sck
Definition: bargraph4.h:132
BARGRAPH4_CHANNEL_D
@ BARGRAPH4_CHANNEL_D
Definition: bargraph4.h:165
BARGRAPH4_ERROR
@ BARGRAPH4_ERROR
Definition: bargraph4.h:152
bargraph4_return_value_t
bargraph4_return_value_t
BarGraph 4 Click return value data.
Definition: bargraph4.h:150
bargraph4_init
err_t bargraph4_init(bargraph4_t *ctx, bargraph4_cfg_t *cfg)
BarGraph 4 initialization function.
bargraph4_set_channel_level
err_t bargraph4_set_channel_level(bargraph4_t *ctx, bargraph4_sel_ch_t channel, bargraph4_level_t level)
BarGraph 4 set channel level function.
spi_specifics.h
This file contains SPI specific macros, functions, etc.
bargraph4_t::rst
digital_out_t rst
Definition: bargraph4.h:114
BARGRAPH4_OK
@ BARGRAPH4_OK
Definition: bargraph4.h:151
bargraph4_enable_output
void bargraph4_enable_output(bargraph4_t *ctx)
BarGraph 4 enable output function.
bargraph4_cfg_t::rst
pin_name_t rst
Definition: bargraph4.h:136
bargraph4_cfg_t::cs
pin_name_t cs
Definition: bargraph4.h:133
bargraph4_set_output
err_t bargraph4_set_output(bargraph4_t *ctx, uint16_t ch_mask)
BarGraph 4 set output function.
bargraph4_cfg_t::mosi
pin_name_t mosi
Definition: bargraph4.h:131
bargraph4_cfg_setup
void bargraph4_cfg_setup(bargraph4_cfg_t *cfg)
BarGraph 4 configuration object setup function.
bargraph4_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: bargraph4.h:141
BARGRAPH4_LEVEL_0
@ BARGRAPH4_LEVEL_0
Definition: bargraph4.h:175
BARGRAPH4_LEVEL_1
@ BARGRAPH4_LEVEL_1
Definition: bargraph4.h:176
bargraph4_t::spi
spi_master_t spi
Definition: bargraph4.h:117
BARGRAPH4_CHANNEL_A
@ BARGRAPH4_CHANNEL_A
Definition: bargraph4.h:162
bargraph4_cfg_t::miso
pin_name_t miso
Definition: bargraph4.h:130
bargraph4_read_output
err_t bargraph4_read_output(bargraph4_t *ctx, uint16_t *ch_mask)
BarGraph 4 read output function.
bargraph4_t
BarGraph 4 Click context object.
Definition: bargraph4.h:112
bargraph4_disable_output
void bargraph4_disable_output(bargraph4_t *ctx)
BarGraph 4 disable output function.
bargraph4_cfg_t::spi_speed
uint32_t spi_speed
Definition: bargraph4.h:139
bargraph4_cfg_t
BarGraph 4 Click configuration object.
Definition: bargraph4.h:128
BARGRAPH4_LEVEL_3
@ BARGRAPH4_LEVEL_3
Definition: bargraph4.h:178
BARGRAPH4_LEVEL_2
@ BARGRAPH4_LEVEL_2
Definition: bargraph4.h:177
bargraph4_sel_ch_t
bargraph4_sel_ch_t
BarGraph 4 Click select channel.
Definition: bargraph4.h:161
BARGRAPH4_CHANNEL_B
@ BARGRAPH4_CHANNEL_B
Definition: bargraph4.h:163
bargraph4_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: bargraph4.h:140
BARGRAPH4_LEVEL_4
@ BARGRAPH4_LEVEL_4
Definition: bargraph4.h:179
bargraph4_t::chip_select
pin_name_t chip_select
Definition: bargraph4.h:119