boostinv2  2.0.0.0
boostinv2.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 BOOSTONV2_H
36 #define BOOSTONV2_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 
53 // -------------------------------------------------------------- PUBLIC MACROS
64 #define BOOSTONV2_MAP_MIKROBUS( cfg, mikrobus ) \
65  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
66  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
67  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
68  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
69  cfg.en = MIKROBUS( mikrobus, MIKROBUS_AN ); \
70  cfg.csn = MIKROBUS( mikrobus, MIKROBUS_RST ); \
71  cfg.psm = MIKROBUS( mikrobus, MIKROBUS_PWM );
72 
78 #define BOOSTONV2_RETVAL uint8_t
79 
80 #define BOOSTONV2_OK 0x00
81 #define BOOSTONV2_INIT_ERROR 0xFF
82 
87 #define BOOSTINV2_POS_VOUT_5V 0x7FFF
88 #define BOOSTINV2_POS_VOUT_6V 0x7B00
89 #define BOOSTINV2_POS_VOUT_7V 0x7A20
90 #define BOOSTINV2_POS_VOUT_8V 0x7950
91 #define BOOSTINV2_POS_VOUT_9V 0x7870
92 #define BOOSTINV2_POS_VOUT_10V 0x7790
93 #define BOOSTINV2_POS_VOUT_11V 0x76B0
94 #define BOOSTINV2_POS_VOUT_12V 0x75E0
95 #define BOOSTINV2_POS_VOUT_13V 0x7500
96 #define BOOSTINV2_POS_VOUT_14V 0x7420
97 #define BOOSTINV2_POS_VOUT_15V 0x7340
98 
104 #define BOOSTINV2_NEG_VOUT_5V 0x79A2
105 #define BOOSTINV2_NEG_VOUT_6V 0x7900
106 #define BOOSTINV2_NEG_VOUT_7V 0x786A
107 #define BOOSTINV2_NEG_VOUT_8V 0x77D0
108 #define BOOSTINV2_NEG_VOUT_9V 0x7744
109 #define BOOSTINV2_NEG_VOUT_10V 0x76B0
110 #define BOOSTINV2_NEG_VOUT_11V 0x7630
111 #define BOOSTINV2_NEG_VOUT_12V 0x75B2
112 #define BOOSTINV2_NEG_VOUT_13V 0x7530
113 #define BOOSTINV2_NEG_VOUT_14V 0x74B0
114 #define BOOSTINV2_NEG_VOUT_15V 0x7474
115  // End group macro
118 // --------------------------------------------------------------- PUBLIC TYPES
127 typedef struct
128 {
129  // Output pins
130 
131  digital_out_t en;
132  digital_out_t csn;
133  digital_out_t psm;
134  digital_out_t cs;
135 
136  // Modules
137 
138  spi_master_t spi;
139  pin_name_t chip_select;
140 
141 } boostinv2_t;
142 
146 typedef struct
147 {
148  // Communication gpio pins
149 
150  pin_name_t miso;
151  pin_name_t mosi;
152  pin_name_t sck;
153  pin_name_t cs;
154 
155  // Additional gpio pins
156 
157  pin_name_t en;
158  pin_name_t csn;
159  pin_name_t psm;
160 
161  // static variable
162 
163  uint32_t spi_speed;
164  uint8_t spi_mode;
165  spi_master_chip_select_polarity_t cs_polarity;
166 
168  // End types group
170 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
171 
176 #ifdef __cplusplus
177 extern "C"{
178 #endif
179 
189 
198 
207 
220 (
221  boostinv2_t *ctx,
222  uint8_t *wr_buf,
223  uint16_t wr_len,
224  uint8_t *rd_buf,
225  uint16_t rd_len
226 );
227 
236 
245 void boostinv2_set_positive_voltage ( boostinv2_t *ctx, uint16_t voltage );
246 
255 void boostinv2_set_negative_voltage ( boostinv2_t *ctx, uint16_t voltage );
256 
265 void boostinv2_set_psn ( boostinv2_t *ctx, uint8_t state );
266 
267 #ifdef __cplusplus
268 }
269 #endif
270 #endif // _BOOSTONV2_H_
271 
272  // End public_function group
275 
276 // ------------------------------------------------------------------------- END
boostinv2_t::psm
digital_out_t psm
Definition: boostinv2.h:133
boostinv2_default_cfg
void boostinv2_default_cfg(boostinv2_t *ctx)
Click Default Configuration function.
boostinv2_cfg_t::en
pin_name_t en
Definition: boostinv2.h:157
boostinv2_t::spi
spi_master_t spi
Definition: boostinv2.h:138
boostinv2_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: boostinv2.h:165
boostinv2_cfg_t::spi_speed
uint32_t spi_speed
Definition: boostinv2.h:163
boostinv2_cfg_t::psm
pin_name_t psm
Definition: boostinv2.h:159
boostinv2_cfg_t::cs
pin_name_t cs
Definition: boostinv2.h:153
boostinv2_cfg_t::spi_mode
uint8_t spi_mode
Definition: boostinv2.h:164
boostinv2_t::en
digital_out_t en
Definition: boostinv2.h:131
boostinv2_t::cs
digital_out_t cs
Definition: boostinv2.h:134
boostinv2_enable
void boostinv2_enable(boostinv2_t *ctx)
Enable analog pin.
boostinv2_cfg_setup
void boostinv2_cfg_setup(boostinv2_cfg_t *cfg)
Config Object Initialization function.
boostinv2_generic_transfer
void boostinv2_generic_transfer(boostinv2_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
boostinv2_cfg_t::miso
pin_name_t miso
Definition: boostinv2.h:150
boostinv2_cfg_t::sck
pin_name_t sck
Definition: boostinv2.h:152
boostinv2_init
BOOSTONV2_RETVAL boostinv2_init(boostinv2_t *ctx, boostinv2_cfg_t *cfg)
Initialization function.
BOOSTONV2_RETVAL
#define BOOSTONV2_RETVAL
Definition: boostinv2.h:78
boostinv2_set_psn
void boostinv2_set_psn(boostinv2_t *ctx, uint8_t state)
Sets PSN depending on input state.
boostinv2_t
Click ctx object definition.
Definition: boostinv2.h:128
boostinv2_cfg_t::mosi
pin_name_t mosi
Definition: boostinv2.h:151
boostinv2_t::chip_select
pin_name_t chip_select
Definition: boostinv2.h:139
boostinv2_cfg_t
Click configuration structure definition.
Definition: boostinv2.h:147
boostinv2_set_negative_voltage
void boostinv2_set_negative_voltage(boostinv2_t *ctx, uint16_t voltage)
Sets negative voltage.
boostinv2_cfg_t::csn
pin_name_t csn
Definition: boostinv2.h:158
boostinv2_set_positive_voltage
void boostinv2_set_positive_voltage(boostinv2_t *ctx, uint16_t voltage)
Sets postive voltage.
boostinv2_t::csn
digital_out_t csn
Definition: boostinv2.h:132