buck16 2.0.0.0
buck16.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef BUCK16_H
29#define BUCK16_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_spi_master.h"
38#include "spi_specifics.h"
39
60#define BUCK16_CMD_VOLATILE_WIPER_0 0x00
61#define BUCK16_CMD_NV_WIPER_0 0x20
62#define BUCK16_CMD_VOLATILE_TCON 0x40
63#define BUCK16_CMD_DATA_EEPROM_1 0x60
64#define BUCK16_CMD_DATA_EEPROM_2 0x70
65#define BUCK16_CMD_DATA_EEPROM_3 0x80
66#define BUCK16_CMD_DATA_EEPROM_4 0x90
67#define BUCK16_CMD_DATA_EEPROM_5 0xA0
68#define BUCK16_CMD_DATA_EEPROM_6 0xB0
69#define BUCK16_CMD_DATA_EEPROM_7 0xC0
70#define BUCK16_CMD_DATA_EEPROM_8 0xD0
71#define BUCK16_CMD_DATA_EEPROM_9 0xE0
72#define BUCK16_CMD_DATA_EEPROM_10 0xF0
73
78#define BUCK16_WRITE 0x00
79#define BUCK16_INCREMENT 0x04
80#define BUCK16_DECREMENT 0x08
81 // buck16_reg
83
102#define BUCK16_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
103#define BUCK16_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
104 // buck16_set
106
121#define BUCK16_MAP_MIKROBUS( cfg, mikrobus ) \
122 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
123 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
124 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
125 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
126 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST );
127 // buck16_map // buck16
130
135typedef struct
136{
137 // Output pins
138 digital_out_t rst;
140 // Modules
141 spi_master_t spi;
142 pin_name_t chip_select;
144} buck16_t;
145
150typedef struct
151{
152 // Communication gpio pins
153 pin_name_t miso;
154 pin_name_t mosi;
155 pin_name_t sck;
156 pin_name_t cs;
158 // Additional gpio pins
159 pin_name_t rst;
161 // static variable
162 uint32_t spi_speed;
163 spi_master_mode_t spi_mode;
164 spi_master_chip_select_polarity_t cs_polarity;
167
172typedef enum
173{
175 BUCK16_ERROR = -1
176
178
195
209err_t buck16_init ( buck16_t *ctx, buck16_cfg_t *cfg );
210
224err_t buck16_generic_write ( buck16_t *ctx, uint8_t cmd, uint8_t cmd_bits, uint16_t tx_data );
225
234void buck16_enable_output ( buck16_t *ctx, uint8_t enable );
235
247err_t buck16_set_potentiometer ( buck16_t *ctx, uint16_t rwb );
248
262err_t buck16_set_output ( buck16_t *ctx, uint16_t vout );
263
264
265#ifdef __cplusplus
266}
267#endif
268#endif // BUCK16_H
269 // buck16
271
272// ------------------------------------------------------------------------ END
buck16_return_value_t
Buck 16 Click return value data.
Definition: buck16.h:173
@ BUCK16_ERROR
Definition: buck16.h:175
@ BUCK16_OK
Definition: buck16.h:174
void buck16_enable_output(buck16_t *ctx, uint8_t enable)
Enable/Disable voltage output.
err_t buck16_set_output(buck16_t *ctx, uint16_t vout)
Set output voltage.
err_t buck16_generic_write(buck16_t *ctx, uint8_t cmd, uint8_t cmd_bits, uint16_t tx_data)
Data writing function.
err_t buck16_set_potentiometer(buck16_t *ctx, uint16_t rwb)
Set potentiometer resistivity.
err_t buck16_init(buck16_t *ctx, buck16_cfg_t *cfg)
Buck 16 initialization function.
void buck16_cfg_setup(buck16_cfg_t *cfg)
Buck 16 configuration object setup function.
This file contains SPI specific macros, functions, etc.
Buck 16 Click configuration object.
Definition: buck16.h:151
spi_master_chip_select_polarity_t cs_polarity
Definition: buck16.h:164
pin_name_t sck
Definition: buck16.h:155
spi_master_mode_t spi_mode
Definition: buck16.h:163
pin_name_t mosi
Definition: buck16.h:154
uint32_t spi_speed
Definition: buck16.h:162
pin_name_t miso
Definition: buck16.h:153
pin_name_t rst
Definition: buck16.h:159
pin_name_t cs
Definition: buck16.h:156
Buck 16 Click context object.
Definition: buck16.h:136
spi_master_t spi
Definition: buck16.h:141
digital_out_t rst
Definition: buck16.h:138
pin_name_t chip_select
Definition: buck16.h:142