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 "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_spi_master.h"
48 #include "spi_specifics.h"
49 
74 #define BARGRAPH4_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
75 #define BARGRAPH4_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
76  // bargraph4_set
78 
93 #define BARGRAPH4_MAP_MIKROBUS( cfg, mikrobus ) \
94  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
95  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
96  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
97  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
98  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST );
99  // bargraph4_map // bargraph4
102 
107 typedef struct
108 {
109  // Output pins
110  digital_out_t rst;
112  // Modules
113  spi_master_t spi;
115  pin_name_t chip_select;
117 } bargraph4_t;
118 
123 typedef struct
124 {
125  // Communication gpio pins
126  pin_name_t miso;
127  pin_name_t mosi;
128  pin_name_t sck;
129  pin_name_t cs;
131  // Additional gpio pins
132  pin_name_t rst;
134  // static variable
135  uint32_t spi_speed;
136  spi_master_mode_t spi_mode;
137  spi_master_chip_select_polarity_t cs_polarity;
140 
145 typedef enum
146 {
148  BARGRAPH4_ERROR = -1
149 
151 
156 typedef enum
157 {
162 
164 
169 typedef enum
170 {
176 
178 
195 
211 
224 err_t bargraph4_set_output ( bargraph4_t *ctx, uint16_t ch_mask );
225 
238 err_t bargraph4_read_output ( bargraph4_t *ctx, uint16_t *ch_mask );
239 
249 
259 
276 
277 #ifdef __cplusplus
278 }
279 #endif
280 #endif // BARGRAPH4_H
281  // bargraph4
283 
284 // ------------------------------------------------------------------------ END
BARGRAPH4_CHANNEL_C
@ BARGRAPH4_CHANNEL_C
Definition: bargraph4.h:160
bargraph4_level_t
bargraph4_level_t
BarGraph 4 Click bar level.
Definition: bargraph4.h:170
bargraph4_cfg_t::sck
pin_name_t sck
Definition: bargraph4.h:128
BARGRAPH4_CHANNEL_D
@ BARGRAPH4_CHANNEL_D
Definition: bargraph4.h:161
BARGRAPH4_ERROR
@ BARGRAPH4_ERROR
Definition: bargraph4.h:148
bargraph4_return_value_t
bargraph4_return_value_t
BarGraph 4 Click return value data.
Definition: bargraph4.h:146
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:110
BARGRAPH4_OK
@ BARGRAPH4_OK
Definition: bargraph4.h:147
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:132
bargraph4_cfg_t::cs
pin_name_t cs
Definition: bargraph4.h:129
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:127
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:137
BARGRAPH4_LEVEL_0
@ BARGRAPH4_LEVEL_0
Definition: bargraph4.h:171
BARGRAPH4_LEVEL_1
@ BARGRAPH4_LEVEL_1
Definition: bargraph4.h:172
bargraph4_t::spi
spi_master_t spi
Definition: bargraph4.h:113
BARGRAPH4_CHANNEL_A
@ BARGRAPH4_CHANNEL_A
Definition: bargraph4.h:158
bargraph4_cfg_t::miso
pin_name_t miso
Definition: bargraph4.h:126
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:108
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:135
bargraph4_cfg_t
BarGraph 4 Click configuration object.
Definition: bargraph4.h:124
BARGRAPH4_LEVEL_3
@ BARGRAPH4_LEVEL_3
Definition: bargraph4.h:174
BARGRAPH4_LEVEL_2
@ BARGRAPH4_LEVEL_2
Definition: bargraph4.h:173
bargraph4_sel_ch_t
bargraph4_sel_ch_t
BarGraph 4 Click select channel.
Definition: bargraph4.h:157
BARGRAPH4_CHANNEL_B
@ BARGRAPH4_CHANNEL_B
Definition: bargraph4.h:159
bargraph4_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: bargraph4.h:136
BARGRAPH4_LEVEL_4
@ BARGRAPH4_LEVEL_4
Definition: bargraph4.h:175
bargraph4_t::chip_select
pin_name_t chip_select
Definition: bargraph4.h:115