dac3 2.0.0.0
dac3.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef DAC3_H
36#define DAC3_H
37
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40#include "drv_i2c_master.h"
41
42// -------------------------------------------------------------- PUBLIC MACROS
52#define DAC3_MAP_MIKROBUS( cfg, mikrobus ) \
53 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
54 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
61#define DAC3_RETVAL uint8_t
62
63#define DAC3_OK 0x00
64#define DAC3_INIT_ERROR 0xFF
71#define DAC3_RESET 0x06
72#define DAC3_WAKE_UP 0x09
73#define DAC3_VOLATILE_MEM 0x40
74#define DAC3_VOLATILE_ALL_MEM 0x60
75#define DAC3_VOLATILE_CONF 0x80 // End group macro
79// --------------------------------------------------------------- PUBLIC TYPES
88typedef enum
89{
91 VDD = 0,
96
98
102typedef enum
103{
111 PD_500
112
114
118typedef enum
119{
123 GAIN_2x
124
126
130typedef struct
131{
135
137
141typedef struct
142{
143 // Modules
144
145 i2c_master_t i2c;
146
147 // ctx variable
148
151
152} dac3_t;
153
157typedef struct
158{
159 // Communication gpio pins
160
161 pin_name_t scl;
162 pin_name_t sda;
163
164 // static variable
165
167 uint32_t i2c_speed;
168 uint8_t i2c_address;
169
170} dac3_cfg_t;
171 // End types group
173// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
174
180#ifdef __cplusplus
181extern "C"{
182#endif
183
193
202
211void dac3_set_out_voltage ( dac3_t *ctx, uint16_t output );
212
221void dac3_send_command ( dac3_t *ctx, uint8_t cmd );
222
232void dac3_write_all_mem ( dac3_t *ctx, uint16_t value );
233
234#ifdef __cplusplus
235}
236#endif
237#endif // _DAC3_H_
238 // End public_function group
241
242// ------------------------------------------------------------------------- END
#define DAC3_RETVAL
Definition: dac3.h:61
void dac3_set_out_voltage(dac3_t *ctx, uint16_t output)
Set output voltage function.
DAC3_RETVAL dac3_init(dac3_t *ctx, dac3_cfg_t *cfg)
Initialization function.
void dac3_cfg_setup(dac3_cfg_t *cfg)
Config Object Initialization function.
void dac3_send_command(dac3_t *ctx, uint8_t cmd)
Send command function.
void dac3_write_all_mem(dac3_t *ctx, uint16_t value)
Send command function.
dac3_pd_t
Power configuration enumeration.
Definition: dac3.h:103
dac3_gain_t
Gain configuration enumeration.
Definition: dac3.h:119
dac3_vrl_t
VRL configuration enumeration.
Definition: dac3.h:89
@ PD_1
Definition: dac3.h:107
@ NORMAL
Definition: dac3.h:105
@ PD_100
Definition: dac3.h:109
@ PD_500
Definition: dac3.h:111
@ GAIN_1x
Definition: dac3.h:121
@ GAIN_2x
Definition: dac3.h:123
@ VREF_UNBUFFERED
Definition: dac3.h:93
@ VDD
Definition: dac3.h:91
@ VREF_BUFFERED
Definition: dac3.h:95
Click configuration structure definition.
Definition: dac3.h:158
uint32_t i2c_speed
Definition: dac3.h:167
dac3_conf_t dac_cfg
Definition: dac3.h:166
pin_name_t scl
Definition: dac3.h:161
pin_name_t sda
Definition: dac3.h:162
uint8_t i2c_address
Definition: dac3.h:168
DAC configuration object.
Definition: dac3.h:131
dac3_gain_t gain
Definition: dac3.h:134
dac3_pd_t power
Definition: dac3.h:133
dac3_vrl_t vrl
Definition: dac3.h:132
Click ctx object definition.
Definition: dac3.h:142
i2c_master_t i2c
Definition: dac3.h:145
dac3_conf_t dac_cfg
Definition: dac3.h:149
uint8_t slave_address
Definition: dac3.h:150