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_spi_master.h"
74#define DAC13_REG_INTERFACE_CONFIG_A 0x00
75#define DAC13_REG_INTERFACE_CONFIG_B 0x01
76#define DAC13_REG_DEVICE_CONFIG 0x02
77#define DAC13_REG_CHIP_TYPE 0x03
78#define DAC13_REG_PRODUCT_ID_L 0x04
79#define DAC13_REG_PRODUCT_ID_H 0x05
80#define DAC13_REG_CHIP_GRADE 0x06
81#define DAC13_REG_SCRATCH_PAD 0x0A
82#define DAC13_REG_SPI_REVISION 0x0B
83#define DAC13_REG_VENDOR_L 0x0C
84#define DAC13_REG_VENDOR_H 0x0D
85#define DAC13_REG_STREAM_MODE 0x0E
86#define DAC13_REG_TRANSFER_REGISTER 0x0F
87#define DAC13_REG_INTERFACE_CONFIG_C 0x10
88#define DAC13_REG_INTERFACE_STATUS_A 0x11
89#define DAC13_REG_INTERFACE_CONFIG_D 0x14
90#define DAC13_REG_REFERENCE_CONFIG 0x15
91#define DAC13_REG_ERR_ALARM_MASK 0x16
92#define DAC13_REG_ERR_STATUS 0x17
93#define DAC13_REG_POWERDOWN_CONFIG 0x18
94#define DAC13_REG_CH0_OUTPUT_RANGE 0x19
95#define DAC13_REG_HW_LDAC_16B 0x28
96#define DAC13_REG_CH0_DAC_16B 0x2A
97#define DAC13_REG_DAC_PAGE_16B 0x2E
98#define DAC13_REG_CH_SELECT_16B 0x2F
99#define DAC13_REG_INPUT_PAGE_16B 0x31
100#define DAC13_REG_SW_LDAC_16B 0x32
101#define DAC13_REG_CH0_INPUT_16B 0x34
102#define DAC13_REG_HW_LDAC_24B 0x37
103#define DAC13_REG_CH0_DAC_24B 0x3A
104#define DAC13_REG_DAC_PAGE_24B 0x40
105#define DAC13_REG_CH_SELECT_24B 0x41
106#define DAC13_REG_INPUT_PAGE_24B 0x44
107#define DAC13_REG_SW_LDAC_24B 0x45
108#define DAC13_REG_CH0_INPUT_24B 0x48
126#define DAC13_SPI_READ_BIT 0x80
132#define DAC13_PRODUCT_ID 0x400B
133#define DAC13_VENDOR_ID 0x0456
139#define DAC13_IDUMP_FASTMODE 0x40
140#define DAC13_REFERENCE_VOLTAGE_SEL_INT 0x00
141#define DAC13_REFERENCE_VOLTAGE_SEL_INT_OUT 0x01
142#define DAC13_REFERENCE_VOLTAGE_SEL_EXT 0x02
143#define DAC13_REFERENCE_VOLTAGE_SEL_MASK 0x03
149#define DAC13_OUT_RANGE_0_TO_2p5V 0x00
150#define DAC13_OUT_RANGE_0_TO_5V 0x01
151#define DAC13_OUT_RANGE_0_TO_10V 0x02
152#define DAC13_OUT_RANGE_NEG_5_TO_5V 0x03
153#define DAC13_OUT_RANGE_NEG_2p5_TO_7p5V 0x04
159#define DAC13_VZS_OUT_RANGE_0_TO_2p5V ( -0.197f )
160#define DAC13_VFS_OUT_RANGE_0_TO_2p5V ( 2.701f )
161#define DAC13_VZS_OUT_RANGE_0_TO_5V ( -0.077f )
162#define DAC13_VFS_OUT_RANGE_0_TO_5V ( 5.077f )
163#define DAC13_VZS_OUT_RANGE_0_TO_10V ( -0.162f )
164#define DAC13_VFS_OUT_RANGE_0_TO_10V ( 10.164f )
165#define DAC13_VZS_OUT_RANGE_NEG_5_TO_5V ( -5.164f )
166#define DAC13_VFS_OUT_RANGE_NEG_5_TO_5V ( 5.162f )
167#define DAC13_VZS_OUT_RANGE_NEG_2p5_TO_7p5V ( -2.663f )
168#define DAC13_VFS_OUT_RANGE_NEG_2p5_TO_7p5V ( 7.663f )
169#define DAC13_DAC_RES_16BIT 0xFFFF
179#define DAC13_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
180#define DAC13_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
198#define DAC13_MAP_MIKROBUS( cfg, mikrobus ) \
199 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
200 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
201 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
202 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
203 cfg.ldc = MIKROBUS( mikrobus, MIKROBUS_AN ); \
204 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
205 cfg.alt = MIKROBUS( mikrobus, MIKROBUS_INT )
dac13_return_value_t
DAC 13 Click return value data.
Definition dac13.h:262
@ DAC13_OK
Definition dac13.h:263
@ DAC13_ERROR
Definition dac13.h:264
void dac13_set_ldc_pin(dac13_t *ctx, uint8_t state)
DAC 13 set ldc pin function.
err_t dac13_set_dac_value(dac13_t *ctx, uint16_t dac_value)
DAC 13 set dac value function.
err_t dac13_read_register(dac13_t *ctx, uint8_t reg, uint8_t *data_out)
DAC 13 read register function.
err_t dac13_default_cfg(dac13_t *ctx)
DAC 13 default configuration function.
uint8_t dac13_get_alert_pin(dac13_t *ctx)
DAC 13 get alert pin function.
void dac13_reset_device(dac13_t *ctx)
DAC 13 reset device function.
err_t dac13_read_register_16b(dac13_t *ctx, uint8_t reg, uint16_t *data_out)
DAC 13 read register 16b function.
err_t dac13_set_output_range(dac13_t *ctx, uint8_t out_range)
DAC 13 set output range function.
err_t dac13_init(dac13_t *ctx, dac13_cfg_t *cfg)
DAC 13 initialization function.
err_t dac13_generic_write(dac13_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
DAC 13 data writing function.
err_t dac13_check_communication(dac13_t *ctx)
DAC 13 check communication function.
void dac13_cfg_setup(dac13_cfg_t *cfg)
DAC 13 configuration object setup function.
err_t dac13_write_register(dac13_t *ctx, uint8_t reg, uint8_t data_in)
DAC 13 write register function.
err_t dac13_generic_read(dac13_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
DAC 13 data reading function.
err_t dac13_write_register_16b(dac13_t *ctx, uint8_t reg, uint16_t data_in)
DAC 13 write register 16b function.
err_t dac13_set_output_voltage(dac13_t *ctx, float voltage)
DAC 13 set output voltage function.
void dac13_set_rst_pin(dac13_t *ctx, uint8_t state)
DAC 13 set rst pin function.
This file contains SPI specific macros, functions, etc.
DAC 13 Click configuration object.
Definition dac13.h:238
pin_name_t alt
Definition dac13.h:248
pin_name_t ldc
Definition dac13.h:246
spi_master_chip_select_polarity_t cs_polarity
Definition dac13.h:253
pin_name_t sck
Definition dac13.h:242
spi_master_mode_t spi_mode
Definition dac13.h:252
pin_name_t mosi
Definition dac13.h:241
uint32_t spi_speed
Definition dac13.h:251
pin_name_t miso
Definition dac13.h:240
pin_name_t rst
Definition dac13.h:247
pin_name_t cs
Definition dac13.h:243
DAC 13 Click context object.
Definition dac13.h:215
spi_master_t spi
Definition dac13.h:224
float v_zero_scale
Definition dac13.h:228
digital_out_t ldc
Definition dac13.h:217
digital_in_t alt
Definition dac13.h:221
float v_full_scale
Definition dac13.h:229
digital_out_t rst
Definition dac13.h:218
pin_name_t chip_select
Definition dac13.h:226