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_MAX 0x0000
78 #define BOOST4_VOUT_MIN 0x0FFF
79 #define BOOST4_VOUT_4 0x0740
80 #define BOOST4_VOUT_4_5 0x041F
81 #define BOOST4_12_BIT 0x0FFF
82 #define BOOST4_ENABLE 1
83 #define BOOST4_DISABLE 0
84  // End group macro
87 // --------------------------------------------------------------- PUBLIC TYPES
96 typedef struct
97 {
98  // Output pins
99 
100  digital_out_t en;
101  digital_out_t cs;
102 
103  // Modules
104 
105  spi_master_t spi;
106  pin_name_t chip_select;
107 
108 } boost4_t;
109 
113 typedef struct
114 {
115  // Communication gpio pins
116 
117  pin_name_t miso;
118  pin_name_t mosi;
119  pin_name_t sck;
120  pin_name_t cs;
121 
122  // Additional gpio pins
123 
124  pin_name_t en;
125 
126 
127  // static variable
128 
129  uint32_t spi_speed;
130  spi_master_mode_t spi_mode;
131  spi_master_chip_select_polarity_t cs_polarity;
132 
133 } boost4_cfg_t;
134  // End types group
136 
137 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
138 
143 #ifdef __cplusplus
144 extern "C"{
145 #endif
146 
157 
167 
176 void boost4_enable ( boost4_t *ctx, uint8_t state );
177 
187 void boost4_set_out_voltage ( boost4_t *ctx, uint16_t value );
188 
189 #ifdef __cplusplus
190 }
191 #endif
192 #endif // _BOOST4_H_
193  // End public_function group
196 
197 // ------------------------------------------------------------------------- END
boost4_cfg_t::cs
pin_name_t cs
Definition: boost4.h:120
boost4_t::spi
spi_master_t spi
Definition: boost4.h:105
boost4_t::chip_select
pin_name_t chip_select
Definition: boost4.h:106
boost4_t::cs
digital_out_t cs
Definition: boost4.h:101
boost4_cfg_t::spi_speed
uint32_t spi_speed
Definition: boost4.h:129
BOOST4_RETVAL
#define BOOST4_RETVAL
Definition: boost4.h:65
boost4_cfg_t
Click configuration structure definition.
Definition: boost4.h:114
boost4_t
Click ctx object definition.
Definition: boost4.h:97
boost4_cfg_t::mosi
pin_name_t mosi
Definition: boost4.h:118
boost4_cfg_t::sck
pin_name_t sck
Definition: boost4.h:119
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:124
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:100
boost4_cfg_t::miso
pin_name_t miso
Definition: boost4.h:117
boost4_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: boost4.h:130
boost4_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: boost4.h:131