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 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_spi_master.h"
38 #include "spi_specifics.h"
39 
64 #define BARGRAPH4_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
65 #define BARGRAPH4_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
66  // bargraph4_set
68 
83 #define BARGRAPH4_MAP_MIKROBUS( cfg, mikrobus ) \
84  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
85  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
86  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
87  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
88  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST );
89  // bargraph4_map // bargraph4
92 
97 typedef struct
98 {
99  // Output pins
100  digital_out_t rst;
102  // Modules
103  spi_master_t spi;
105  pin_name_t chip_select;
107 } bargraph4_t;
108 
113 typedef struct
114 {
115  // Communication gpio pins
116  pin_name_t miso;
117  pin_name_t mosi;
118  pin_name_t sck;
119  pin_name_t cs;
121  // Additional gpio pins
122  pin_name_t rst;
124  // static variable
125  uint32_t spi_speed;
126  spi_master_mode_t spi_mode;
127  spi_master_chip_select_polarity_t cs_polarity;
130 
135 typedef enum
136 {
139 
141 
146 typedef enum
147 {
152 
154 
159 typedef enum
160 {
166 
168 
185 
200 err_t bargraph4_init ( bargraph4_t *ctx, bargraph4_cfg_t *cfg );
201 
214 err_t bargraph4_set_output ( bargraph4_t *ctx, uint16_t ch_mask );
215 
228 err_t bargraph4_read_output ( bargraph4_t *ctx, uint16_t *ch_mask );
229 
239 
249 
266 
267 #ifdef __cplusplus
268 }
269 #endif
270 #endif // BARGRAPH4_H
271  // bargraph4
273 
274 // ------------------------------------------------------------------------ END
BARGRAPH4_CHANNEL_C
Definition: bargraph4.h:150
bargraph4_level_t
bargraph4_level_t
BarGraph 4 Click bar level.
Definition: bargraph4.h:159
bargraph4_cfg_t::sck
pin_name_t sck
Definition: bargraph4.h:118
BARGRAPH4_CHANNEL_D
Definition: bargraph4.h:151
BARGRAPH4_ERROR
Definition: bargraph4.h:138
bargraph4_return_value_t
bargraph4_return_value_t
BarGraph 4 Click return value data.
Definition: bargraph4.h:135
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:100
BARGRAPH4_OK
Definition: bargraph4.h:137
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:122
bargraph4_cfg_t::cs
pin_name_t cs
Definition: bargraph4.h:119
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:117
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:127
BARGRAPH4_LEVEL_0
Definition: bargraph4.h:161
BARGRAPH4_LEVEL_1
Definition: bargraph4.h:162
bargraph4_t::spi
spi_master_t spi
Definition: bargraph4.h:103
BARGRAPH4_CHANNEL_A
Definition: bargraph4.h:148
bargraph4_cfg_t::miso
pin_name_t miso
Definition: bargraph4.h:116
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:97
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:125
bargraph4_cfg_t
BarGraph 4 Click configuration object.
Definition: bargraph4.h:113
BARGRAPH4_LEVEL_3
Definition: bargraph4.h:164
BARGRAPH4_LEVEL_2
Definition: bargraph4.h:163
bargraph4_sel_ch_t
bargraph4_sel_ch_t
BarGraph 4 Click select channel.
Definition: bargraph4.h:146
BARGRAPH4_CHANNEL_B
Definition: bargraph4.h:149
bargraph4_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: bargraph4.h:126
BARGRAPH4_LEVEL_4
Definition: bargraph4.h:165
bargraph4_t::chip_select
pin_name_t chip_select
Definition: bargraph4.h:105