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
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_i2c_master.h"
38
59#define STEPDOWN8_PFM_PWM_MODE 0x00
60#define STEPDOWN8_FORCED_PWM_MODE 0x01
61#define STEPDOWN8_R1_RPROG_ADDRESS 0x00
62 // stepdown8_reg
64
80#define STEPDOWN8_R1_VALUE 200000ul
81#define STEPDOWN8_DIGIPOT_MAX_VALUE 100000ul
82#define STEPDOWN8_DIGIPOT_RESOLUTION 257
83#define STEPDOWN8_ROUND_TO_NEAREST_INT 0.5
84#define STEPDOWN8_R10_VALUE 10000u
85#define STEPDOWN8_MAX_OUTPUT 18
86#define STEPDOWN8_MIN_OUTPUT 3
87
92#define STEPDOWN8_PIN_STATE_HIGH 0x01
93#define STEPDOWN8_PIN_STATE_LOW 0x00
94
100#define STEPDOWN8_ADDR_A2A1A0_000 0x28
101#define STEPDOWN8_ADDR_A2A1A0_001 0x29
102#define STEPDOWN8_ADDR_A2A1A0_010 0x2A
103#define STEPDOWN8_ADDR_A2A1A0_011 0x2B
104#define STEPDOWN8_ADDR_A2A1A0_100 0x2C
105#define STEPDOWN8_ADDR_A2A1A0_101 0x2D
106#define STEPDOWN8_ADDR_A2A1A0_110 0x2E
107#define STEPDOWN8_ADDR_A2A1A0_111 0x2F
108 // stepdown8_set
110
125#define STEPDOWN8_MAP_MIKROBUS( cfg, mikrobus ) \
126 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
127 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
128 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
129 cfg.sps = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
130 cfg.pg = MIKROBUS( mikrobus, MIKROBUS_INT )
131 // stepdown8_map // stepdown8
134
139typedef struct
140{
141 // Output pins
142 digital_out_t en;
143 digital_out_t sps;
145 // Input pins
146 digital_in_t pg;
148 // Modules
149 i2c_master_t i2c;
151 // I2C slave address
155
160typedef struct
161{
162 pin_name_t scl;
163 pin_name_t sda;
165 pin_name_t en;
166 pin_name_t sps;
167 pin_name_t pg;
169 uint32_t i2c_speed;
170 uint8_t i2c_address;
173
178typedef enum
179{
181 STEPDOWN8_ERROR = -1
182
184
201
216
230
240void stepdown8_set_en_pin ( stepdown8_t *ctx, uint8_t pin_state );
241
251void stepdown8_set_sps_pin ( stepdown8_t *ctx, uint8_t pin_state );
252
262
274err_t stepdown8_set_wiper_pos ( stepdown8_t *ctx, uint16_t wiper_pos );
275
287err_t stepdown8_set_r2_resistance ( stepdown8_t *ctx, uint32_t resistance );
288
300err_t stepdown8_set_output ( stepdown8_t *ctx, float voltage );
301
302#ifdef __cplusplus
303}
304#endif
305#endif // STEPDOWN8_H
306 // stepdown8
308
309// ------------------------------------------------------------------------ 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:179
@ STEPDOWN8_OK
Definition: stepdown8.h:180
@ STEPDOWN8_ERROR
Definition: stepdown8.h:181
Step Down 8 Click configuration object.
Definition: stepdown8.h:161
uint32_t i2c_speed
Definition: stepdown8.h:169
pin_name_t scl
Definition: stepdown8.h:162
pin_name_t en
Definition: stepdown8.h:165
pin_name_t sps
Definition: stepdown8.h:166
pin_name_t sda
Definition: stepdown8.h:163
pin_name_t pg
Definition: stepdown8.h:167
uint8_t i2c_address
Definition: stepdown8.h:170
Step Down 8 Click context object.
Definition: stepdown8.h:140
i2c_master_t i2c
Definition: stepdown8.h:149
digital_out_t en
Definition: stepdown8.h:142
uint8_t slave_address
Definition: stepdown8.h:152
digital_out_t sps
Definition: stepdown8.h:143
digital_in_t pg
Definition: stepdown8.h:146