bargraph3 2.0.0.0
bargraph3.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef BARGRAPH3_H
36#define BARGRAPH3_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_spi_master.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
67#define BARGRAPH3_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
69 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
70 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
71 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
72 cfg.oe = MIKROBUS( mikrobus, MIKROBUS_AN ); \
73 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
74 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM )
81#define BARGRAPH3_RETVAL uint8_t
82
83#define BARGRAPH3_OK 0x00
84#define BARGRAPH3_INIT_ERROR 0xFF
91#define BARGRAPH3_LED_0 0
92#define BARGRAPH3_LED_1 1
93#define BARGRAPH3_LED_2 2
94#define BARGRAPH3_LED_3 3
95#define BARGRAPH3_LED_4 4
96#define BARGRAPH3_LED_5 5
103#define BARGRAPH3_INCREASE_LED 1
104#define BARGRAPH3_CONTROL_ONE_LED 0
111#define BARGRAPH3_DIRECTION_TOP_TO_BOTTOM 1
112#define BARGRAPH3_DIRECTION_BOTTOM_TO_TOP 0
119#define BARGRAPH3_DEVICE_ENABLE 0
120#define BARGRAPH3_DEVICE_DISABLE 1
123 // End group macro
124// --------------------------------------------------------------- PUBLIC TYPES
133typedef struct
134{
135 digital_out_t cs;
136
137 // Output pins
138
139 digital_out_t oe;
140 digital_out_t rst;
141 digital_out_t pwm;
142
143 // Modules
144
145 spi_master_t spi;
146 pin_name_t chip_select;
147
149
153typedef struct
154{
155 // Communication gpio pins
156
157 pin_name_t miso;
158 pin_name_t mosi;
159 pin_name_t sck;
160 pin_name_t cs;
161
162 // Additional gpio pins
163
164 pin_name_t oe;
165 pin_name_t rst;
166 pin_name_t pwm;
167
168 // static variable
169
170 uint32_t spi_speed;
171 spi_master_mode_t spi_mode;
172 spi_master_chip_select_polarity_t cs_polarity;
173
175
176 // End types groupS
177// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
178
183#ifdef __cplusplus
184extern "C"{
185#endif
186
196
206
215
227void bargraph3_generic_transfer ( bargraph3_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len );
228
236void bargraph3_enable ( bargraph3_t *ctx, uint8_t state );
237
245
253void bargraph3_set_pwm ( bargraph3_t *ctx, uint8_t state );
254
264void bargraph3_display ( bargraph3_t *ctx, uint8_t ctrl, uint8_t dir, uint8_t counter);
265
266#ifdef __cplusplus
267}
268#endif
269#endif // _BARGRAPH3_H_
270
271 // End public_function group
273
274// ------------------------------------------------------------------------- END
#define BARGRAPH3_RETVAL
Definition bargraph3.h:81
void bargraph3_set_pwm(bargraph3_t *ctx, uint8_t state)
Functions for set PWM.
void bargraph3_default_cfg(bargraph3_t *ctx)
Click Default Configuration function.
void bargraph3_cfg_setup(bargraph3_cfg_t *cfg)
Config Object Initialization function.
void bargraph3_display(bargraph3_t *ctx, uint8_t ctrl, uint8_t dir, uint8_t counter)
Displays function.
void bargraph3_reset(bargraph3_t *ctx)
Functions for reset the chip.
BARGRAPH3_RETVAL bargraph3_init(bargraph3_t *ctx, bargraph3_cfg_t *cfg)
Initialization function.
void bargraph3_generic_transfer(bargraph3_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void bargraph3_enable(bargraph3_t *ctx, uint8_t state)
Functions for enable the chip.
Click configuration structure definition.
Definition bargraph3.h:154
spi_master_chip_select_polarity_t cs_polarity
Definition bargraph3.h:172
pin_name_t sck
Definition bargraph3.h:159
pin_name_t oe
Definition bargraph3.h:164
spi_master_mode_t spi_mode
Definition bargraph3.h:171
pin_name_t mosi
Definition bargraph3.h:158
uint32_t spi_speed
Definition bargraph3.h:170
pin_name_t pwm
Definition bargraph3.h:166
pin_name_t miso
Definition bargraph3.h:157
pin_name_t rst
Definition bargraph3.h:165
pin_name_t cs
Definition bargraph3.h:160
Click ctx object definition.
Definition bargraph3.h:134
digital_out_t cs
Definition bargraph3.h:135
spi_master_t spi
Definition bargraph3.h:145
digital_out_t pwm
Definition bargraph3.h:141
digital_out_t oe
Definition bargraph3.h:139
digital_out_t rst
Definition bargraph3.h:140
pin_name_t chip_select
Definition bargraph3.h:146