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
32extern "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
97typedef struct
98{
99 // Output pins
100 digital_out_t rst;
102 // Modules
103 spi_master_t spi;
105 pin_name_t chip_select;
108
113typedef 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
135typedef enum
136{
138 BARGRAPH4_ERROR = -1
139
141
146typedef enum
147{
152
154
159typedef enum
160{
166
168
185
201
214err_t bargraph4_set_output ( bargraph4_t *ctx, uint16_t ch_mask );
215
228err_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_level_t
BarGraph 4 Click bar level.
Definition: bargraph4.h:160
@ BARGRAPH4_LEVEL_2
Definition: bargraph4.h:163
@ BARGRAPH4_LEVEL_4
Definition: bargraph4.h:165
@ BARGRAPH4_LEVEL_0
Definition: bargraph4.h:161
@ BARGRAPH4_LEVEL_3
Definition: bargraph4.h:164
@ BARGRAPH4_LEVEL_1
Definition: bargraph4.h:162
bargraph4_sel_ch_t
BarGraph 4 Click select channel.
Definition: bargraph4.h:147
@ BARGRAPH4_CHANNEL_A
Definition: bargraph4.h:148
@ BARGRAPH4_CHANNEL_B
Definition: bargraph4.h:149
@ BARGRAPH4_CHANNEL_C
Definition: bargraph4.h:150
@ BARGRAPH4_CHANNEL_D
Definition: bargraph4.h:151
bargraph4_return_value_t
BarGraph 4 Click return value data.
Definition: bargraph4.h:136
@ BARGRAPH4_ERROR
Definition: bargraph4.h:138
@ BARGRAPH4_OK
Definition: bargraph4.h:137
void bargraph4_enable_output(bargraph4_t *ctx)
BarGraph 4 enable output function.
void bargraph4_cfg_setup(bargraph4_cfg_t *cfg)
BarGraph 4 configuration object setup function.
err_t bargraph4_set_output(bargraph4_t *ctx, uint16_t ch_mask)
BarGraph 4 set output function.
void bargraph4_disable_output(bargraph4_t *ctx)
BarGraph 4 disable output function.
err_t bargraph4_init(bargraph4_t *ctx, bargraph4_cfg_t *cfg)
BarGraph 4 initialization function.
err_t bargraph4_set_channel_level(bargraph4_t *ctx, bargraph4_sel_ch_t channel, bargraph4_level_t level)
BarGraph 4 set channel level function.
err_t bargraph4_read_output(bargraph4_t *ctx, uint16_t *ch_mask)
BarGraph 4 read output function.
This file contains SPI specific macros, functions, etc.
BarGraph 4 Click configuration object.
Definition: bargraph4.h:114
spi_master_chip_select_polarity_t cs_polarity
Definition: bargraph4.h:127
pin_name_t sck
Definition: bargraph4.h:118
spi_master_mode_t spi_mode
Definition: bargraph4.h:126
pin_name_t mosi
Definition: bargraph4.h:117
uint32_t spi_speed
Definition: bargraph4.h:125
pin_name_t miso
Definition: bargraph4.h:116
pin_name_t rst
Definition: bargraph4.h:122
pin_name_t cs
Definition: bargraph4.h:119
BarGraph 4 Click context object.
Definition: bargraph4.h:98
spi_master_t spi
Definition: bargraph4.h:103
digital_out_t rst
Definition: bargraph4.h:100
pin_name_t chip_select
Definition: bargraph4.h:105