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
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
66#define BOOST_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
68 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
69 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
70 cfg.cs1 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
71 cfg.cs2 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
72 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST )
79#define BOOST_OK 0
80#define BOOST_ERROR (-1)
87#define BOOST_CFG_VREF_BUFFERED 1
88#define BOOST_CFG_VREF_UNBUFFERED 0
89
90#define BOOST_CFG_GAIN_1X 1
91#define BOOST_CFG_GAIN_2X 0
92
93#define BOOST_CFG_POWER_OUT_ON 1
94#define BOOST_CFG_POWER_OUT_OFF 0
97 // End group macro
98// --------------------------------------------------------------- PUBLIC TYPES
107typedef struct
108{
109 uint8_t buf;
110 uint8_t ga;
111 uint8_t shdn;
112
114
118typedef struct
119{
120 // Output pins
121
122 digital_out_t cs1;
123 digital_out_t cs2;
124 digital_out_t en;
125
126 digital_in_t miso;
127
128 // Modules
129
130 spi_master_t spi;
131 pin_name_t chip_select1;
132 pin_name_t chip_select2;
133 spi_master_chip_select_polarity_t cs1_polarity;
134 spi_master_chip_select_polarity_t cs2_polarity;
135
137
138} boost_t;
139
143typedef struct
144{
145 // Communication gpio pins
146
147 pin_name_t miso;
148 pin_name_t mosi;
149 pin_name_t sck;
150 pin_name_t cs1;
151 pin_name_t cs2;
152
153 // Additional gpio pins
154
155 pin_name_t en;
156
157 // Static variable
158
159 uint32_t spi_speed;
160 spi_master_mode_t spi_mode;
161 spi_master_chip_select_polarity_t cs1_polarity;
162 spi_master_chip_select_polarity_t cs2_polarity;
163
165
167
168 // End types group
169// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
175#ifdef __cplusplus
176extern "C"{
177#endif
178
188
199err_t boost_init ( boost_t *ctx, boost_cfg_t *cfg );
200
209
218
228
240err_t boost_dac_write ( boost_t *ctx, uint16_t dac_val );
241
251
252#ifdef __cplusplus
253}
254#endif
255#endif // BOOST_H
256
257 // End public_function group
258 // End click Driver group
259
260// ------------------------------------------------------------------------ END
void boost_dac_setup(boost_t *ctx, boost_dac_cfg_t *cfg)
DAC Setup function.
float boost_vout_read(boost_t *ctx)
VOUT Read function.
void boost_device_enable(boost_t *ctx)
Device Enable function.
void boost_device_disable(boost_t *ctx)
Device Disable function.
void boost_cfg_setup(boost_cfg_t *cfg)
Config Object Initialization function.
err_t boost_dac_write(boost_t *ctx, uint16_t dac_val)
DAC Write function.
err_t boost_init(boost_t *ctx, boost_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition boost.h:144
pin_name_t cs1
Definition boost.h:150
pin_name_t cs2
Definition boost.h:151
spi_master_chip_select_polarity_t cs1_polarity
Definition boost.h:161
boost_dac_cfg_t dac
Definition boost.h:164
pin_name_t sck
Definition boost.h:149
spi_master_mode_t spi_mode
Definition boost.h:160
pin_name_t mosi
Definition boost.h:148
uint32_t spi_speed
Definition boost.h:159
pin_name_t en
Definition boost.h:155
pin_name_t miso
Definition boost.h:147
spi_master_chip_select_polarity_t cs2_polarity
Definition boost.h:162
Click DAC configuration structure definition.
Definition boost.h:108
uint8_t buf
Definition boost.h:109
uint8_t shdn
Definition boost.h:111
uint8_t ga
Definition boost.h:110
Click ctx object definition.
Definition boost.h:119
spi_master_t spi
Definition boost.h:130
spi_master_chip_select_polarity_t cs1_polarity
Definition boost.h:133
digital_in_t miso
Definition boost.h:126
boost_dac_cfg_t dac
Definition boost.h:136
pin_name_t chip_select2
Definition boost.h:132
digital_out_t cs1
Definition boost.h:122
digital_out_t en
Definition boost.h:124
digital_out_t cs2
Definition boost.h:123
pin_name_t chip_select1
Definition boost.h:131
spi_master_chip_select_polarity_t cs2_polarity
Definition boost.h:134