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
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40#include "drv_spi_master.h"
41
42// -------------------------------------------------------------- PUBLIC MACROS
53#define BARGRAPH3_MAP_MIKROBUS( cfg, mikrobus ) \
54 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
55 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
56 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
57 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
58 cfg.oe = MIKROBUS( mikrobus, MIKROBUS_AN ); \
59 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
60 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM )
67#define BARGRAPH3_RETVAL uint8_t
68
69#define BARGRAPH3_OK 0x00
70#define BARGRAPH3_INIT_ERROR 0xFF
77#define BARGRAPH3_LED_0 0
78#define BARGRAPH3_LED_1 1
79#define BARGRAPH3_LED_2 2
80#define BARGRAPH3_LED_3 3
81#define BARGRAPH3_LED_4 4
82#define BARGRAPH3_LED_5 5
89#define BARGRAPH3_INCREASE_LED 1
90#define BARGRAPH3_CONTROL_ONE_LED 0
97#define BARGRAPH3_DIRECTION_TOP_TO_BOTTOM 1
98#define BARGRAPH3_DIRECTION_BOTTOM_TO_TOP 0
105#define BARGRAPH3_DEVICE_ENABLE 0
106#define BARGRAPH3_DEVICE_DISABLE 1 // End group macro
110// --------------------------------------------------------------- PUBLIC TYPES
119typedef struct
120{
121 digital_out_t cs;
122
123 // Output pins
124
125 digital_out_t oe;
126 digital_out_t rst;
127 digital_out_t pwm;
128
129 // Modules
130
131 spi_master_t spi;
132 pin_name_t chip_select;
133
135
139typedef struct
140{
141 // Communication gpio pins
142
143 pin_name_t miso;
144 pin_name_t mosi;
145 pin_name_t sck;
146 pin_name_t cs;
147
148 // Additional gpio pins
149
150 pin_name_t oe;
151 pin_name_t rst;
152 pin_name_t pwm;
153
154 // static variable
155
156 uint32_t spi_speed;
157 spi_master_mode_t spi_mode;
158 spi_master_chip_select_polarity_t cs_polarity;
159
161 // End types groupS
163// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
164
169#ifdef __cplusplus
170extern "C"{
171#endif
172
182
192
201
213void bargraph3_generic_transfer ( bargraph3_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len );
214void bargraph3_enable ( bargraph3_t *ctx, uint8_t state );
223void bargraph3_reset ( bargraph3_t *ctx );
231void bargraph3_set_pwm ( bargraph3_t *ctx, uint8_t state );
240void bargraph3_display ( bargraph3_t *ctx, uint8_t ctrl, uint8_t dir, uint8_t counter);
251
252#ifdef __cplusplus
253}
254#endif
255#endif // _BARGRAPH3_H_
256 // End public_function group
259
260// ------------------------------------------------------------------------- END
#define BARGRAPH3_RETVAL
Definition: bargraph3.h:67
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:140
spi_master_chip_select_polarity_t cs_polarity
Definition: bargraph3.h:158
pin_name_t sck
Definition: bargraph3.h:145
pin_name_t oe
Definition: bargraph3.h:150
spi_master_mode_t spi_mode
Definition: bargraph3.h:157
pin_name_t mosi
Definition: bargraph3.h:144
uint32_t spi_speed
Definition: bargraph3.h:156
pin_name_t pwm
Definition: bargraph3.h:152
pin_name_t miso
Definition: bargraph3.h:143
pin_name_t rst
Definition: bargraph3.h:151
pin_name_t cs
Definition: bargraph3.h:146
Click ctx object definition.
Definition: bargraph3.h:120
digital_out_t cs
Definition: bargraph3.h:121
spi_master_t spi
Definition: bargraph3.h:131
digital_out_t pwm
Definition: bargraph3.h:127
digital_out_t oe
Definition: bargraph3.h:125
digital_out_t rst
Definition: bargraph3.h:126
pin_name_t chip_select
Definition: bargraph3.h:132