mic24055 2.0.0.0
mic24055.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 MIC24055_H
36#define MIC24055_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_spi_master.h"
55
56
57// -------------------------------------------------------------- PUBLIC MACROS
68#define MIC24055_MAP_MIKROBUS( cfg, mikrobus ) \
69 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
70 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
71 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
72 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
73 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
74 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
75 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
82#define MIC24055_RETVAL uint8_t
83
84#define MIC24055_OK 0x00
85#define MIC24055_INIT_ERROR 0xFF
88 // End group macro
89// --------------------------------------------------------------- PUBLIC TYPES
98typedef struct
99{
100 // Output pins
101
102 digital_out_t en;
103 digital_out_t int_pin;
104 digital_out_t cs;
105
106 // Input pins
107
108 digital_in_t an;
109
110 // Modules
111
112 spi_master_t spi;
113 pin_name_t chip_select;
114
115
116} mic24055_t;
117
121typedef struct
122{
123 // Communication gpio pins
124
125 pin_name_t miso;
126 pin_name_t mosi;
127 pin_name_t sck;
128 pin_name_t cs;
129
130 // Additional gpio pins
131
132 pin_name_t an;
133 pin_name_t en;
134 //pin_name_t pwm;
135 pin_name_t int_pin;
136
137 // static variable
138
139 uint32_t spi_speed;
140 spi_master_mode_t spi_mode;
141 spi_master_chip_select_polarity_t cs_polarity;
142
144
145 // End types group
146
147// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
148
153#ifdef __cplusplus
154extern "C"{
155#endif
156
166
175
188(
189 mic24055_t *ctx,
190 uint8_t *wr_buf,
191 uint16_t wr_len,
192 uint8_t *rd_buf,
193 uint16_t rd_len
194);
195
204void mic24055_dac_output ( mic24055_t *ctx, uint16_t value_dac );
205
214void mic24055_set_vout ( mic24055_t *ctx, uint16_t voltage );
215
216#ifdef __cplusplus
217}
218#endif
219#endif // _MIC24055_H_
220
221 // End public_function group
223
224// ------------------------------------------------------------------------- END
#define MIC24055_RETVAL
Definition mic24055.h:82
MIC24055_RETVAL mic24055_init(mic24055_t *ctx, mic24055_cfg_t *cfg)
Initialization function.
void mic24055_set_vout(mic24055_t *ctx, uint16_t voltage)
Set output voltage.
void mic24055_cfg_setup(mic24055_cfg_t *cfg)
Config Object Initialization function.
void mic24055_generic_transfer(mic24055_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void mic24055_dac_output(mic24055_t *ctx, uint16_t value_dac)
Generic transfer function.
Click configuration structure definition.
Definition mic24055.h:122
spi_master_chip_select_polarity_t cs_polarity
Definition mic24055.h:141
pin_name_t sck
Definition mic24055.h:127
spi_master_mode_t spi_mode
Definition mic24055.h:140
pin_name_t mosi
Definition mic24055.h:126
uint32_t spi_speed
Definition mic24055.h:139
pin_name_t en
Definition mic24055.h:133
pin_name_t int_pin
Definition mic24055.h:135
pin_name_t miso
Definition mic24055.h:125
pin_name_t an
Definition mic24055.h:132
pin_name_t cs
Definition mic24055.h:128
Click ctx object definition.
Definition mic24055.h:99
digital_out_t cs
Definition mic24055.h:104
spi_master_t spi
Definition mic24055.h:112
digital_in_t an
Definition mic24055.h:108
digital_out_t int_pin
Definition mic24055.h:103
digital_out_t en
Definition mic24055.h:102
pin_name_t chip_select
Definition mic24055.h:113