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 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_spi_master.h"
41 
42 
43 // -------------------------------------------------------------- PUBLIC MACROS
54 #define MIC33153_MAP_MIKROBUS( cfg, mikrobus ) \
55  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
56  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
57  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
58  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
59  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
60  cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
61  cfg.pg = MIKROBUS( mikrobus, MIKROBUS_INT );
62 
68 #define MIC33153_RETVAL uint8_t
69 
70 #define MIC33153_OK 0x00
71 #define MIC33153_INIT_ERROR 0xFF
72 
78 #define MIC33153_OUT_ENABLE 1
79 #define MIC33153_OUT_DISABLE 0
80 
86 #define MIC33153_MIN_VOLTAGE_800MV 0x0FFF
87 #define MIC33153_VOLTAGE_1000MV 0x0EC0
88 #define MIC33153_VOLTAGE_1500MV 0x0BE0
89 #define MIC33153_VOLTAGE_2000MV 0x08F0
90 #define MIC33153_VOLTAGE_2500MV 0x060F
91 #define MIC33153_VOLTAGE_3000MV 0x0330
92 #define MIC33153_VOLTAGE_3200MV 0x0210
93 #define MIC33153_MAX_VOLTAGE_3550MV 0x0000
94  // End group macro
97 // --------------------------------------------------------------- PUBLIC TYPES
106 typedef struct
107 {
108  // Output pins
109 
110  digital_out_t en;
111  digital_out_t cs;
112 
113  // Input pins
114 
115  digital_in_t an;
116  digital_in_t pg;
117 
118  // Modules
119 
120  spi_master_t spi;
121  pin_name_t chip_select;
122 
123 } mic33153_t;
124 
128 typedef struct
129 {
130  // Communication gpio pins
131 
132  pin_name_t miso;
133  pin_name_t mosi;
134  pin_name_t sck;
135  pin_name_t cs;
136 
137  // Additional gpio pins
138 
139  pin_name_t an;
140  pin_name_t en;
141  pin_name_t pg;
142 
143  // static variable
144 
145  uint32_t spi_speed;
146  uint8_t spi_mode;
147  spi_master_chip_select_polarity_t cs_polarity;
148 
150  // End types group
152 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
153 
158 #ifdef __cplusplus
159 extern "C"{
160 #endif
161 
171 
180 
193 (
194  mic33153_t *ctx,
195  uint8_t *wr_buf,
196  uint16_t wr_len,
197  uint8_t *rd_buf,
198  uint16_t rd_len
199 );
200 
209 void mic33153_write_dac ( mic33153_t *ctx, const uint16_t value_dac );
210 
219 void mic33153_enable_out ( mic33153_t *ctx, uint8_t state );
220 
231 
232 #ifdef __cplusplus
233 }
234 #endif
235 #endif // _MIC33153_H_
236  // End public_function group
239 
240 // ------------------------------------------------------------------------- END
mic33153_cfg_t::sck
pin_name_t sck
Definition: mic33153.h:134
mic33153_cfg_setup
void mic33153_cfg_setup(mic33153_cfg_t *cfg)
Config Object Initialization function.
mic33153_cfg_t
Click configuration structure definition.
Definition: mic33153.h:129
mic33153_t::chip_select
pin_name_t chip_select
Definition: mic33153.h:121
mic33153_t::spi
spi_master_t spi
Definition: mic33153.h:120
mic33153_generic_transfer
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.
mic33153_t
Click ctx object definition.
Definition: mic33153.h:107
mic33153_enable_out
void mic33153_enable_out(mic33153_t *ctx, uint8_t state)
Out enable function.
mic33153_t::pg
digital_in_t pg
Definition: mic33153.h:116
MIC33153_RETVAL
#define MIC33153_RETVAL
Definition: mic33153.h:68
mic33153_cfg_t::spi_mode
uint8_t spi_mode
Definition: mic33153.h:146
mic33153_cfg_t::miso
pin_name_t miso
Definition: mic33153.h:132
mic33153_check_power_good
uint8_t mic33153_check_power_good(mic33153_t *ctx)
Power Good check function.
mic33153_t::en
digital_out_t en
Definition: mic33153.h:110
mic33153_cfg_t::pg
pin_name_t pg
Definition: mic33153.h:141
mic33153_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: mic33153.h:147
mic33153_cfg_t::mosi
pin_name_t mosi
Definition: mic33153.h:133
mic33153_t::an
digital_in_t an
Definition: mic33153.h:115
mic33153_cfg_t::cs
pin_name_t cs
Definition: mic33153.h:135
mic33153_cfg_t::en
pin_name_t en
Definition: mic33153.h:140
mic33153_write_dac
void mic33153_write_dac(mic33153_t *ctx, const uint16_t value_dac)
Write DAC function.
mic33153_init
MIC33153_RETVAL mic33153_init(mic33153_t *ctx, mic33153_cfg_t *cfg)
Initialization function.
mic33153_cfg_t::an
pin_name_t an
Definition: mic33153.h:139
mic33153_cfg_t::spi_speed
uint32_t spi_speed
Definition: mic33153.h:145
mic33153_t::cs
digital_out_t cs
Definition: mic33153.h:111