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 "drv_digital_out.h"
39 #include "drv_spi_master.h"
40 
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
53 #define BOOST4_MAP_MIKROBUS( cfg, mikrobus ) \
54  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
55  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
56  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
57  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
58  cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST )
59 
65 #define BOOST4_RETVAL uint8_t
66 
67 #define BOOST4_OK 0x00
68 #define BOOST4_INIT_ERROR 0xFF
69 
75 #define BOOST4_START_CMD 0x70
76 
77 #define BOOST4_VOUT_MIN 1500
78 #define BOOST4_VOUT_2_5 1330
79 #define BOOST4_VOUT_3 1085
80 #define BOOST4_VOUT_3_5 840
81 #define BOOST4_VOUT_4 595
82 #define BOOST4_VOUT_4_5 350
83 #define BOOST4_VOUT_5 105
84 #define BOOST4_VOUT_MAX 0
85 
86 #define BOOST4_12_BIT 0x0FFF
87 #define BOOST4_ENABLE 1
88 #define BOOST4_DISABLE 0
89  // End group macro
92 // --------------------------------------------------------------- PUBLIC TYPES
101 typedef struct
102 {
103  // Output pins
104 
105  digital_out_t en;
106  digital_out_t cs;
107 
108  // Modules
109 
110  spi_master_t spi;
111  pin_name_t chip_select;
112 
113 } boost4_t;
114 
118 typedef struct
119 {
120  // Communication gpio pins
121 
122  pin_name_t miso;
123  pin_name_t mosi;
124  pin_name_t sck;
125  pin_name_t cs;
126 
127  // Additional gpio pins
128 
129  pin_name_t en;
130 
131 
132  // static variable
133 
134  uint32_t spi_speed;
135  spi_master_mode_t spi_mode;
136  spi_master_chip_select_polarity_t cs_polarity;
137 
138 } boost4_cfg_t;
139  // End types group
141 
142 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
143 
148 #ifdef __cplusplus
149 extern "C"{
150 #endif
151 
162 
172 
181 void boost4_enable ( boost4_t *ctx, uint8_t state );
182 
192 void boost4_set_out_voltage ( boost4_t *ctx, uint16_t value );
193 
194 #ifdef __cplusplus
195 }
196 #endif
197 #endif // _BOOST4_H_
198  // End public_function group
201 
202 // ------------------------------------------------------------------------- END
boost4_cfg_t::cs
pin_name_t cs
Definition: boost4.h:125
boost4_t::spi
spi_master_t spi
Definition: boost4.h:110
boost4_t::chip_select
pin_name_t chip_select
Definition: boost4.h:111
boost4_t::cs
digital_out_t cs
Definition: boost4.h:106
boost4_cfg_t::spi_speed
uint32_t spi_speed
Definition: boost4.h:134
BOOST4_RETVAL
#define BOOST4_RETVAL
Definition: boost4.h:65
boost4_cfg_t
Click configuration structure definition.
Definition: boost4.h:119
boost4_t
Click ctx object definition.
Definition: boost4.h:102
boost4_cfg_t::mosi
pin_name_t mosi
Definition: boost4.h:123
boost4_cfg_t::sck
pin_name_t sck
Definition: boost4.h:124
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:129
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:105
boost4_cfg_t::miso
pin_name_t miso
Definition: boost4.h:122
boost4_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: boost4.h:135
boost4_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: boost4.h:136