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 )
65#define BOOST4_RETVAL uint8_t
66
67#define BOOST4_OK 0x00
68#define BOOST4_INIT_ERROR 0xFF
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 // End group macro
92// --------------------------------------------------------------- PUBLIC TYPES
101typedef 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
118typedef 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
139 // End types group
141
142// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
143
148#ifdef __cplusplus
149extern "C"{
150#endif
151
162
172
181void boost4_enable ( boost4_t *ctx, uint8_t state );
182
192void 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
#define BOOST4_RETVAL
Definition: boost4.h:65
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:119
spi_master_chip_select_polarity_t cs_polarity
Definition: boost4.h:136
pin_name_t sck
Definition: boost4.h:124
spi_master_mode_t spi_mode
Definition: boost4.h:135
pin_name_t mosi
Definition: boost4.h:123
uint32_t spi_speed
Definition: boost4.h:134
pin_name_t en
Definition: boost4.h:129
pin_name_t miso
Definition: boost4.h:122
pin_name_t cs
Definition: boost4.h:125
Click ctx object definition.
Definition: boost4.h:102
digital_out_t cs
Definition: boost4.h:106
spi_master_t spi
Definition: boost4.h:110
digital_out_t en
Definition: boost4.h:105
pin_name_t chip_select
Definition: boost4.h:111