qireceiver 2.0.0.0
qireceiver.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 QIRECEIVER_H
36#define QIRECEIVER_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 QIRECEIVER_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.teop = MIKROBUS( mikrobus, MIKROBUS_AN ); \
70 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
71 cfg.stat = MIKROBUS( mikrobus, MIKROBUS_CS ); \
72 cfg.end = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
73 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
80#define QIRECEIVER_RETVAL uint8_t
81
82#define QIRECEIVER_OK 0x00
83#define QIRECEIVER_INIT_ERROR 0xFF
85 // End group macro
86// -------------------------------------------------------------- PRIVATE MACROS
96#define QIRECEIVER_I2C_ADDR 0x25
104#define QIRECEIVER_VRECT_REG0 0x40
105#define QIRECEIVER_VRECT_REG1 0x41
113#define QIRECEIVER_IOUT_REG2 0x42
114#define QIRECEIVER_IOUT_REG3 0x43
121#define QIRECEIVER_FREQ_REG4 0x44
122#define QIRECEIVER_FREQ_REG5 0x45
130#define QIRECEIVER_REG7 0x47
131#define QIRECEIVER_REG8 0x48
139#define QIRECEIVER_WPC_ID_B0 0x54
140#define QIRECEIVER_WPC_ID_B1 0x55
141#define QIRECEIVER_WPC_ID_B2 0x56
142#define QIRECEIVER_WPC_ID_B3 0x57
143#define QIRECEIVER_WPC_ID_B4 0x58
144#define QIRECEIVER_WPC_ID_B5 0x59
145#define QIRECEIVER_WPC_ID_B6 0x5A
153#define QIRECEIVER_FOD9 0x49
154#define QIRECEIVER_FOD10 0x4A
155#define QIRECEIVER_FOD11 0x4B
156#define QIRECEIVER_FOD12 0x4C
157#define QIRECEIVER_FOD13 0x4D
158#define QIRECEIVER_FOD14 0x4E
159#define QIRECEIVER_FOD15 0x4F
160#define QIRECEIVER_FOD16 0x50
161#define QIRECEIVER_FOD17 0x51
162#define QIRECEIVER_FOD18 0x52
163#define QIRECEIVER_FOD19 0x53
166 // End group macro
167// --------------------------------------------------------------- PUBLIC TYPES
176typedef struct
177{
178 // Output pins
179
180 digital_out_t teop;
181 digital_out_t en;
182 digital_out_t end;
183
184 // Input pins
185
186 digital_in_t stat;
187 digital_in_t int_pin;
188
189 // Modules
190
191 i2c_master_t i2c;
192
193 // ctx variable
194
196
198
202typedef struct
203{
204 // Communication gpio pins
205
206 pin_name_t scl;
207 pin_name_t sda;
208
209 // Additional gpio pins
210
211 pin_name_t teop;
212 pin_name_t en;
213 pin_name_t stat;
214 pin_name_t end;
215 pin_name_t int_pin;
216
217 // static variable
218
219 uint32_t i2c_speed;
220 uint8_t i2c_address;
221
223
224 // End types group
225
226// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
227
233#ifdef __cplusplus
234extern "C"{
235#endif
236
246
256
267void qireceiver_generic_write ( qireceiver_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
268
277void qireceiver_generic_read ( qireceiver_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
278
289
300
311
320
321#ifdef __cplusplus
322}
323#endif
324#endif // _QIRECEIVER_H_
325
326 // End public_function group
328
329// ------------------------------------------------------------------------- END
#define QIRECEIVER_RETVAL
Definition qireceiver.h:80
void qireceiver_dev_enable(qireceiver_t *ctx)
Device enable function.
float qireceiver_read_voltage(qireceiver_t *ctx)
Read Voltage function.
QIRECEIVER_RETVAL qireceiver_init(qireceiver_t *ctx, qireceiver_cfg_t *cfg)
Initialization function.
void qireceiver_generic_write(qireceiver_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
float qireceiver_read_freq(qireceiver_t *ctx)
Read Frequency function.
void qireceiver_generic_read(qireceiver_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
float qireceiver_read_current(qireceiver_t *ctx)
Read Current function.
void qireceiver_cfg_setup(qireceiver_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition qireceiver.h:203
uint32_t i2c_speed
Definition qireceiver.h:219
pin_name_t scl
Definition qireceiver.h:206
pin_name_t en
Definition qireceiver.h:212
pin_name_t int_pin
Definition qireceiver.h:215
pin_name_t end
Definition qireceiver.h:214
pin_name_t sda
Definition qireceiver.h:207
pin_name_t teop
Definition qireceiver.h:211
pin_name_t stat
Definition qireceiver.h:213
uint8_t i2c_address
Definition qireceiver.h:220
Click ctx object definition.
Definition qireceiver.h:177
digital_out_t teop
Definition qireceiver.h:180
digital_in_t stat
Definition qireceiver.h:186
digital_in_t int_pin
Definition qireceiver.h:187
digital_out_t end
Definition qireceiver.h:182
i2c_master_t i2c
Definition qireceiver.h:191
digital_out_t en
Definition qireceiver.h:181
uint8_t slave_address
Definition qireceiver.h:195