digipot13  2.1.0.0
digipot13.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 DIGIPOT13_H
29 #define DIGIPOT13_H
30 
31 #ifdef __cplusplus
32 extern "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 DIGIPOT13_CMD_VREG 0x11
60 #define DIGIPOT13_CMD_NVREG 0x21
61 #define DIGIPOT13_CMD_VREGxNVREG 0x51
62 #define DIGIPOT13_CMD_NVREGxVREG 0x61
63  // digipot13_cmd
65 
80 #define DIGIPOT13_WIPER_POS_MIN 0
81 #define DIGIPOT13_WIPER_POS_MIDDLE 127
82 #define DIGIPOT13_WIPER_POS_MAX 255
83 #define DIGIPOT13_RES_0_KOHM 0
84 #define DIGIPOT13_RES_50_KOHM 50
85 #define DIGIPOT13_RES_200_KOHM 200
86 
92 #define DIGIPOT13_DEVICE_ADDRESS_GND 0x28
93 #define DIGIPOT13_DEVICE_ADDRESS_VCC 0x29
94  // digipot13_set
96 
111 #define DIGIPOT13_MAP_MIKROBUS( cfg, mikrobus ) \
112  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
113  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
114  // digipot13_map // digipot13
116 
121 typedef struct
122 {
123  // Modules
124  i2c_master_t i2c;
126  // I2C slave address
127  uint8_t slave_address;
129 } digipot13_t;
130 
135 typedef struct
136 {
137  pin_name_t scl;
138  pin_name_t sda;
140  uint32_t i2c_speed;
141  uint8_t i2c_address;
144 
149 typedef enum
150 {
152  DIGIPOT13_ERROR = -1
153 
155 
160 typedef enum
161 {
166 
183 
198 
212 
227 err_t digipot13_write_data ( digipot13_t *ctx, uint8_t cmd, uint8_t data_in );
228 
242 err_t digipot13_set_wiper_pos ( digipot13_t *ctx, uint8_t wiper_pos );
243 
259 err_t digipot13_set_resistance ( digipot13_t *ctx, digipot13_cfg_res_t cfg_res, float res_kohm );
260 
275 
290 
291 #ifdef __cplusplus
292 }
293 #endif
294 #endif // DIGIPOT13_H
295  // digipot13
297 
298 // ------------------------------------------------------------------------ END
digipot13_t::i2c
i2c_master_t i2c
Definition: digipot13.h:124
digipot13_t::slave_address
uint8_t slave_address
Definition: digipot13.h:127
digipot13_cfg_t::scl
pin_name_t scl
Definition: digipot13.h:137
digipot13_init
err_t digipot13_init(digipot13_t *ctx, digipot13_cfg_t *cfg)
DIGI POT 13 initialization function.
DIGIPOT13_ERROR
@ DIGIPOT13_ERROR
Definition: digipot13.h:152
digipot13_default_cfg
err_t digipot13_default_cfg(digipot13_t *ctx)
DIGI POT 13 default configuration function.
DIGIPOT13_CFG_RES_WL
@ DIGIPOT13_CFG_RES_WL
Definition: digipot13.h:162
digipot13_switch_v_to_nv
err_t digipot13_switch_v_to_nv(digipot13_t *ctx)
DIGI POT 13 data transfers volatile to nonvolatile function.
digipot13_set_wiper_pos
err_t digipot13_set_wiper_pos(digipot13_t *ctx, uint8_t wiper_pos)
DIGI POT 13 set the wiper position function.
digipot13_cfg_res_t
digipot13_cfg_res_t
DIGI POT 13 Click resistance configuration value data.
Definition: digipot13.h:161
digipot13_set_resistance
err_t digipot13_set_resistance(digipot13_t *ctx, digipot13_cfg_res_t cfg_res, float res_kohm)
DIGI POT 13 set the resistance function.
digipot13_t
DIGI POT 13 Click context object.
Definition: digipot13.h:122
DIGIPOT13_OK
@ DIGIPOT13_OK
Definition: digipot13.h:151
DIGIPOT13_CFG_RES_WH
@ DIGIPOT13_CFG_RES_WH
Definition: digipot13.h:163
digipot13_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: digipot13.h:140
digipot13_cfg_t::i2c_address
uint8_t i2c_address
Definition: digipot13.h:141
digipot13_cfg_t::sda
pin_name_t sda
Definition: digipot13.h:138
digipot13_switch_nv_to_v
err_t digipot13_switch_nv_to_v(digipot13_t *ctx)
DIGI POT 13 data transfers nonvolatile to volatile function.
digipot13_write_data
err_t digipot13_write_data(digipot13_t *ctx, uint8_t cmd, uint8_t data_in)
DIGI POT 13 write data function.
digipot13_cfg_t
DIGI POT 13 Click configuration object.
Definition: digipot13.h:136
digipot13_return_value_t
digipot13_return_value_t
DIGI POT 13 Click return value data.
Definition: digipot13.h:150
digipot13_cfg_setup
void digipot13_cfg_setup(digipot13_cfg_t *cfg)
DIGI POT 13 configuration object setup function.