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 
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 
57 // -------------------------------------------------------------- PUBLIC MACROS
68 #define BOOSTONV2_MAP_MIKROBUS( cfg, mikrobus ) \
69  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
70  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
71  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
72  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
73  cfg.en = MIKROBUS( mikrobus, MIKROBUS_AN ); \
74  cfg.csn = MIKROBUS( mikrobus, MIKROBUS_RST ); \
75  cfg.psm = MIKROBUS( mikrobus, MIKROBUS_PWM );
76 
82 #define BOOSTONV2_RETVAL uint8_t
83 
84 #define BOOSTONV2_OK 0x00
85 #define BOOSTONV2_INIT_ERROR 0xFF
86 
91 #define BOOSTINV2_POS_VOUT_5V 0x7FFF
92 #define BOOSTINV2_POS_VOUT_6V 0x7B00
93 #define BOOSTINV2_POS_VOUT_7V 0x7A20
94 #define BOOSTINV2_POS_VOUT_8V 0x7950
95 #define BOOSTINV2_POS_VOUT_9V 0x7870
96 #define BOOSTINV2_POS_VOUT_10V 0x7790
97 #define BOOSTINV2_POS_VOUT_11V 0x76B0
98 #define BOOSTINV2_POS_VOUT_12V 0x75E0
99 #define BOOSTINV2_POS_VOUT_13V 0x7500
100 #define BOOSTINV2_POS_VOUT_14V 0x7420
101 #define BOOSTINV2_POS_VOUT_15V 0x7340
102 
108 #define BOOSTINV2_NEG_VOUT_5V 0x79A2
109 #define BOOSTINV2_NEG_VOUT_6V 0x7900
110 #define BOOSTINV2_NEG_VOUT_7V 0x786A
111 #define BOOSTINV2_NEG_VOUT_8V 0x77D0
112 #define BOOSTINV2_NEG_VOUT_9V 0x7744
113 #define BOOSTINV2_NEG_VOUT_10V 0x76B0
114 #define BOOSTINV2_NEG_VOUT_11V 0x7630
115 #define BOOSTINV2_NEG_VOUT_12V 0x75B2
116 #define BOOSTINV2_NEG_VOUT_13V 0x7530
117 #define BOOSTINV2_NEG_VOUT_14V 0x74B0
118 #define BOOSTINV2_NEG_VOUT_15V 0x7474
119  // End group macro
122 // --------------------------------------------------------------- PUBLIC TYPES
131 typedef struct
132 {
133  // Output pins
134 
135  digital_out_t en;
136  digital_out_t csn;
137  digital_out_t psm;
138  digital_out_t cs;
139 
140  // Modules
141 
142  spi_master_t spi;
143  pin_name_t chip_select;
144 
145 } boostinv2_t;
146 
150 typedef struct
151 {
152  // Communication gpio pins
153 
154  pin_name_t miso;
155  pin_name_t mosi;
156  pin_name_t sck;
157  pin_name_t cs;
158 
159  // Additional gpio pins
160 
161  pin_name_t en;
162  pin_name_t csn;
163  pin_name_t psm;
164 
165  // static variable
166 
167  uint32_t spi_speed;
168  uint8_t spi_mode;
169  spi_master_chip_select_polarity_t cs_polarity;
170 
172  // End types group
174 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
175 
180 #ifdef __cplusplus
181 extern "C"{
182 #endif
183 
193 
202 
211 
224 (
225  boostinv2_t *ctx,
226  uint8_t *wr_buf,
227  uint16_t wr_len,
228  uint8_t *rd_buf,
229  uint16_t rd_len
230 );
231 
240 
249 void boostinv2_set_positive_voltage ( boostinv2_t *ctx, uint16_t voltage );
250 
259 void boostinv2_set_negative_voltage ( boostinv2_t *ctx, uint16_t voltage );
260 
269 void boostinv2_set_psn ( boostinv2_t *ctx, uint8_t state );
270 
271 #ifdef __cplusplus
272 }
273 #endif
274 #endif // _BOOSTONV2_H_
275 
276  // End public_function group
279 
280 // ------------------------------------------------------------------------- END
boostinv2_t::psm
digital_out_t psm
Definition: boostinv2.h:137
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:161
boostinv2_t::spi
spi_master_t spi
Definition: boostinv2.h:142
boostinv2_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: boostinv2.h:169
boostinv2_cfg_t::spi_speed
uint32_t spi_speed
Definition: boostinv2.h:167
boostinv2_cfg_t::psm
pin_name_t psm
Definition: boostinv2.h:163
boostinv2_cfg_t::cs
pin_name_t cs
Definition: boostinv2.h:157
boostinv2_cfg_t::spi_mode
uint8_t spi_mode
Definition: boostinv2.h:168
boostinv2_t::en
digital_out_t en
Definition: boostinv2.h:135
boostinv2_t::cs
digital_out_t cs
Definition: boostinv2.h:138
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:154
boostinv2_cfg_t::sck
pin_name_t sck
Definition: boostinv2.h:156
boostinv2_init
BOOSTONV2_RETVAL boostinv2_init(boostinv2_t *ctx, boostinv2_cfg_t *cfg)
Initialization function.
BOOSTONV2_RETVAL
#define BOOSTONV2_RETVAL
Definition: boostinv2.h:82
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:132
boostinv2_cfg_t::mosi
pin_name_t mosi
Definition: boostinv2.h:155
boostinv2_t::chip_select
pin_name_t chip_select
Definition: boostinv2.h:143
boostinv2_cfg_t
Click configuration structure definition.
Definition: boostinv2.h:151
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:162
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:136