digipot14 2.1.0.0
digipot14.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 DIGIPOT14_H
29#define DIGIPOT14_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 DIGIPOT14_VOLATILE_REG_WRA 0x00
60#define DIGIPOT14_VOLATILE_REG_WRB 0x01
61#define DIGIPOT14_VOLATILE_REG_ACR 0x10
62#define DIGIPOT14_NON_VOLATILE_REG_IVRA 0x00
63#define DIGIPOT14_NON_VOLATILE_REG_IVRB 0x01
64 // digipot14_reg
66
81#define DIGIPOT14_VOLATILE_REG_WRITE 0x80
82#define DIGIPOT14_NON_VOLATILE_REG_WRITE 0x00
83#define DIGIPOT14_DISABLE_SHUT_DOWN 0x40
84#define DIGIPOT14_ENABLE_SHUT_DOWN 0x00
85#define DIGIPOT14_NON_VOLATILE_WR_IN_PROGRESS 0x20
86#define DIGIPOT14_NON_VOLATILE_WR_NOT_IN_PROGRESS 0x00
87
88#define DIGIPOT14_MAX_RESISTANCE_KOHM 100.0
89#define DIGIPOT14_MAX_POSITION 255
90#define DIGIPOT14_MAX_POSITION_NUM 256.0
91#define DIGIPOT14_MIN_POSITION 0
92
98#define DIGIPOT14_DEVICE_ADDRESS_000 0x50
99#define DIGIPOT14_DEVICE_ADDRESS_001 0x51
100#define DIGIPOT14_DEVICE_ADDRESS_010 0x52
101#define DIGIPOT14_DEVICE_ADDRESS_011 0x53
102#define DIGIPOT14_DEVICE_ADDRESS_100 0x54
103#define DIGIPOT14_DEVICE_ADDRESS_101 0x55
104#define DIGIPOT14_DEVICE_ADDRESS_110 0x56
105#define DIGIPOT14_DEVICE_ADDRESS_111 0x57
106 // digipot14_set
108
123#define DIGIPOT14_MAP_MIKROBUS( cfg, mikrobus ) \
124 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
125 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
126 // digipot14_map // digipot14
129
134typedef struct
135{
136 // Modules
137 i2c_master_t i2c;
139 // I2C slave address
143
148typedef struct
149{
150 pin_name_t scl;
151 pin_name_t sda;
153 uint32_t i2c_speed;
154 uint8_t i2c_address;
157
162typedef enum
163{
165 DIGIPOT14_ERROR = -1
166
168
185
200
214
229err_t digipot14_generic_write ( digipot14_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
230
245err_t digipot14_generic_read ( digipot14_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
246
260err_t digipot14_reg_write ( digipot14_t *ctx, uint8_t reg, uint8_t data_in );
261
275err_t digipot14_reg_read ( digipot14_t *ctx, uint8_t reg, uint8_t *data_out );
276
290err_t digipot14_set_pot_a_wiper ( digipot14_t *ctx, uint8_t wiper_pos );
291
305err_t digipot14_set_pot_b_wiper ( digipot14_t *ctx, uint8_t wiper_pos );
306
307#ifdef __cplusplus
308}
309#endif
310#endif // DIGIPOT14_H
311 // digipot14
313
314// ------------------------------------------------------------------------ END
digipot14_return_value_t
DIGI POT 14 Click return value data.
Definition: digipot14.h:163
@ DIGIPOT14_OK
Definition: digipot14.h:164
@ DIGIPOT14_ERROR
Definition: digipot14.h:165
err_t digipot14_init(digipot14_t *ctx, digipot14_cfg_t *cfg)
DIGI POT 14 initialization function.
void digipot14_cfg_setup(digipot14_cfg_t *cfg)
DIGI POT 14 configuration object setup function.
err_t digipot14_generic_write(digipot14_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
DIGI POT 14 I2C writing function.
err_t digipot14_generic_read(digipot14_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
DIGI POT 14 I2C reading function.
err_t digipot14_reg_read(digipot14_t *ctx, uint8_t reg, uint8_t *data_out)
DIGI POT 14 register reading function.
err_t digipot14_reg_write(digipot14_t *ctx, uint8_t reg, uint8_t data_in)
DIGI POT 14 register write function.
err_t digipot14_default_cfg(digipot14_t *ctx)
DIGI POT 14 default configuration function.
err_t digipot14_set_pot_b_wiper(digipot14_t *ctx, uint8_t wiper_pos)
DIGI POT 14 set the wiper position of potentiometer B function.
err_t digipot14_set_pot_a_wiper(digipot14_t *ctx, uint8_t wiper_pos)
DIGI POT 14 set the wiper position of potentiometer A function.
DIGI POT 14 Click configuration object.
Definition: digipot14.h:149
uint32_t i2c_speed
Definition: digipot14.h:153
pin_name_t scl
Definition: digipot14.h:150
pin_name_t sda
Definition: digipot14.h:151
uint8_t i2c_address
Definition: digipot14.h:154
DIGI POT 14 Click context object.
Definition: digipot14.h:135
i2c_master_t i2c
Definition: digipot14.h:137
uint8_t slave_address
Definition: digipot14.h:140