41#ifdef PREINIT_SUPPORTED
45#ifdef MikroCCoreVersion
46 #if MikroCCoreVersion >= 1
51#include "drv_digital_out.h"
52#include "drv_digital_in.h"
53#include "drv_i2c_master.h"
65#define ADAC_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
67 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
68 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST )
75#define ADAC_RETVAL uint8_t
78#define ADAC_INIT_ERROR 0xFF
85#define ADAC_I2C_SLAVE_ADDR 0X10
86#define ADAC_SOFT_RESET_CMD 0x0DAC
87#define ADAC_NO_OP 0X00
88#define ADAC_ADC_SEQUENCE 0X02
89#define ADAC_GP_CONTROL 0X03
90#define ADAC_ADC_CONFIG 0X04
91#define ADAC_DAC_CONFIG 0X05
92#define ADAC_PULL_DOWN 0X06
93#define ADAC_LDAC_MODE 0X07
94#define ADAC_GPIO_WR_CONFIG 0X08
95#define ADAC_GPIO_WR_DATA 0X09
96#define ADAC_GPIO_RD_CONFIG 0X0A
97#define ADAC_POWER_REF_CTRL 0X0B
98#define ADAC_OPEN_DRAIN_CFG 0X0C
99#define ADAC_THREE_STATE 0X0D
100#define ADAC_SOFT_RESET 0X0F
107#define ADAC_CONFIG_MOD 0X00
108#define ADAC_DAC_WRITE 0X10
109#define ADAC_ADC_READ 0X40
110#define ADAC_DAC_READ 0X50
111#define ADAC_GPIO_READ 0X60
112#define ADAC_REG_READ 0X70
119#define ADAC_VREF_ON 0X02
120#define ADAC_SEQUENCE_ON 0X02
141#define ADAC_PB_PIN0 0X00
142#define ADAC_PB_PIN1 0X01
143#define ADAC_PB_PIN2 0X02
144#define ADAC_PB_PIN3 0X03
145#define ADAC_PB_PIN4 0X04
146#define ADAC_PB_PIN5 0X05
147#define ADAC_PB_PIN6 0X06
148#define ADAC_PB_PIN7 0X07
155#define ADAC_PB_DAC0 0X10
156#define ADAC_PB_DAC1 0X11
157#define ADAC_PB_DAC2 0X12
158#define ADAC_PB_DAC3 0X13
159#define ADAC_PB_DAC4 0X14
160#define ADAC_PB_DAC5 0X15
161#define ADAC_PB_DAC6 0X16
162#define ADAC_PB_DAC7 0X17
169#define ADAC_DAC_RANGE_SEL 0X0010
170#define ADAC_ADC_RANGE_SEL 0X0020
171#define ADAC_WRITE_ALL_DACS 0X0040
172#define ADAC_LOCK_CONFIG 0X0080
173#define ADAC_ADC_BUFF_ENABLE 0X0100
174#define ADAC_ADC_BUFF_PRE_CHAR 0X0200
181#define ADAC_PD_CHAN_0 0X0001
182#define ADAC_PD_CHAN_1 0X0002
183#define ADAC_PD_CHAN_2 0X0004
184#define ADAC_PD_CHAN_3 0X0008
185#define ADAC_PD_CHAN_4 0X0010
186#define ADAC_PD_CHAN_5 0X0020
187#define ADAC_PD_CHAN_6 0X0040
188#define ADAC_PD_CHAN_7 0x0080
189#define ADAC_REF_BUFF_POW_UP 0x0200
190#define ADAC_PD_ALL 0x0400
#define ADAC_RETVAL
Definition adac.h:75
void adac_power_down_settings(adac_t *ctx, uint16_t settings)
Power down function.
ADAC_RETVAL adac_init(adac_t *ctx, adac_cfg_t *cfg)
Initialization function.
uint16_t adac_read_dac(adac_t *ctx, uint8_t *chan)
Read DAC function.
void adac_cfg_setup(adac_cfg_t *cfg)
Config Object Initialization function.
void adac_hardware_reset(adac_t *ctx)
Hardware reset function.
void adac_write_dac_data(adac_t *ctx, uint8_t chan, uint16_t w_data)
Write DAC data function.
void adac_general_purpose_settings(adac_t *ctx, uint16_t settings)
General purpose function.
void adac_set_configuration(adac_t *ctx, uint8_t ptr, uint8_t msb, uint8_t lsb)
Set configuration function.
void adac_software_reset(adac_t *ctx, uint16_t cmd)
Software reset function.
void adac_generic_write(adac_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint16_t adac_read_config(adac_t *ctx)
Read configuration function.
void adac_generic_read(adac_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void adac_write_dac(adac_t *ctx, uint8_t chan, uint8_t msb, uint8_t lsb)
Write DAC function.
void adac_write_data(adac_t *ctx, uint8_t addr, uint16_t w_data)
Write data function.
uint8_t adac_read_gpio(adac_t *ctx)
Read GPIO function.
uint16_t adac_read_adc(adac_t *ctx, uint8_t *chan)
Read ADC function.
uint16_t adac_read_data(adac_t *ctx, uint8_t addr)
Read data function.
void adac_write_gpio(adac_t *ctx, uint8_t w_data)
Write GPIO function.
Click configuration structure definition.
Definition adac.h:223
uint32_t i2c_speed
Definition adac.h:235
pin_name_t scl
Definition adac.h:226
pin_name_t sda
Definition adac.h:227
pin_name_t rst
Definition adac.h:231
uint8_t i2c_address
Definition adac.h:236
Click ctx object definition.
Definition adac.h:204
i2c_master_t i2c
Definition adac.h:211
digital_out_t rst
Definition adac.h:207
uint8_t slave_address
Definition adac.h:215