Go to the documentation of this file.
35 #include "mikrosdk_version.h"
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
69 #define DAC18_REG_NOP 0x00
70 #define DAC18_REG_DAC0_VOUT_CMP_CONFIG 0x15
71 #define DAC18_REG_DAC1_VOUT_CMP_CONFIG 0x03
72 #define DAC18_REG_COMMON_CONFIG 0x1F
73 #define DAC18_REG_COMMON_TRIGGER 0x20
74 #define DAC18_REG_FUNCTION_TRIGGER 0x21
75 #define DAC18_REG_GENERAL_STATUS 0x22
76 #define DAC18_REG_DEVICE_MODE_CONFIG 0x25
77 #define DAC18_REG_INTERFACE_CONFIG 0x26
78 #define DAC18_REG_STATE_MACHINE_CONFIG 0x27
79 #define DAC18_REG_SRAM_CONFIG 0x2B
80 #define DAC18_REG_SRAM_DATA 0x2C
86 #define DAC18_SRAM_REG_FUNCTION_CONFIG 0x20
87 #define DAC18_SRAM_REG_FUNCTION_MAX 0x21
88 #define DAC18_SRAM_REG_FUNCTION_MIN 0x22
89 #define DAC18_SRAM_REG_GPI_DEBOUNCE 0x23
90 #define DAC18_SRAM_REG_VOUT_DATA_0 0x24
91 #define DAC18_SRAM_REG_VOUT_DATA_1 0x25
92 #define DAC18_SRAM_REG_VOUT_DATA_2 0x26
93 #define DAC18_SRAM_REG_VOUT_DATA_3 0x27
94 #define DAC18_SRAM_REG_VOUT_DATA_4 0x28
95 #define DAC18_SRAM_REG_VOUT_DATA_5 0x29
96 #define DAC18_SRAM_REG_VOUT_DATA_6 0x2A
97 #define DAC18_SRAM_REG_VOUT_DATA_7 0x2B
98 #define DAC18_SRAM_REG_PWM_FREQUENCY_ERROR 0x9E
116 #define DAC18_MODE_CONFIGURATION 0
117 #define DAC18_MODE_STANDALONE 1
123 #define DAC18_DACX_VOUT_CFG_GAIN_BITMASK 0x1C00u
124 #define DAC18_DACX_VOUT_CFG_GAIN_X1 0x0400u
125 #define DAC18_DACX_VOUT_CFG_GAIN_X1_5 0x0800u
126 #define DAC18_DACX_VOUT_CFG_GAIN_X2 0x0C00u
127 #define DAC18_DACX_VOUT_CFG_GAIN_X3 0x1000u
128 #define DAC18_DACX_VOUT_CFG_GAIN_X4 0x1400u
129 #define DAC18_DACX_VOUT_CFG_CMPX_OD_EN 0x0010u
130 #define DAC18_DACX_VOUT_CFG_CMPX_OUT_EN 0x0008u
131 #define DAC18_DACX_VOUT_CFG_CMPX_HIZ_IN_DIS 0x0004u
132 #define DAC18_DACX_VOUT_CFG_CMPX_INV_EN 0x0002u
133 #define DAC18_DACX_VOUT_CFG_CMPX_EN 0x0001u
139 #define DAC18_COMMON_CFG_DEFAULT 0x03F9u
140 #define DAC18_COMMON_CFG_DEV_LOCK 0x4000u
141 #define DAC18_COMMON_CFG_EN_INT_REF 0x1000u
142 #define DAC18_COMMON_CFG_VOUT0_BITMASK 0x0C00u
143 #define DAC18_COMMON_CFG_VOUT0_PDN 0x0000u
144 #define DAC18_COMMON_CFG_VOUT0_10KOHM 0x0400u
145 #define DAC18_COMMON_CFG_VOUT0_100KOHM 0x0800u
146 #define DAC18_COMMON_CFG_VOUT0_HIZ 0x0C00u
147 #define DAC18_COMMON_CFG_VOUT1_BITMASK 0x0060u
148 #define DAC18_COMMON_CFG_VOUT1_PDN 0x0000u
149 #define DAC18_COMMON_CFG_VOUT1_10KOHM 0x0040u
150 #define DAC18_COMMON_CFG_VOUT1_100KOHM 0x0020u
151 #define DAC18_COMMON_CFG_VOUT1_HIZ 0x0060u
157 #define DAC18_COMMON_TRG_DEV_LOCK 0x5000u
158 #define DAC18_COMMON_TRG_RESET 0x0A00u
159 #define DAC18_COMMON_TRG_NVM_PROG 0x0002u
160 #define DAC18_COMMON_TRG_NVM_RELOAD 0x0001u
166 #define DAC18_FUNCTION_TRG_START 0x0001u
167 #define DAC18_FUNCTION_TRG_STOP 0x0000u
173 #define DAC18_GEN_STATUS_NVM_CRC_FAIL_INT 0x8000u
174 #define DAC18_GEN_STATUS_NVM_CRC_FAIL_USER 0x4000u
175 #define DAC18_GEN_STATUS_DAC_0_BUSY 0x1000u
176 #define DAC18_GEN_STATUS_DAC_1_BUSY 0x0200u
177 #define DAC18_GEN_STATUS_NVM_BUSY 0x0100u
178 #define DAC18_GEN_STATUS_DEVICE_ID_BITMASK 0x00FCu
179 #define DAC18_GEN_STATUS_DEVICE_ID 0x001Au
180 #define DAC18_GEN_STATUS_VERSION_ID_BITMASK 0x0003u
181 #define DAC18_GEN_STATUS_VERSION_ID 0x0000u
187 #define DAC18_DEV_MODE_CFG_DEFAULT 0x8000u
188 #define DAC18_DEV_MODE_CFG_EN 0x0000u
189 #define DAC18_DEV_MODE_CFG_DIS 0x2000u
190 #define DAC18_DEV_MODE_CFG_SM_IO_EN 0x0040u
196 #define DAC18_STATE_M_CFG_SM_ABORT 0x0004u
197 #define DAC18_STATE_M_CFG_SM_START 0x0002u
198 #define DAC18_STATE_M_CFG_SM_EN 0x0001u
199 #define DAC18_STATE_M_CFG_SM_STOP 0x0000u
205 #define DAC18_FUN_CFG_F_SEL_TRIANGULAR 0x00
206 #define DAC18_FUN_CFG_F_SEL_SAWTOOTH 0x01
207 #define DAC18_FUN_CFG_F_SEL_INV_SAWTOOTH 0x02
208 #define DAC18_FUN_CFG_F_SEL_DISABLE 0x07
209 #define DAC18_FUN_CFG_C_STEP_1LSB 0x00
210 #define DAC18_FUN_CFG_C_STEP_2LSB 0x01
211 #define DAC18_FUN_CFG_C_STEP_3LSB 0x02
212 #define DAC18_FUN_CFG_C_STEP_4LSB 0x03
213 #define DAC18_FUN_CFG_C_STEP_6LSB 0x04
214 #define DAC18_FUN_CFG_C_STEP_8LSB 0x05
215 #define DAC18_FUN_CFG_C_STEP_16LSB 0x06
216 #define DAC18_FUN_CFG_C_STEP_32LSB 0x07
217 #define DAC18_FUN_CFG_T_STEP_INVALID 0x00
218 #define DAC18_FUN_CFG_T_STEP_4_US 0x01
219 #define DAC18_FUN_CFG_T_STEP_8_US 0x02
220 #define DAC18_FUN_CFG_T_STEP_12_US 0x03
221 #define DAC18_FUN_CFG_T_STEP_18_US 0x04
222 #define DAC18_FUN_CFG_T_STEP_27_04_US 0x05
223 #define DAC18_FUN_CFG_T_STEP_40_48_US 0x06
224 #define DAC18_FUN_CFG_T_STEP_60_72_US 0x07
225 #define DAC18_FUN_CFG_T_STEP_91_12_US 0x08
226 #define DAC18_FUN_CFG_T_STEP_136_72_US 0x09
227 #define DAC18_FUN_CFG_T_STEP_239_2_US 0x0A
228 #define DAC18_FUN_CFG_T_STEP_418_64_US 0x0B
229 #define DAC18_FUN_CFG_T_STEP_732_56_US 0x0C
230 #define DAC18_FUN_CFG_T_STEP_1282_US 0x0D
231 #define DAC18_FUN_CFG_T_STEP_2563_92_US 0x0E
232 #define DAC18_FUN_CFG_T_STEP_5127_92_US 0x0F
238 #define DAC18_DAC_CODE_MAX_DEFAULT 0x05AAu
239 #define DAC18_DAC_CODE_MIN_DEFAULT 0x00C8u
240 #define DAC18_DAC_CODE_12BIT_MAX 0x0FFFu
246 #define DAC18_GPI_DEBOUNCE_50_MS 50.0f
247 #define DAC18_GPI_DEBOUNCE_MAX 10485.7f
248 #define DAC18_GPI_DEBOUNCE_SENS 0.16f
254 #define DAC18_LUT_DEFAULT_VOUT_DATA_0 0xA1C0u
255 #define DAC18_LUT_DEFAULT_VOUT_DATA_1 0x8E40u
256 #define DAC18_LUT_DEFAULT_VOUT_DATA_2 0x7AC0u
257 #define DAC18_LUT_DEFAULT_VOUT_DATA_3 0x6740u
258 #define DAC18_LUT_DEFAULT_VOUT_DATA_4 0x5380u
259 #define DAC18_LUT_DEFAULT_VOUT_DATA_5 0x4000u
260 #define DAC18_LUT_DEFAULT_VOUT_DATA_6 0x2C80u
261 #define DAC18_LUT_DEFAULT_VOUT_DATA_7 0x18C0u
268 #define DAC18_DEVICE_ADDRESS_GND 0x48
269 #define DAC18_DEVICE_ADDRESS_VCC 0x49
287 #define DAC18_MAP_MIKROBUS( cfg, mikrobus ) \
288 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
289 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
290 cfg.gp2 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
291 cfg.mod = MIKROBUS( mikrobus, MIKROBUS_RST ); \
292 cfg.gp1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
293 cfg.gp0 = MIKROBUS( mikrobus, MIKROBUS_INT )
DAC 18 Click configuration object.
Definition: dac18.h:325
@ DAC18_ERROR
Definition: dac18.h:346
err_t dac18_set_dac_code(dac18_t *ctx, uint16_t max_dc, uint16_t min_dc)
DAC 18 set DAC code function.
uint8_t i2c_address
Definition: dac18.h:335
pin_name_t gp0
Definition: dac18.h:332
digital_in_t gp0
Definition: dac18.h:310
dac18_return_value_t
DAC 18 Click return value data.
Definition: dac18.h:344
pin_name_t gp2
Definition: dac18.h:329
digital_out_t mod
Definition: dac18.h:305
i2c_master_t i2c
Definition: dac18.h:313
err_t dac18_generic_write(dac18_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
DAC 18 I2C writing function.
uint8_t dac18_get_gp0(dac18_t *ctx)
DAC 18 get GP0 pin state function.
err_t dac18_init(dac18_t *ctx, dac18_cfg_t *cfg)
DAC 18 initialization function.
pin_name_t gp1
Definition: dac18.h:331
@ DAC18_OK
Definition: dac18.h:345
err_t dac18_register_write(dac18_t *ctx, uint8_t reg, uint16_t data_in)
DAC 18 register writing function.
uint8_t dac18_get_gp2(dac18_t *ctx)
DAC 18 get GP2 pin state function.
digital_in_t gp2
Definition: dac18.h:308
uint8_t slave_address
Definition: dac18.h:316
err_t dac18_generic_read(dac18_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
DAC 18 I2C reading function.
err_t dac18_register_read(dac18_t *ctx, uint8_t reg, uint16_t *data_out)
DAC 18 register reading function.
pin_name_t sda
Definition: dac18.h:327
uint8_t dac18_get_gp1(dac18_t *ctx)
DAC 18 get GP1 pin state function.
void dac18_set_mode(dac18_t *ctx, uint8_t mode)
DAC 18 set operation mode function.
void dac18_cfg_setup(dac18_cfg_t *cfg)
DAC 18 configuration object setup function.
pin_name_t scl
Definition: dac18.h:326
pin_name_t mod
Definition: dac18.h:330
uint32_t i2c_speed
Definition: dac18.h:334
void dac18_get_gpi_status(dac18_t *ctx, uint8_t *gpi_status)
DAC 18 get GPI status function.
digital_in_t gp1
Definition: dac18.h:309
DAC 18 Click context object.
Definition: dac18.h:303
err_t dac18_default_cfg(dac18_t *ctx)
DAC 18 default configuration function.
err_t dac18_set_debounce_delay(dac18_t *ctx, float delay_ms)
DAC 18 set debounce delay function.
err_t dac18_cfg_pwm_out(dac18_t *ctx, uint8_t f_sel, uint8_t c_step, uint8_t t_step)
DAC 18 PWM OUT0 configuration function.