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
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
66#define DAC3_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
75#define DAC3_RETVAL uint8_t
76
77#define DAC3_OK 0x00
78#define DAC3_INIT_ERROR 0xFF
85#define DAC3_RESET 0x06
86#define DAC3_WAKE_UP 0x09
87#define DAC3_VOLATILE_MEM 0x40
88#define DAC3_VOLATILE_ALL_MEM 0x60
89#define DAC3_VOLATILE_CONF 0x80
92 // End group macro
93// --------------------------------------------------------------- PUBLIC TYPES
102typedef enum
103{
105 VDD = 0,
110
111} dac3_vrl_t;
112
116typedef enum
117{
125 PD_500
126
128
132typedef enum
133{
137 GAIN_2x
138
140
151
155typedef struct
156{
157 // Modules
158
159 i2c_master_t i2c;
160
161 // ctx variable
162
165
166} dac3_t;
167
171typedef struct
172{
173 // Communication gpio pins
174
175 pin_name_t scl;
176 pin_name_t sda;
177
178 // static variable
179
181 uint32_t i2c_speed;
182 uint8_t i2c_address;
183
184} dac3_cfg_t;
185
186 // End types group
187// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
188
194#ifdef __cplusplus
195extern "C"{
196#endif
197
207
216
225void dac3_set_out_voltage ( dac3_t *ctx, uint16_t output );
226
235void dac3_send_command ( dac3_t *ctx, uint8_t cmd );
236
246void dac3_write_all_mem ( dac3_t *ctx, uint16_t value );
247
248#ifdef __cplusplus
249}
250#endif
251#endif // _DAC3_H_
252
253 // End public_function group
255
256// ------------------------------------------------------------------------- END
#define DAC3_RETVAL
Definition dac3.h:75
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:117
dac3_gain_t
Gain configuration enumeration.
Definition dac3.h:133
dac3_vrl_t
VRL configuration enumeration.
Definition dac3.h:103
@ PD_1
Definition dac3.h:121
@ NORMAL
Definition dac3.h:119
@ PD_100
Definition dac3.h:123
@ PD_500
Definition dac3.h:125
@ GAIN_1x
Definition dac3.h:135
@ GAIN_2x
Definition dac3.h:137
@ VREF_UNBUFFERED
Definition dac3.h:107
@ VDD
Definition dac3.h:105
@ VREF_BUFFERED
Definition dac3.h:109
Click configuration structure definition.
Definition dac3.h:172
uint32_t i2c_speed
Definition dac3.h:181
dac3_conf_t dac_cfg
Definition dac3.h:180
pin_name_t scl
Definition dac3.h:175
pin_name_t sda
Definition dac3.h:176
uint8_t i2c_address
Definition dac3.h:182
DAC configuration object.
Definition dac3.h:145
dac3_gain_t gain
Definition dac3.h:148
dac3_pd_t power
Definition dac3.h:147
dac3_vrl_t vrl
Definition dac3.h:146
Click ctx object definition.
Definition dac3.h:156
i2c_master_t i2c
Definition dac3.h:159
dac3_conf_t dac_cfg
Definition dac3.h:163
uint8_t slave_address
Definition dac3.h:164