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"
52#include "drv_spi_master.h"
75#define DAC15_REG_NOOP 0x00
76#define DAC15_REG_DEVID 0x01
77#define DAC15_REG_SYNC 0x02
78#define DAC15_REG_CONFIG 0x03
79#define DAC15_REG_GAIN 0x04
80#define DAC15_REG_TRIGGER 0x05
81#define DAC15_REG_BRDCAST 0x06
82#define DAC15_REG_STATUS 0x07
83#define DAC15_REG_DAC_A_DATA 0x08
84#define DAC15_REG_DAC_B_DATA 0x09
102#define DAC15_DEVICE_ID 0x0295u
108#define DAC15_SYNC_DAC_B_BRDCAST_DIS 0x0000u
109#define DAC15_SYNC_DAC_B_BRDCAST_EN 0x0100u
110#define DAC15_SYNC_DAC_A_BRDCAST_DIS 0x0000u
111#define DAC15_SYNC_DAC_A_BRDCAST_EN 0x0080u
112#define DAC15_SYNC_DAC_B_SYNC_DIS 0x0000u
113#define DAC15_SYNC_DAC_B_SYNC_EN 0x0002u
114#define DAC15_SYNC_DAC_A_SYNC_DIS 0x0000u
115#define DAC15_SYNC_DAC_A_SYNC_EN 0x0001u
121#define DAC15_CONFIG_REF_PWUP 0x0000u
122#define DAC15_CONFIG_REF_PWDWN 0x0100u
123#define DAC15_CONFIG_DAC_B_PWUP 0x0000u
124#define DAC15_CONFIG_DAC_B_PWDWN 0x0002u
125#define DAC15_CONFIG_DAC_A_PWUP 0x0000u
126#define DAC15_CONFIG_DAC_A_PWDWN 0x0001u
132#define DAC15_GAIN_REF_DIV_1 0x0000u
133#define DAC15_GAIN_REF_DIV_2 0x0100u
134#define DAC15_GAIN_BUFF_B_GAIN_1 0x0000u
135#define DAC15_GAIN_BUFF_B_GAIN_2 0x0002u
136#define DAC15_GAIN_BUFF_A_GAIN_1 0x0000u
137#define DAC15_GAIN_BUFF_A_GAIN_2 0x0001u
143#define DAC15_TRIGGER_LDA_SYNC_LOAD_DAC 0x0010u
144#define DAC15_TRIGGER_SOFT_RESET 0x000Au
150#define DAC15_SET_DAC_A 0
151#define DAC15_SET_DAC_B 1
157#define DAC15_DAC_RES_16BIT 0xFFFFu
158#define DAC15_MAX_DAC_DATA 65535.0f
159#define DAC15_MAX_VOUT_MV 3300.0f
160#define DAC15_VREF_3V3 3.3f
161#define DAC15_VREF_5V 5.0f
162#define DAC15_CONV_DEV_MV_TO_V 1000.0f
170#define DAC15_DEVICE_ADDRESS_GND 0x48
171#define DAC15_DEVICE_ADDRESS_VCC 0x49
181#define DAC15_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
182#define DAC15_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
200#define DAC15_MAP_MIKROBUS( cfg, mikrobus ) \
201 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
202 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
203 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
204 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
205 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
206 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
207 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST )
dac15_return_value_t
DAC 15 Click return value data.
Definition dac15.h:282
@ DAC15_OK
Definition dac15.h:283
@ DAC15_ERROR
Definition dac15.h:284
dac15_drv_t
DAC 15 Click driver selector.
Definition dac15.h:217
@ DAC15_DRV_SEL_SPI
Definition dac15.h:218
@ DAC15_DRV_SEL_I2C
Definition dac15.h:219
err_t(* dac15_master_io_t)(struct dac15_s *, uint8_t, uint8_t *, uint8_t)
DAC 15 Click driver interface.
Definition dac15.h:227
struct dac15_s dac15_t
DAC 15 Click context object.
err_t dac15_get_dac_data(dac15_t *ctx, uint8_t dac_sel, uint16_t *dac_data)
DAC 15 get DAC data function.
err_t dac15_soft_reset(dac15_t *ctx)
DAC 15 soft reset function.
void dac15_drv_interface_selection(dac15_cfg_t *cfg, dac15_drv_t drv_sel)
DAC 15 driver interface setup function.
void dac15_cfg_setup(dac15_cfg_t *cfg)
DAC 15 configuration object setup function.
err_t dac15_write_reg(dac15_t *ctx, uint8_t reg, uint16_t data_in)
DAC 15 write register function.
err_t dac15_set_dac_vout(dac15_t *ctx, uint8_t dac_sel, float vtg)
DAC 15 set DAC output voltage function.
err_t dac15_set_dac_data(dac15_t *ctx, uint8_t dac_sel, uint16_t dac_data)
DAC 15 set DAC data function.
err_t dac15_get_device_id(dac15_t *ctx, uint16_t *device_id)
DAC 15 get device ID function.
err_t dac15_read_reg(dac15_t *ctx, uint8_t reg, uint16_t *data_out)
DAC 15 read register function.
err_t dac15_generic_write(dac15_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
DAC 15 data writing function.
err_t dac15_default_cfg(dac15_t *ctx)
DAC 15 default configuration function.
err_t dac15_get_dac_vout(dac15_t *ctx, uint8_t dac_sel, float *vtg)
DAC 15 get DAC output voltage function.
err_t dac15_init(dac15_t *ctx, dac15_cfg_t *cfg)
DAC 15 initialization function.
err_t dac15_generic_read(dac15_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
DAC 15 data reading function.
void dac15_power_up_to_midscale(dac15_t *ctx)
DAC 15 DACs s power up to midscale function.
err_t dac15_set_sync_mode(dac15_t *ctx)
DAC 15 set sync mode function.
void dac15_power_up_to_zero_scale(dac15_t *ctx)
DAC 15 DACs power up to zero scale function.
This file contains SPI specific macros, functions, etc.
DAC 15 Click configuration object.
Definition dac15.h:256
float vref
Definition dac15.h:273
dac15_drv_t drv_sel
Definition dac15.h:272
uint32_t i2c_speed
Definition dac15.h:265
spi_master_chip_select_polarity_t cs_polarity
Definition dac15.h:270
pin_name_t sck
Definition dac15.h:261
spi_master_mode_t spi_mode
Definition dac15.h:269
pin_name_t mosi
Definition dac15.h:260
uint32_t spi_speed
Definition dac15.h:268
pin_name_t scl
Definition dac15.h:257
pin_name_t miso
Definition dac15.h:259
pin_name_t sda
Definition dac15.h:258
pin_name_t rst
Definition dac15.h:263
pin_name_t cs
Definition dac15.h:262
uint8_t i2c_address
Definition dac15.h:266
DAC 15 Click context object.
Definition dac15.h:234
spi_master_t spi
Definition dac15.h:238
dac15_master_io_t read_f
Definition dac15.h:245
float vref
Definition dac15.h:247
dac15_drv_t drv_sel
Definition dac15.h:242
dac15_master_io_t write_f
Definition dac15.h:244
i2c_master_t i2c
Definition dac15.h:237
digital_out_t rst
Definition dac15.h:235
uint8_t slave_address
Definition dac15.h:240
pin_name_t chip_select
Definition dac15.h:241