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 "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_spi_master.h"
41 
42 
43 // -------------------------------------------------------------- PUBLIC MACROS
54 #define BOOSTONV2_MAP_MIKROBUS( cfg, mikrobus ) \
55  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
56  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
57  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
58  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
59  cfg.en = MIKROBUS( mikrobus, MIKROBUS_AN ); \
60  cfg.csn = MIKROBUS( mikrobus, MIKROBUS_RST ); \
61  cfg.psm = MIKROBUS( mikrobus, MIKROBUS_PWM );
62 
68 #define BOOSTONV2_RETVAL uint8_t
69 
70 #define BOOSTONV2_OK 0x00
71 #define BOOSTONV2_INIT_ERROR 0xFF
72 
77 #define BOOSTINV2_POS_VOUT_5V 0x7FFF
78 #define BOOSTINV2_POS_VOUT_6V 0x7B00
79 #define BOOSTINV2_POS_VOUT_7V 0x7A20
80 #define BOOSTINV2_POS_VOUT_8V 0x7950
81 #define BOOSTINV2_POS_VOUT_9V 0x7870
82 #define BOOSTINV2_POS_VOUT_10V 0x7790
83 #define BOOSTINV2_POS_VOUT_11V 0x76B0
84 #define BOOSTINV2_POS_VOUT_12V 0x75E0
85 #define BOOSTINV2_POS_VOUT_13V 0x7500
86 #define BOOSTINV2_POS_VOUT_14V 0x7420
87 #define BOOSTINV2_POS_VOUT_15V 0x7340
88 
94 #define BOOSTINV2_NEG_VOUT_5V 0x79A2
95 #define BOOSTINV2_NEG_VOUT_6V 0x7900
96 #define BOOSTINV2_NEG_VOUT_7V 0x786A
97 #define BOOSTINV2_NEG_VOUT_8V 0x77D0
98 #define BOOSTINV2_NEG_VOUT_9V 0x7744
99 #define BOOSTINV2_NEG_VOUT_10V 0x76B0
100 #define BOOSTINV2_NEG_VOUT_11V 0x7630
101 #define BOOSTINV2_NEG_VOUT_12V 0x75B2
102 #define BOOSTINV2_NEG_VOUT_13V 0x7530
103 #define BOOSTINV2_NEG_VOUT_14V 0x74B0
104 #define BOOSTINV2_NEG_VOUT_15V 0x7474
105  // End group macro
108 // --------------------------------------------------------------- PUBLIC TYPES
117 typedef struct
118 {
119  // Output pins
120 
121  digital_out_t en;
122  digital_out_t csn;
123  digital_out_t psm;
124  digital_out_t cs;
125 
126  // Modules
127 
128  spi_master_t spi;
129  pin_name_t chip_select;
130 
131 } boostinv2_t;
132 
136 typedef struct
137 {
138  // Communication gpio pins
139 
140  pin_name_t miso;
141  pin_name_t mosi;
142  pin_name_t sck;
143  pin_name_t cs;
144 
145  // Additional gpio pins
146 
147  pin_name_t en;
148  pin_name_t csn;
149  pin_name_t psm;
150 
151  // static variable
152 
153  uint32_t spi_speed;
154  uint8_t spi_mode;
155  spi_master_chip_select_polarity_t cs_polarity;
156 
158  // End types group
160 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
161 
166 #ifdef __cplusplus
167 extern "C"{
168 #endif
169 
179 
188 
196 void boostinv2_default_cfg ( boostinv2_t *ctx );
197 
210 (
211  boostinv2_t *ctx,
212  uint8_t *wr_buf,
213  uint16_t wr_len,
214  uint8_t *rd_buf,
215  uint16_t rd_len
216 );
217 
225 void boostinv2_enable ( boostinv2_t *ctx );
226 
235 void boostinv2_set_positive_voltage ( boostinv2_t *ctx, uint16_t voltage );
236 
245 void boostinv2_set_negative_voltage ( boostinv2_t *ctx, uint16_t voltage );
246 
255 void boostinv2_set_psn ( boostinv2_t *ctx, uint8_t state );
256 
257 #ifdef __cplusplus
258 }
259 #endif
260 #endif // _BOOSTONV2_H_
261 
262  // End public_function group
265 
266 // ------------------------------------------------------------------------- END
boostinv2_t::psm
digital_out_t psm
Definition: boostinv2.h:123
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:147
boostinv2_t::spi
spi_master_t spi
Definition: boostinv2.h:128
boostinv2_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: boostinv2.h:155
boostinv2_cfg_t::spi_speed
uint32_t spi_speed
Definition: boostinv2.h:153
boostinv2_cfg_t::psm
pin_name_t psm
Definition: boostinv2.h:149
boostinv2_cfg_t::cs
pin_name_t cs
Definition: boostinv2.h:143
boostinv2_cfg_t::spi_mode
uint8_t spi_mode
Definition: boostinv2.h:154
boostinv2_t::en
digital_out_t en
Definition: boostinv2.h:121
boostinv2_t::cs
digital_out_t cs
Definition: boostinv2.h:124
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:140
boostinv2_cfg_t::sck
pin_name_t sck
Definition: boostinv2.h:142
boostinv2_init
BOOSTONV2_RETVAL boostinv2_init(boostinv2_t *ctx, boostinv2_cfg_t *cfg)
Initialization function.
BOOSTONV2_RETVAL
#define BOOSTONV2_RETVAL
Definition: boostinv2.h:68
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:117
boostinv2_cfg_t::mosi
pin_name_t mosi
Definition: boostinv2.h:141
boostinv2_t::chip_select
pin_name_t chip_select
Definition: boostinv2.h:129
boostinv2_cfg_t
Click configuration structure definition.
Definition: boostinv2.h:136
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:148
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:122