dac2 2.0.0.0
dac2.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 */
32// ----------------------------------------------------------------------------
33
34#ifndef DAC2_H
35#define DAC2_H
36
37#include "drv_digital_out.h"
38#include "drv_digital_in.h"
39#include "drv_spi_master.h"
40
41// -------------------------------------------------------------- PUBLIC MACROS
52#define DAC2_MAP_MIKROBUS( cfg, mikrobus ) \
53 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
54 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
55 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
56 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
57 cfg.clr = MIKROBUS( mikrobus, MIKROBUS_RST );
64#define DAC2_RETVAL uint8_t
65
66#define DAC2_OK 0x00
67#define DAC2_INIT_ERROR 0xFF // End group macro
71
72// --------------------------------------------------------------- PUBLIC TYPES
81typedef struct
82{
83 // Output pins
84
85 digital_out_t clr;
86 digital_out_t cs;
87
88 // Modules
89
90 spi_master_t spi;
91 pin_name_t chip_select;
92
93} dac2_t;
94
98typedef struct
99{
100 // Communication gpio pins
101
102 pin_name_t miso;
103 pin_name_t mosi;
104 pin_name_t sck;
105 pin_name_t cs;
106
107 // Additional gpio pins
108
109 pin_name_t clr;
110
111 // static variable
112
113 uint32_t spi_speed;
114 spi_master_mode_t spi_mode;
115 spi_master_chip_select_polarity_t cs_polarity;
116
117} dac2_cfg_t;
118 // End types group
120
121// ------------------------------------------------------------------ CONSTANTS // End constants group
129
130// ------------------------------------------------------------------ VARIABLES // End variable group
138
139// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
140
145#ifdef __cplusplus
146extern "C"{
147#endif
148
158
168
181(
182 dac2_t *ctx,
183 uint8_t *wr_buf,
184 uint16_t wr_len,
185 uint8_t *rd_buf,
186 uint16_t rd_len
187);
188
197
207
218void dac2_write_output_voltage_procentage ( dac2_t *ctx, uint8_t value_pct );
219
230void dac2_write_output_voltage_data ( dac2_t *ctx, uint16_t value_data );
231
232#ifdef __cplusplus
233}
234#endif
235#endif // _DAC2_H_
236 // End public_function group
239
240// ------------------------------------------------------------------------- END
#define DAC2_RETVAL
Definition: dac2.h:64
void dac2_write_output_voltage_procentage(dac2_t *ctx, uint8_t value_pct)
Procentage generic write function.
void dac2_clr_dac_2_reg(dac2_t *ctx)
Asynchronous Clear Input function.
void dac2_default_cfg(dac2_t *ctx)
Click Default Configuration function.
void dac2_write_output_voltage_data(dac2_t *ctx, uint16_t value_data)
Data generic write function.
void dac2_generic_transfer(dac2_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void dac2_cfg_setup(dac2_cfg_t *cfg)
Config Object Initialization function.
DAC2_RETVAL dac2_init(dac2_t *ctx, dac2_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition: dac2.h:99
pin_name_t clr
Definition: dac2.h:109
spi_master_chip_select_polarity_t cs_polarity
Definition: dac2.h:115
pin_name_t sck
Definition: dac2.h:104
spi_master_mode_t spi_mode
Definition: dac2.h:114
pin_name_t mosi
Definition: dac2.h:103
uint32_t spi_speed
Definition: dac2.h:113
pin_name_t miso
Definition: dac2.h:102
pin_name_t cs
Definition: dac2.h:105
Click ctx object definition.
Definition: dac2.h:82
digital_out_t cs
Definition: dac2.h:86
spi_master_t spi
Definition: dac2.h:90
digital_out_t clr
Definition: dac2.h:85
pin_name_t chip_select
Definition: dac2.h:91