boost  2.0.0.0
boost.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 BOOST_H
36 #define BOOST_H
37 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_spi_master.h"
51 
52 // -------------------------------------------------------------- PUBLIC MACROS
62 #define BOOST_MAP_MIKROBUS( cfg, mikrobus ) \
63  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
64  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
65  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
66  cfg.cs1 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
67  cfg.cs2 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
68  cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST )
69 
75 #define BOOST_OK 0
76 #define BOOST_ERROR (-1)
77 
83 #define BOOST_CFG_VREF_BUFFERED 1
84 #define BOOST_CFG_VREF_UNBUFFERED 0
85 
86 #define BOOST_CFG_GAIN_1X 1
87 #define BOOST_CFG_GAIN_2X 0
88 
89 #define BOOST_CFG_POWER_OUT_ON 1
90 #define BOOST_CFG_POWER_OUT_OFF 0
91  // End group macro
94 // --------------------------------------------------------------- PUBLIC TYPES
103 typedef struct
104 {
105  uint8_t buf;
106  uint8_t ga;
107  uint8_t shdn;
108 
110 
114 typedef struct
115 {
116  // Output pins
117 
118  digital_out_t cs1;
119  digital_out_t cs2;
120  digital_out_t en;
121 
122  digital_in_t miso;
123 
124  // Modules
125 
126  spi_master_t spi;
127  pin_name_t chip_select1;
128  pin_name_t chip_select2;
129  spi_master_chip_select_polarity_t cs1_polarity;
130  spi_master_chip_select_polarity_t cs2_polarity;
131 
133 
134 } boost_t;
135 
139 typedef 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 cs1;
147  pin_name_t cs2;
148 
149  // Additional gpio pins
150 
151  pin_name_t en;
152 
153  // Static variable
154 
155  uint32_t spi_speed;
156  spi_master_mode_t spi_mode;
157  spi_master_chip_select_polarity_t cs1_polarity;
158  spi_master_chip_select_polarity_t cs2_polarity;
159 
161 
162 } boost_cfg_t;
163  // End types group
165 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
171 #ifdef __cplusplus
172 extern "C"{
173 #endif
174 
184 
195 err_t boost_init ( boost_t *ctx, boost_cfg_t *cfg );
196 
205 
214 
224 
236 err_t boost_dac_write ( boost_t *ctx, uint16_t dac_val );
237 
246 float boost_vout_read ( boost_t *ctx );
247 
248 #ifdef __cplusplus
249 }
250 #endif
251 #endif // BOOST_H
252  // End public_function group // End click Driver group
255 
256 // ------------------------------------------------------------------------ END
boost_dac_cfg_t::buf
uint8_t buf
Definition: boost.h:105
boost_vout_read
float boost_vout_read(boost_t *ctx)
VOUT Read function.
boost_cfg_t::cs1_polarity
spi_master_chip_select_polarity_t cs1_polarity
Definition: boost.h:157
boost_cfg_t::dac
boost_dac_cfg_t dac
Definition: boost.h:160
boost_t::miso
digital_in_t miso
Definition: boost.h:122
boost_device_enable
void boost_device_enable(boost_t *ctx)
Device Enable function.
boost_t::cs1_polarity
spi_master_chip_select_polarity_t cs1_polarity
Definition: boost.h:129
boost_t::chip_select2
pin_name_t chip_select2
Definition: boost.h:128
boost_t::cs1
digital_out_t cs1
Definition: boost.h:118
boost_dac_cfg_t::ga
uint8_t ga
Definition: boost.h:106
boost_t::spi
spi_master_t spi
Definition: boost.h:126
boost_cfg_t::spi_speed
uint32_t spi_speed
Definition: boost.h:155
boost_t::en
digital_out_t en
Definition: boost.h:120
boost_t::chip_select1
pin_name_t chip_select1
Definition: boost.h:127
boost_cfg_t::miso
pin_name_t miso
Definition: boost.h:143
boost_t::dac
boost_dac_cfg_t dac
Definition: boost.h:132
boost_init
err_t boost_init(boost_t *ctx, boost_cfg_t *cfg)
Initialization function.
boost_dac_cfg_t
Click DAC configuration structure definition.
Definition: boost.h:104
boost_cfg_t::en
pin_name_t en
Definition: boost.h:151
boost_t::cs2
digital_out_t cs2
Definition: boost.h:119
boost_cfg_t::cs2_polarity
spi_master_chip_select_polarity_t cs2_polarity
Definition: boost.h:158
boost_device_disable
void boost_device_disable(boost_t *ctx)
Device Disable function.
boost_cfg_t::sck
pin_name_t sck
Definition: boost.h:145
boost_cfg_t::cs2
pin_name_t cs2
Definition: boost.h:147
boost_cfg_t
Click configuration structure definition.
Definition: boost.h:140
boost_t
Click ctx object definition.
Definition: boost.h:115
boost_cfg_setup
void boost_cfg_setup(boost_cfg_t *cfg)
Config Object Initialization function.
boost_dac_cfg_t::shdn
uint8_t shdn
Definition: boost.h:107
boost_cfg_t::cs1
pin_name_t cs1
Definition: boost.h:146
boost_dac_write
err_t boost_dac_write(boost_t *ctx, uint16_t dac_val)
DAC Write function.
boost_cfg_t::mosi
pin_name_t mosi
Definition: boost.h:144
boost_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: boost.h:156
boost_t::cs2_polarity
spi_master_chip_select_polarity_t cs2_polarity
Definition: boost.h:130
boost_dac_setup
void boost_dac_setup(boost_t *ctx, boost_dac_cfg_t *cfg)
DAC Setup function.