boost4  2.0.0.0
boost4.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 BOOST4_H
36 #define BOOST4_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_spi_master.h"
50 
51 
52 // -------------------------------------------------------------- PUBLIC MACROS
63 #define BOOST4_MAP_MIKROBUS( cfg, mikrobus ) \
64  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
65  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
66  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
67  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
68  cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST )
69 
75 #define BOOST4_RETVAL uint8_t
76 
77 #define BOOST4_OK 0x00
78 #define BOOST4_INIT_ERROR 0xFF
79 
85 #define BOOST4_START_CMD 0x70
86 
87 #define BOOST4_VOUT_MIN 1500
88 #define BOOST4_VOUT_2_5 1330
89 #define BOOST4_VOUT_3 1085
90 #define BOOST4_VOUT_3_5 840
91 #define BOOST4_VOUT_4 595
92 #define BOOST4_VOUT_4_5 350
93 #define BOOST4_VOUT_5 105
94 #define BOOST4_VOUT_MAX 0
95 
96 #define BOOST4_12_BIT 0x0FFF
97 #define BOOST4_ENABLE 1
98 #define BOOST4_DISABLE 0
99  // End group macro
102 // --------------------------------------------------------------- PUBLIC TYPES
111 typedef struct
112 {
113  // Output pins
114 
115  digital_out_t en;
116  digital_out_t cs;
117 
118  // Modules
119 
120  spi_master_t spi;
121  pin_name_t chip_select;
122 
123 } boost4_t;
124 
128 typedef struct
129 {
130  // Communication gpio pins
131 
132  pin_name_t miso;
133  pin_name_t mosi;
134  pin_name_t sck;
135  pin_name_t cs;
136 
137  // Additional gpio pins
138 
139  pin_name_t en;
140 
141 
142  // static variable
143 
144  uint32_t spi_speed;
145  spi_master_mode_t spi_mode;
146  spi_master_chip_select_polarity_t cs_polarity;
147 
148 } boost4_cfg_t;
149  // End types group
151 
152 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
153 
158 #ifdef __cplusplus
159 extern "C"{
160 #endif
161 
172 
182 
191 void boost4_enable ( boost4_t *ctx, uint8_t state );
192 
202 void boost4_set_out_voltage ( boost4_t *ctx, uint16_t value );
203 
204 #ifdef __cplusplus
205 }
206 #endif
207 #endif // _BOOST4_H_
208  // End public_function group
211 
212 // ------------------------------------------------------------------------- END
boost4_cfg_t::cs
pin_name_t cs
Definition: boost4.h:135
boost4_t::spi
spi_master_t spi
Definition: boost4.h:120
boost4_t::chip_select
pin_name_t chip_select
Definition: boost4.h:121
boost4_t::cs
digital_out_t cs
Definition: boost4.h:116
boost4_cfg_t::spi_speed
uint32_t spi_speed
Definition: boost4.h:144
BOOST4_RETVAL
#define BOOST4_RETVAL
Definition: boost4.h:75
boost4_cfg_t
Click configuration structure definition.
Definition: boost4.h:129
boost4_t
Click ctx object definition.
Definition: boost4.h:112
boost4_cfg_t::mosi
pin_name_t mosi
Definition: boost4.h:133
boost4_cfg_t::sck
pin_name_t sck
Definition: boost4.h:134
boost4_set_out_voltage
void boost4_set_out_voltage(boost4_t *ctx, uint16_t value)
Set output voltage function.
boost4_cfg_setup
void boost4_cfg_setup(boost4_cfg_t *cfg)
Config Object Initialization function.
boost4_enable
void boost4_enable(boost4_t *ctx, uint8_t state)
Enable device function.
boost4_cfg_t::en
pin_name_t en
Definition: boost4.h:139
boost4_init
BOOST4_RETVAL boost4_init(boost4_t *ctx, boost4_cfg_t *cfg)
Initialization function.
boost4_t::en
digital_out_t en
Definition: boost4.h:115
boost4_cfg_t::miso
pin_name_t miso
Definition: boost4.h:132
boost4_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: boost4.h:145
boost4_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: boost4.h:146