digipot11  2.1.0.0
digipot11.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 DIGIPOT11_H
29 #define DIGIPOT11_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 
54 #define DIGIPOT11_WIPER_SEL_A 0x11
55 #define DIGIPOT11_WIPER_SEL_B 0x12
56 #define DIGIPOT11_WIPER_SEL_BOTH 0x13
57 
62 #define DIGIPOT11_WIPER_FULL_SCALE 0xFF
63 #define DIGIPOT11_WIPER_MID_SCALE 0x80
64 #define DIGIPOT11_WIPER_ZERO_SCALE 0x00
65 
71 #define DIGIPOT11_U1_DEVICE_ADDRESS_A1A0_00 0x2C
72 #define DIGIPOT11_U1_DEVICE_ADDRESS_A1A0_01 0x2D
73 #define DIGIPOT11_U1_DEVICE_ADDRESS_A1A0_10 0x2E
74 #define DIGIPOT11_U1_DEVICE_ADDRESS_A1A0_11 0x2F
75 #define DIGIPOT11_U2_DEVICE_ADDRESS_A1A0_00 0x28
76 #define DIGIPOT11_U2_DEVICE_ADDRESS_A1A0_01 0x29
77 #define DIGIPOT11_U2_DEVICE_ADDRESS_A1A0_10 0x2A
78 #define DIGIPOT11_U2_DEVICE_ADDRESS_A1A0_11 0x2B
79  // digipot11_set
81 
96 #define DIGIPOT11_MAP_MIKROBUS( cfg, mikrobus ) \
97  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
98  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
99  // digipot11_map // digipot11
102 
107 typedef struct
108 {
109  // Modules
110  i2c_master_t i2c;
112  // I2C slave address
116 } digipot11_t;
117 
122 typedef struct
123 {
124  pin_name_t scl;
125  pin_name_t sda;
127  uint32_t i2c_speed;
128  uint8_t i2c_address_u1;
129  uint8_t i2c_address_u2;
132 
137 typedef enum
138 {
140  DIGIPOT11_ERROR = -1
141 
143 
160 
175 
190 err_t digipot11_set_u1_wiper ( digipot11_t *ctx, uint8_t wiper_sel, uint8_t data_in );
191 
206 err_t digipot11_set_u2_wiper ( digipot11_t *ctx, uint8_t wiper_sel, uint8_t data_in );
207 
208 #ifdef __cplusplus
209 }
210 #endif
211 #endif // DIGIPOT11_H
212  // digipot11
214 
215 // ------------------------------------------------------------------------ END
DIGIPOT11_OK
@ DIGIPOT11_OK
Definition: digipot11.h:139
digipot11_t::u1_slave_address
uint8_t u1_slave_address
Definition: digipot11.h:113
digipot11_set_u2_wiper
err_t digipot11_set_u2_wiper(digipot11_t *ctx, uint8_t wiper_sel, uint8_t data_in)
DIGI POT 11 set u2 wiper function.
digipot11_cfg_t::scl
pin_name_t scl
Definition: digipot11.h:124
DIGIPOT11_ERROR
@ DIGIPOT11_ERROR
Definition: digipot11.h:140
digipot11_t::u2_slave_address
uint8_t u2_slave_address
Definition: digipot11.h:114
digipot11_cfg_t::sda
pin_name_t sda
Definition: digipot11.h:125
digipot11_cfg_setup
void digipot11_cfg_setup(digipot11_cfg_t *cfg)
DIGI POT 11 configuration object setup function.
digipot11_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: digipot11.h:127
digipot11_t
DIGI POT 11 Click context object.
Definition: digipot11.h:108
digipot11_cfg_t
DIGI POT 11 Click configuration object.
Definition: digipot11.h:123
digipot11_cfg_t::i2c_address_u2
uint8_t i2c_address_u2
Definition: digipot11.h:129
digipot11_set_u1_wiper
err_t digipot11_set_u1_wiper(digipot11_t *ctx, uint8_t wiper_sel, uint8_t data_in)
DIGI POT 11 set u1 wiper function.
digipot11_init
err_t digipot11_init(digipot11_t *ctx, digipot11_cfg_t *cfg)
DIGI POT 11 initialization function.
digipot11_t::i2c
i2c_master_t i2c
Definition: digipot11.h:110
digipot11_cfg_t::i2c_address_u1
uint8_t i2c_address_u1
Definition: digipot11.h:128
digipot11_return_value_t
digipot11_return_value_t
DIGI POT 11 Click return value data.
Definition: digipot11.h:138