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 "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_spi_master.h"
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
52 #define BOOST_MAP_MIKROBUS( cfg, mikrobus ) \
53  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
54  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
55  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
56  cfg.cs1 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
57  cfg.cs2 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
58  cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST )
59 
65 #define BOOST_OK 0
66 #define BOOST_ERROR (-1)
67 
73 #define BOOST_CFG_VREF_BUFFERED 1
74 #define BOOST_CFG_VREF_UNBUFFERED 0
75 
76 #define BOOST_CFG_GAIN_1X 1
77 #define BOOST_CFG_GAIN_2X 0
78 
79 #define BOOST_CFG_POWER_OUT_ON 1
80 #define BOOST_CFG_POWER_OUT_OFF 0
81  // End group macro
84 // --------------------------------------------------------------- PUBLIC TYPES
93 typedef struct
94 {
95  uint8_t buf;
96  uint8_t ga;
97  uint8_t shdn;
98 
100 
104 typedef struct
105 {
106  // Output pins
107 
108  digital_out_t cs1;
109  digital_out_t cs2;
110  digital_out_t en;
111 
112  digital_in_t miso;
113 
114  // Modules
115 
116  spi_master_t spi;
117  pin_name_t chip_select1;
118  pin_name_t chip_select2;
119  spi_master_chip_select_polarity_t cs1_polarity;
120  spi_master_chip_select_polarity_t cs2_polarity;
121 
123 
124 } boost_t;
125 
129 typedef struct
130 {
131  // Communication gpio pins
132 
133  pin_name_t miso;
134  pin_name_t mosi;
135  pin_name_t sck;
136  pin_name_t cs1;
137  pin_name_t cs2;
138 
139  // Additional gpio pins
140 
141  pin_name_t en;
142 
143  // Static variable
144 
145  uint32_t spi_speed;
146  spi_master_mode_t spi_mode;
147  spi_master_chip_select_polarity_t cs1_polarity;
148  spi_master_chip_select_polarity_t cs2_polarity;
149 
151 
152 } boost_cfg_t;
153  // End types group
155 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
161 #ifdef __cplusplus
162 extern "C"{
163 #endif
164 
174 
185 err_t boost_init ( boost_t *ctx, boost_cfg_t *cfg );
186 
195 
204 
214 
226 err_t boost_dac_write ( boost_t *ctx, uint16_t dac_val );
227 
236 float boost_vout_read ( boost_t *ctx );
237 
238 #ifdef __cplusplus
239 }
240 #endif
241 #endif // BOOST_H
242  // End public_function group // End click Driver group
245 
246 // ------------------------------------------------------------------------ END
boost_dac_cfg_t::buf
uint8_t buf
Definition: boost.h:95
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:147
boost_cfg_t::dac
boost_dac_cfg_t dac
Definition: boost.h:150
boost_t::miso
digital_in_t miso
Definition: boost.h:112
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:119
boost_t::chip_select2
pin_name_t chip_select2
Definition: boost.h:118
boost_t::cs1
digital_out_t cs1
Definition: boost.h:108
boost_dac_cfg_t::ga
uint8_t ga
Definition: boost.h:96
boost_t::spi
spi_master_t spi
Definition: boost.h:116
boost_cfg_t::spi_speed
uint32_t spi_speed
Definition: boost.h:145
boost_t::en
digital_out_t en
Definition: boost.h:110
boost_t::chip_select1
pin_name_t chip_select1
Definition: boost.h:117
boost_cfg_t::miso
pin_name_t miso
Definition: boost.h:133
boost_t::dac
boost_dac_cfg_t dac
Definition: boost.h:122
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:94
boost_cfg_t::en
pin_name_t en
Definition: boost.h:141
boost_t::cs2
digital_out_t cs2
Definition: boost.h:109
boost_cfg_t::cs2_polarity
spi_master_chip_select_polarity_t cs2_polarity
Definition: boost.h:148
boost_device_disable
void boost_device_disable(boost_t *ctx)
Device Disable function.
boost_cfg_t::sck
pin_name_t sck
Definition: boost.h:135
boost_cfg_t::cs2
pin_name_t cs2
Definition: boost.h:137
boost_cfg_t
Click configuration structure definition.
Definition: boost.h:130
boost_t
Click ctx object definition.
Definition: boost.h:105
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:97
boost_cfg_t::cs1
pin_name_t cs1
Definition: boost.h:136
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:134
boost_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: boost.h:146
boost_t::cs2_polarity
spi_master_chip_select_polarity_t cs2_polarity
Definition: boost.h:120
boost_dac_setup
void boost_dac_setup(boost_t *ctx, boost_dac_cfg_t *cfg)
DAC Setup function.