stepdown10 2.1.0.0
stepdown10.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 STEPDOWN10_H
29#define STEPDOWN10_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 STEPDOWN10_PFM_PWM_MODE 0x00
60#define STEPDOWN10_FORCED_PWM_MODE 0x01
61#define STEPDOWN10_R1_RPROG_ADDRESS 0x00
62 // stepdown10_reg
64
79#define STEPDOWN10_R1_VALUE 100000ul
80#define STEPDOWN10_DIGIPOT_MAX_VALUE 100000ul
81#define STEPDOWN10_DIGIPOT_RESOLUTION 257
82#define STEPDOWN10_ROUND_TO_NEAREST_INT 0.5
83#define STEPDOWN10_R13_VALUE 1000u
84#define STEPDOWN10_MAX_OUTPUT 20
85#define STEPDOWN10_MIN_OUTPUT 2
86
91#define STEPDOWN10_PIN_STATE_HIGH 0x01
92#define STEPDOWN10_PIN_STATE_LOW 0x00
93
99#define STEPDOWN10_ADDR_A2A1A0_000 0x28
100#define STEPDOWN10_ADDR_A2A1A0_001 0x29
101#define STEPDOWN10_ADDR_A2A1A0_010 0x2A
102#define STEPDOWN10_ADDR_A2A1A0_011 0x2B
103#define STEPDOWN10_ADDR_A2A1A0_100 0x2C
104#define STEPDOWN10_ADDR_A2A1A0_101 0x2D
105#define STEPDOWN10_ADDR_A2A1A0_110 0x2E
106#define STEPDOWN10_ADDR_A2A1A0_111 0x2F
107 // stepdown10_set
109
124#define STEPDOWN10_MAP_MIKROBUS( cfg, mikrobus ) \
125 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
126 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
127 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
128 cfg.md = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
129 cfg.pg = MIKROBUS( mikrobus, MIKROBUS_INT )
130 // stepdown10_map // stepdown10
133
138typedef struct
139{
140 // Output pins
141 digital_out_t en;
142 digital_out_t md;
144 // Input pins
145 digital_in_t pg;
147 // Modules
148 i2c_master_t i2c;
150 // I2C slave address
154
159typedef struct
160{
161 pin_name_t scl;
162 pin_name_t sda;
164 pin_name_t en;
165 pin_name_t md;
166 pin_name_t pg;
168 uint32_t i2c_speed;
169 uint8_t i2c_address;
172
177typedef enum
178{
181
183
200
215
229
244err_t stepdown10_generic_write ( stepdown10_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
245
260err_t stepdown10_generic_read ( stepdown10_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
261
271void stepdown10_set_en_pin ( stepdown10_t *ctx, uint8_t pin_state );
272
282void stepdown10_set_md ( stepdown10_t *ctx, uint8_t mode );
283
293
305err_t stepdown10_set_wiper_pos ( stepdown10_t *ctx, uint16_t wiper_pos );
306
318err_t stepdown10_set_r2_resistance ( stepdown10_t *ctx, uint32_t resistance );
319
331err_t stepdown10_set_output ( stepdown10_t *ctx, float voltage );
332
333#ifdef __cplusplus
334}
335#endif
336#endif // STEPDOWN10_H
337 // stepdown10
339
340// ------------------------------------------------------------------------ END
err_t stepdown10_set_r2_resistance(stepdown10_t *ctx, uint32_t resistance)
Step Down 10 set potentiometer resistance.
err_t stepdown10_set_wiper_pos(stepdown10_t *ctx, uint16_t wiper_pos)
Step Down 10 set wiper position.
void stepdown10_set_en_pin(stepdown10_t *ctx, uint8_t pin_state)
Step Down 10 set EN pin state function.
uint8_t stepdown10_get_pg_state(stepdown10_t *ctx)
Step Down 10 get PG pin state function.
void stepdown10_cfg_setup(stepdown10_cfg_t *cfg)
Step Down 10 configuration object setup function.
err_t stepdown10_generic_read(stepdown10_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Step Down 10 I2C reading function.
err_t stepdown10_set_output(stepdown10_t *ctx, float voltage)
Step Down 10 set output voltage.
err_t stepdown10_init(stepdown10_t *ctx, stepdown10_cfg_t *cfg)
Step Down 10 initialization function.
err_t stepdown10_default_cfg(stepdown10_t *ctx)
Step Down 10 default configuration function.
void stepdown10_set_md(stepdown10_t *ctx, uint8_t mode)
Step Down 10 mode selection function.
err_t stepdown10_generic_write(stepdown10_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Step Down 10 I2C writing function.
stepdown10_return_value_t
Step Down 10 Click return value data.
Definition: stepdown10.h:178
@ STEPDOWN10_OK
Definition: stepdown10.h:179
@ STEPDOWN10_ERROR
Definition: stepdown10.h:180
Step Down 10 Click configuration object.
Definition: stepdown10.h:160
uint32_t i2c_speed
Definition: stepdown10.h:168
pin_name_t md
Definition: stepdown10.h:165
pin_name_t scl
Definition: stepdown10.h:161
pin_name_t en
Definition: stepdown10.h:164
pin_name_t sda
Definition: stepdown10.h:162
pin_name_t pg
Definition: stepdown10.h:166
uint8_t i2c_address
Definition: stepdown10.h:169
Step Down 10 Click context object.
Definition: stepdown10.h:139
digital_out_t md
Definition: stepdown10.h:142
i2c_master_t i2c
Definition: stepdown10.h:148
digital_out_t en
Definition: stepdown10.h:141
uint8_t slave_address
Definition: stepdown10.h:151
digital_in_t pg
Definition: stepdown10.h:145