mic33153 2.0.0.0
mic33153.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 MIC33153_H
36#define MIC33153_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 MIC33153_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.pg = MIKROBUS( mikrobus, MIKROBUS_INT );
82#define MIC33153_RETVAL uint8_t
83
84#define MIC33153_OK 0x00
85#define MIC33153_INIT_ERROR 0xFF
92#define MIC33153_OUT_ENABLE 1
93#define MIC33153_OUT_DISABLE 0
100#define MIC33153_MIN_VOLTAGE_800MV 0x0FFF
101#define MIC33153_VOLTAGE_1000MV 0x0EC0
102#define MIC33153_VOLTAGE_1500MV 0x0BE0
103#define MIC33153_VOLTAGE_2000MV 0x08F0
104#define MIC33153_VOLTAGE_2500MV 0x060F
105#define MIC33153_VOLTAGE_3000MV 0x0330
106#define MIC33153_VOLTAGE_3200MV 0x0210
107#define MIC33153_MAX_VOLTAGE_3550MV 0x0000
110 // End group macro
111// --------------------------------------------------------------- PUBLIC TYPES
120typedef struct
121{
122 // Output pins
123
124 digital_out_t en;
125 digital_out_t cs;
126
127 // Input pins
128
129 digital_in_t an;
130 digital_in_t pg;
131
132 // Modules
133
134 spi_master_t spi;
135 pin_name_t chip_select;
136
137} mic33153_t;
138
142typedef struct
143{
144 // Communication gpio pins
145
146 pin_name_t miso;
147 pin_name_t mosi;
148 pin_name_t sck;
149 pin_name_t cs;
150
151 // Additional gpio pins
152
153 pin_name_t an;
154 pin_name_t en;
155 pin_name_t pg;
156
157 // static variable
158
159 uint32_t spi_speed;
160 uint8_t spi_mode;
161 spi_master_chip_select_polarity_t cs_polarity;
162
164
165 // End types group
166// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
167
172#ifdef __cplusplus
173extern "C"{
174#endif
175
185
194
207(
208 mic33153_t *ctx,
209 uint8_t *wr_buf,
210 uint16_t wr_len,
211 uint8_t *rd_buf,
212 uint16_t rd_len
213);
214
223void mic33153_write_dac ( mic33153_t *ctx, const uint16_t value_dac );
224
233void mic33153_enable_out ( mic33153_t *ctx, uint8_t state );
234
245
246#ifdef __cplusplus
247}
248#endif
249#endif // _MIC33153_H_
250
251 // End public_function group
253
254// ------------------------------------------------------------------------- END
#define MIC33153_RETVAL
Definition mic33153.h:82
MIC33153_RETVAL mic33153_init(mic33153_t *ctx, mic33153_cfg_t *cfg)
Initialization function.
void mic33153_generic_transfer(mic33153_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void mic33153_enable_out(mic33153_t *ctx, uint8_t state)
Out enable function.
void mic33153_cfg_setup(mic33153_cfg_t *cfg)
Config Object Initialization function.
void mic33153_write_dac(mic33153_t *ctx, const uint16_t value_dac)
Write DAC function.
uint8_t mic33153_check_power_good(mic33153_t *ctx)
Power Good check function.
Click configuration structure definition.
Definition mic33153.h:143
uint8_t spi_mode
Definition mic33153.h:160
spi_master_chip_select_polarity_t cs_polarity
Definition mic33153.h:161
pin_name_t sck
Definition mic33153.h:148
pin_name_t mosi
Definition mic33153.h:147
uint32_t spi_speed
Definition mic33153.h:159
pin_name_t en
Definition mic33153.h:154
pin_name_t miso
Definition mic33153.h:146
pin_name_t pg
Definition mic33153.h:155
pin_name_t an
Definition mic33153.h:153
pin_name_t cs
Definition mic33153.h:149
Click ctx object definition.
Definition mic33153.h:121
digital_out_t cs
Definition mic33153.h:125
spi_master_t spi
Definition mic33153.h:134
digital_in_t an
Definition mic33153.h:129
digital_out_t en
Definition mic33153.h:124
pin_name_t chip_select
Definition mic33153.h:135
digital_in_t pg
Definition mic33153.h:130