bargraph3  2.0.0.0
bargraph3.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * 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 
43 // -------------------------------------------------------------- PUBLIC MACROS
54 #define BARGRAPH3_MAP_MIKROBUS( cfg, mikrobus ) \
55  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
56  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
57  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
58  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
59  cfg.oe = MIKROBUS( mikrobus, MIKROBUS_AN ); \
60  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
61  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM );
62 
68 #define BARGRAPH3_RETVAL uint8_t
69 
70 #define BARGRAPH3_OK 0x00
71 #define BARGRAPH3_INIT_ERROR 0xFF
72 
78 #define BARGRAPH3_LED_0 0
79 #define BARGRAPH3_LED_1 1
80 #define BARGRAPH3_LED_2 2
81 #define BARGRAPH3_LED_3 3
82 #define BARGRAPH3_LED_4 4
83 #define BARGRAPH3_LED_5 5
84 
90 #define BARGRAPH3_INCREASE_LED 1
91 #define BARGRAPH3_CONTROL_ONE_LED 0
92 
98 #define BARGRAPH3_DIRECTION_TOP_TO_BOTTOM 1
99 #define BARGRAPH3_DIRECTION_BOTTOM_TO_TOP 0
100 
106 #define BARGRAPH3_DEVICE_ENABLE 0
107 #define BARGRAPH3_DEVICE_DISABLE 1
108  // End group macro
111 // --------------------------------------------------------------- PUBLIC TYPES
120 typedef struct
121 {
122  // Output pins
123 
124  digital_out_t oe;
125  digital_out_t rst;
126  digital_out_t pwm;
127  digital_out_t cs;
128 
129  // Modules
130 
131  spi_master_t spi;
132 
133 } bargraph3_t;
134 
138 typedef struct
139 {
140  // Communication gpio pins
141 
142  pin_name_t miso;
143  pin_name_t mosi;
144  pin_name_t sck;
145  pin_name_t cs;
146 
147  // Additional gpio pins
148 
149  pin_name_t oe;
150  pin_name_t rst;
151  pin_name_t pwm;
152 
153  // static variable
154 
155  hal_spi_speed_t spi_speed;
156  hal_spi_mode_t spi_mode;
157 
159  // End types groupS
161 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
162 
167 #ifdef __cplusplus
168 extern "C"{
169 #endif
170 
180 
189 
197 void bargraph3_default_cfg ( bargraph3_t *ctx );
198 
207 void bargraph3_generic_transfer ( bargraph3_t *ctx, spi_master_transfer_data_t *block );
208 void bargraph3_enable ( bargraph3_t *ctx, uint8_t state );
217 void bargraph3_reset ( bargraph3_t *ctx );
225 void bargraph3_set_pwm ( bargraph3_t *ctx, uint8_t state );
234 void bargraph3_display ( bargraph3_t *ctx, uint8_t ctrl, uint8_t dir, uint8_t counter);
245 
246 #ifdef __cplusplus
247 }
248 #endif
249 #endif // _BARGRAPH3_H_
250  // End public_function group
253 
254 // ------------------------------------------------------------------------- END
bargraph3_t::spi
spi_master_t spi
Definition: bargraph3.h:131
bargraph3_cfg_setup
void bargraph3_cfg_setup(bargraph3_cfg_t *cfg)
Config Object Initialization function.
BARGRAPH3_RETVAL
#define BARGRAPH3_RETVAL
Definition: bargraph3.h:68
bargraph3_cfg_t::miso
pin_name_t miso
Definition: bargraph3.h:142
bargraph3_reset
void bargraph3_reset(bargraph3_t *ctx)
Functions for reset the chip.
bargraph3_enable
void bargraph3_enable(bargraph3_t *ctx, uint8_t state)
Functions for enable the chip.
bargraph3_set_pwm
void bargraph3_set_pwm(bargraph3_t *ctx, uint8_t state)
Functions for set PWM.
bargraph3_t::rst
digital_out_t rst
Definition: bargraph3.h:125
bargraph3_cfg_t::mosi
pin_name_t mosi
Definition: bargraph3.h:143
bargraph3_t
Click ctx object definition.
Definition: bargraph3.h:120
bargraph3_cfg_t::cs
pin_name_t cs
Definition: bargraph3.h:145
bargraph3_cfg_t::spi_speed
hal_spi_speed_t spi_speed
Definition: bargraph3.h:155
bargraph3_t::cs
digital_out_t cs
Definition: bargraph3.h:127
bargraph3_generic_transfer
void bargraph3_generic_transfer(bargraph3_t *ctx, spi_master_transfer_data_t *block)
Generic transfer function.
bargraph3_cfg_t::sck
pin_name_t sck
Definition: bargraph3.h:144
bargraph3_cfg_t
Click configuration structure definition.
Definition: bargraph3.h:138
bargraph3_t::pwm
digital_out_t pwm
Definition: bargraph3.h:126
bargraph3_cfg_t::spi_mode
hal_spi_mode_t spi_mode
Definition: bargraph3.h:156
bargraph3_default_cfg
void bargraph3_default_cfg(bargraph3_t *ctx)
Click Default Configuration function.
bargraph3_cfg_t::rst
pin_name_t rst
Definition: bargraph3.h:150
bargraph3_display
void bargraph3_display(bargraph3_t *ctx, uint8_t ctrl, uint8_t dir, uint8_t counter)
Displays function.
bargraph3_init
BARGRAPH3_RETVAL bargraph3_init(bargraph3_t *ctx, bargraph3_cfg_t *cfg)
Initialization function.
bargraph3_cfg_t::oe
pin_name_t oe
Definition: bargraph3.h:149
bargraph3_cfg_t::pwm
pin_name_t pwm
Definition: bargraph3.h:151
bargraph3_t::oe
digital_out_t oe
Definition: bargraph3.h:124