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
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_spi_master.h"
54
55
56// -------------------------------------------------------------- PUBLIC MACROS
67#define BOOST4_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
69 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
70 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
71 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
72 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST )
79#define BOOST4_RETVAL uint8_t
80
81#define BOOST4_OK 0x00
82#define BOOST4_INIT_ERROR 0xFF
89#define BOOST4_START_CMD 0x70
90
91#define BOOST4_VOUT_MIN 1500
92#define BOOST4_VOUT_2_5 1330
93#define BOOST4_VOUT_3 1085
94#define BOOST4_VOUT_3_5 840
95#define BOOST4_VOUT_4 595
96#define BOOST4_VOUT_4_5 350
97#define BOOST4_VOUT_5 105
98#define BOOST4_VOUT_MAX 0
99
100#define BOOST4_12_BIT 0x0FFF
101#define BOOST4_ENABLE 1
102#define BOOST4_DISABLE 0
105 // End group macro
106// --------------------------------------------------------------- PUBLIC TYPES
115typedef struct
116{
117 // Output pins
118
119 digital_out_t en;
120 digital_out_t cs;
121
122 // Modules
123
124 spi_master_t spi;
125 pin_name_t chip_select;
126
127} boost4_t;
128
132typedef struct
133{
134 // Communication gpio pins
135
136 pin_name_t miso;
137 pin_name_t mosi;
138 pin_name_t sck;
139 pin_name_t cs;
140
141 // Additional gpio pins
142
143 pin_name_t en;
144
145
146 // static variable
147
148 uint32_t spi_speed;
149 spi_master_mode_t spi_mode;
150 spi_master_chip_select_polarity_t cs_polarity;
151
153
154 // End types group
155
156// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
157
162#ifdef __cplusplus
163extern "C"{
164#endif
165
176
186
195void boost4_enable ( boost4_t *ctx, uint8_t state );
196
206void boost4_set_out_voltage ( boost4_t *ctx, uint16_t value );
207
208#ifdef __cplusplus
209}
210#endif
211#endif // _BOOST4_H_
212
213 // End public_function group
215
216// ------------------------------------------------------------------------- END
#define BOOST4_RETVAL
Definition boost4.h:79
void boost4_set_out_voltage(boost4_t *ctx, uint16_t value)
Set output voltage function.
BOOST4_RETVAL boost4_init(boost4_t *ctx, boost4_cfg_t *cfg)
Initialization function.
void boost4_cfg_setup(boost4_cfg_t *cfg)
Config Object Initialization function.
void boost4_enable(boost4_t *ctx, uint8_t state)
Enable device function.
Click configuration structure definition.
Definition boost4.h:133
spi_master_chip_select_polarity_t cs_polarity
Definition boost4.h:150
pin_name_t sck
Definition boost4.h:138
spi_master_mode_t spi_mode
Definition boost4.h:149
pin_name_t mosi
Definition boost4.h:137
uint32_t spi_speed
Definition boost4.h:148
pin_name_t en
Definition boost4.h:143
pin_name_t miso
Definition boost4.h:136
pin_name_t cs
Definition boost4.h:139
Click ctx object definition.
Definition boost4.h:116
digital_out_t cs
Definition boost4.h:120
spi_master_t spi
Definition boost4.h:124
digital_out_t en
Definition boost4.h:119
pin_name_t chip_select
Definition boost4.h:125