39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
73#define DIGIPOT12_CTRL_BIT_NOP 0x00
74#define DIGIPOT12_CTRL_BIT_WRITE_RDAC 0x10
75#define DIGIPOT12_CTRL_BIT_WRITE_SHIFT_REG 0x20
76#define DIGIPOT12_CTRL_BIT_READ 0x30
77#define DIGIPOT12_CTRL_BIT_LIN_RDAC 0x40
78#define DIGIPOT12_CTRL_BIT_6_DB_RDAC 0x50
79#define DIGIPOT12_CTRL_BIT_COPY_LRDAC 0x60
80#define DIGIPOT12_CTRL_BIT_COPY_RDAC_EEPROM 0x70
81#define DIGIPOT12_CTRL_BIT_WRITE_EEPROM 0x80
82#define DIGIPOT12_CTRL_BIT_SCALE 0x90
83#define DIGIPOT12_CTRL_BIT_SW_RST 0xB0
84#define DIGIPOT12_CTRL_BIT_SW_SHDN 0xC0
85#define DIGIPOT12_CTRL_BIT_REG_CTRL 0xD0
86#define DIGIPOT12_CTRL_BIT_MASK 0xF0
99#define DIGIPOT12_ADDR_BIT_RDAC1 0x00
100#define DIGIPOT12_ADDR_BIT_RDAC2 0x01
101#define DIGIPOT12_ADDR_BIT_ALL_CHANNELS 0x08
114#define DIGIPOT12_WIPER_SEL_1 0x00
115#define DIGIPOT12_WIPER_SEL_2 0x01
116#define DIGIPOT12_WIPER_SEL_BOTH 0x08
129#define DIGIPOT12_ADDR_BIT_READ_INPUT_REG 0x00
130#define DIGIPOT12_ADDR_BIT_READ_EEPROM 0x01
131#define DIGIPOT12_ADDR_BIT_READ_CTRL_REG 0x02
132#define DIGIPOT12_ADDR_BIT_READ_RDAC 0x03
133#define DIGIPOT12_ADDR_BIT_RDAC_DECR 0x00
134#define DIGIPOT12_ADDR_BIT_RDAC_INCR 0x01
135#define DIGIPOT12_ADDR_BIT_COPY_TO_RDAC 0x00
136#define DIGIPOT12_ADDR_BIT_COPY_TO_EEPROM 0x01
137#define DIGIPOT12_ADDR_BIT_SCALE_MODE_NORMAL 0x80
138#define DIGIPOT12_ADDR_BIT_SCALE_MODE_SHDN 0x81
139#define DIGIPOT12_ADDR_BIT_SCALE_EXIT 0x00
140#define DIGIPOT12_ADDR_BIT_SCALE_ENTER 0x01
141#define DIGIPOT12_ADDR_BIT_SW_SHDN_MODE_NORMAL 0x00
142#define DIGIPOT12_ADDR_BIT_SW_SHDN_MODE_SHDN 0x01
161#define DIGIPOT12_CTRL_REG_WIPER_POS_FROZEN 0x00
162#define DIGIPOT12_CTRL_REG_UPDATE_WIPER_POS 0x01
163#define DIGIPOT12_CTRL_REG_EEPROM_PROGRAM_DISABLE 0x00
164#define DIGIPOT12_CTRL_REG_EEPROM_PROGRAM_ENABLE 0x02
165#define DIGIPOT12_CTRL_REG_MODE_POTENTIOMETER 0x00
166#define DIGIPOT12_CTRL_REG_MODE_LINEAR_GAIN 0x04
167#define DIGIPOT12_CTRL_REG_MODE_BURST_DISABLE 0x00
168#define DIGIPOT12_CTRL_REG_MODE_BURST_ENABLE 0x08
174#define DIGIPOT12_WIPER_POS_MAX 255
175#define DIGIPOT12_WIPER_POS_MIN 0
176#define DIGIPOT12_WIPER_POS_MIDDLE 127
177#define DIGIPOT12_RES_10_KOHM 10
178#define DIGIPOT12_RES_0_KOHM 0
185#define DIGIPOT12_DEVICE_ADDRESS_0 0x2F
186#define DIGIPOT12_DEVICE_ADDRESS_1 0x2C
187#define DIGIPOT12_DEVICE_ADDRESS_2 0x23
188#define DIGIPOT12_DEVICE_ADDRESS_3 0x20
206#define DIGIPOT12_MAP_MIKROBUS( cfg, mikrobus ) \
207 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
208 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
209 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST )
digipot12_return_value_t
DIGI POT 12 Click return value data.
Definition digipot12.h:252
@ DIGIPOT12_OK
Definition digipot12.h:253
@ DIGIPOT12_ERROR
Definition digipot12.h:254
err_t digipot12_write_rdac(digipot12_t *ctx, uint8_t addr, uint8_t data_in)
DIGI POT 12 write the RDAC function.
err_t digipot12_set_wiper_2(digipot12_t *ctx, uint8_t wiper_pos)
DIGI POT 12 set wiper 2 function.
err_t digipot12_read_rdac(digipot12_t *ctx, uint8_t addr, uint8_t *data_out)
DIGI POT 12 read the RDAC function.
err_t digipot12_set_wiper_1(digipot12_t *ctx, uint8_t wiper_pos)
DIGI POT 12 set wiper 1 function.
err_t digipot12_write_data(digipot12_t *ctx, uint8_t ctrl, uint8_t addr, uint8_t data_in)
DIGI POT 12 I2C writing function.
err_t digipot12_default_cfg(digipot12_t *ctx)
DIGI POT 12 default configuration function.
void digipot12_cfg_setup(digipot12_cfg_t *cfg)
DIGI POT 12 configuration object setup function.
err_t digipot12_read_data(digipot12_t *ctx, uint8_t addr, uint8_t mask, uint8_t *data_out)
DIGI POT 12 I2C reading function.
void digipot12_hw_reset(digipot12_t *ctx)
DIGI POT 12 hardware reset function.
err_t digipot12_get_resistance(digipot12_t *ctx, uint8_t wiper_sel, float *res_kohm)
DIGI POT 12 get the resistance function.
void digipot12_device_enable(digipot12_t *ctx)
DIGI POT 12 enable the device function.
err_t digipot12_set_resistance(digipot12_t *ctx, uint8_t wiper_sel, float res_kohm)
DIGI POT 12 set the resistance function.
err_t digipot12_init(digipot12_t *ctx, digipot12_cfg_t *cfg)
DIGI POT 12 initialization function.
DIGI POT 12 Click configuration object.
Definition digipot12.h:236
uint32_t i2c_speed
Definition digipot12.h:242
pin_name_t scl
Definition digipot12.h:237
pin_name_t sda
Definition digipot12.h:238
pin_name_t rst
Definition digipot12.h:240
uint8_t i2c_address
Definition digipot12.h:243
DIGI POT 12 Click context object.
Definition digipot12.h:219
i2c_master_t i2c
Definition digipot12.h:224
digital_out_t rst
Definition digipot12.h:221
uint8_t slave_address
Definition digipot12.h:227