stepdown8 2.1.0.0
stepdown8.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 STEPDOWN8_H
29#define STEPDOWN8_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
73#define STEPDOWN8_PFM_PWM_MODE 0x00
74#define STEPDOWN8_FORCED_PWM_MODE 0x01
75#define STEPDOWN8_R1_RPROG_ADDRESS 0x00
76
77 // stepdown8_reg
78
94#define STEPDOWN8_R1_VALUE 200000ul
95#define STEPDOWN8_DIGIPOT_MAX_VALUE 100000ul
96#define STEPDOWN8_DIGIPOT_RESOLUTION 257
97#define STEPDOWN8_ROUND_TO_NEAREST_INT 0.5
98#define STEPDOWN8_R10_VALUE 10000u
99#define STEPDOWN8_MAX_OUTPUT 18
100#define STEPDOWN8_MIN_OUTPUT 3
101
106#define STEPDOWN8_PIN_STATE_HIGH 0x01
107#define STEPDOWN8_PIN_STATE_LOW 0x00
108
114#define STEPDOWN8_ADDR_A2A1A0_000 0x28
115#define STEPDOWN8_ADDR_A2A1A0_001 0x29
116#define STEPDOWN8_ADDR_A2A1A0_010 0x2A
117#define STEPDOWN8_ADDR_A2A1A0_011 0x2B
118#define STEPDOWN8_ADDR_A2A1A0_100 0x2C
119#define STEPDOWN8_ADDR_A2A1A0_101 0x2D
120#define STEPDOWN8_ADDR_A2A1A0_110 0x2E
121#define STEPDOWN8_ADDR_A2A1A0_111 0x2F
122
123 // stepdown8_set
124
139#define STEPDOWN8_MAP_MIKROBUS( cfg, mikrobus ) \
140 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
141 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
142 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
143 cfg.sps = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
144 cfg.pg = MIKROBUS( mikrobus, MIKROBUS_INT )
145
146 // stepdown8_map
147 // stepdown8
148
153typedef struct
154{
155 // Output pins
156 digital_out_t en;
157 digital_out_t sps;
159 // Input pins
160 digital_in_t pg;
162 // Modules
163 i2c_master_t i2c;
165 // I2C slave address
169
174typedef struct
175{
176 pin_name_t scl;
177 pin_name_t sda;
179 pin_name_t en;
180 pin_name_t sps;
181 pin_name_t pg;
183 uint32_t i2c_speed;
184 uint8_t i2c_address;
187
198
215
230
244
254void stepdown8_set_en_pin ( stepdown8_t *ctx, uint8_t pin_state );
255
265void stepdown8_set_sps_pin ( stepdown8_t *ctx, uint8_t pin_state );
266
276
288err_t stepdown8_set_wiper_pos ( stepdown8_t *ctx, uint16_t wiper_pos );
289
301err_t stepdown8_set_r2_resistance ( stepdown8_t *ctx, uint32_t resistance );
302
314err_t stepdown8_set_output ( stepdown8_t *ctx, float voltage );
315
316#ifdef __cplusplus
317}
318#endif
319#endif // STEPDOWN8_H
320
321 // stepdown8
322
323// ------------------------------------------------------------------------ END
err_t stepdown8_set_wiper_pos(stepdown8_t *ctx, uint16_t wiper_pos)
Step Down 8 set wiper position.
err_t stepdown8_default_cfg(stepdown8_t *ctx)
Step Down 8 default configuration function.
void stepdown8_set_sps_pin(stepdown8_t *ctx, uint8_t pin_state)
Step Down 8 set SPS pin state function.
void stepdown8_set_en_pin(stepdown8_t *ctx, uint8_t pin_state)
Step Down 8 set EN pin state function.
err_t stepdown8_set_r2_resistance(stepdown8_t *ctx, uint32_t resistance)
Step Down 8 set potentiometer resistance.
uint8_t stepdown8_get_pg_state(stepdown8_t *ctx)
Step Down 8 get PG pin state function.
err_t stepdown8_init(stepdown8_t *ctx, stepdown8_cfg_t *cfg)
Step Down 8 initialization function.
err_t stepdown8_set_output(stepdown8_t *ctx, float voltage)
Step Down 8 set output voltage.
void stepdown8_cfg_setup(stepdown8_cfg_t *cfg)
Step Down 8 configuration object setup function.
stepdown8_return_value_t
Step Down 8 Click return value data.
Definition stepdown8.h:193
@ STEPDOWN8_OK
Definition stepdown8.h:194
@ STEPDOWN8_ERROR
Definition stepdown8.h:195
Step Down 8 Click configuration object.
Definition stepdown8.h:175
uint32_t i2c_speed
Definition stepdown8.h:183
pin_name_t scl
Definition stepdown8.h:176
pin_name_t en
Definition stepdown8.h:179
pin_name_t sps
Definition stepdown8.h:180
pin_name_t sda
Definition stepdown8.h:177
pin_name_t pg
Definition stepdown8.h:181
uint8_t i2c_address
Definition stepdown8.h:184
Step Down 8 Click context object.
Definition stepdown8.h:154
i2c_master_t i2c
Definition stepdown8.h:163
digital_out_t en
Definition stepdown8.h:156
uint8_t slave_address
Definition stepdown8.h:166
digital_out_t sps
Definition stepdown8.h:157
digital_in_t pg
Definition stepdown8.h:160