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
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
68#define DIGIPOT11_WIPER_SEL_A 0x11
69#define DIGIPOT11_WIPER_SEL_B 0x12
70#define DIGIPOT11_WIPER_SEL_BOTH 0x13
71
76#define DIGIPOT11_WIPER_FULL_SCALE 0xFF
77#define DIGIPOT11_WIPER_MID_SCALE 0x80
78#define DIGIPOT11_WIPER_ZERO_SCALE 0x00
79
85#define DIGIPOT11_U1_DEVICE_ADDRESS_A1A0_00 0x2C
86#define DIGIPOT11_U1_DEVICE_ADDRESS_A1A0_01 0x2D
87#define DIGIPOT11_U1_DEVICE_ADDRESS_A1A0_10 0x2E
88#define DIGIPOT11_U1_DEVICE_ADDRESS_A1A0_11 0x2F
89#define DIGIPOT11_U2_DEVICE_ADDRESS_A1A0_00 0x28
90#define DIGIPOT11_U2_DEVICE_ADDRESS_A1A0_01 0x29
91#define DIGIPOT11_U2_DEVICE_ADDRESS_A1A0_10 0x2A
92#define DIGIPOT11_U2_DEVICE_ADDRESS_A1A0_11 0x2B
93
94 // digipot11_set
95
110#define DIGIPOT11_MAP_MIKROBUS( cfg, mikrobus ) \
111 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
112 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
113
114 // digipot11_map
115 // digipot11
116
121typedef struct
122{
123 // Modules
124 i2c_master_t i2c;
126 // I2C slave address
131
136typedef struct
137{
138 pin_name_t scl;
139 pin_name_t sda;
141 uint32_t i2c_speed;
146
157
174
189
204err_t digipot11_set_u1_wiper ( digipot11_t *ctx, uint8_t wiper_sel, uint8_t data_in );
205
220err_t digipot11_set_u2_wiper ( digipot11_t *ctx, uint8_t wiper_sel, uint8_t data_in );
221
222#ifdef __cplusplus
223}
224#endif
225#endif // DIGIPOT11_H
226
227 // digipot11
228
229// ------------------------------------------------------------------------ END
digipot11_return_value_t
DIGI POT 11 Click return value data.
Definition digipot11.h:152
@ DIGIPOT11_OK
Definition digipot11.h:153
@ DIGIPOT11_ERROR
Definition digipot11.h:154
err_t digipot11_set_u1_wiper(digipot11_t *ctx, uint8_t wiper_sel, uint8_t data_in)
DIGI POT 11 set u1 wiper function.
err_t digipot11_set_u2_wiper(digipot11_t *ctx, uint8_t wiper_sel, uint8_t data_in)
DIGI POT 11 set u2 wiper function.
void digipot11_cfg_setup(digipot11_cfg_t *cfg)
DIGI POT 11 configuration object setup function.
err_t digipot11_init(digipot11_t *ctx, digipot11_cfg_t *cfg)
DIGI POT 11 initialization function.
DIGI POT 11 Click configuration object.
Definition digipot11.h:137
uint8_t i2c_address_u1
Definition digipot11.h:142
uint32_t i2c_speed
Definition digipot11.h:141
uint8_t i2c_address_u2
Definition digipot11.h:143
pin_name_t scl
Definition digipot11.h:138
pin_name_t sda
Definition digipot11.h:139
DIGI POT 11 Click context object.
Definition digipot11.h:122
uint8_t u2_slave_address
Definition digipot11.h:128
uint8_t u1_slave_address
Definition digipot11.h:127
i2c_master_t i2c
Definition digipot11.h:124