qirx
2.0.0.0
cmake
qirx
lib_qirx
include
qirx.h
Go to the documentation of this file.
1
/****************************************************************************
2
** Copyright (C) 2020 MikroElektronika d.o.o.
3
** Contact: https://www.mikroe.com/contact
4
**
5
** Permission is hereby granted, free of charge, to any person obtaining a copy
6
** of this software and associated documentation files (the "Software"), to deal
7
** in the Software without restriction, including without limitation the rights
8
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
** copies of the Software, and to permit persons to whom the Software is
10
** furnished to do so, subject to the following conditions:
11
** The above copyright notice and this permission notice shall be
12
** included in all copies or substantial portions of the Software.
13
**
14
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16
** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19
** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
** USE OR OTHER DEALINGS IN THE SOFTWARE.
21
****************************************************************************/
22
28
#ifndef QIRX_H
29
#define QIRX_H
30
31
#ifdef __cplusplus
32
extern
"C"
{
33
#endif
34
35
#include "drv_digital_out.h"
36
#include "drv_digital_in.h"
37
#include "drv_i2c_master.h"
38
59
#define QIRX_RESOLUTION 4096
60
#define QIRX_12_BIT_DATA 0x0FFF
61
66
#define QIRX_SET_DEV_ADDR 0x4D
67
// qirx_set
69
84
#define QIRX_MAP_MIKROBUS( cfg, mikrobus ) \
85
cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
86
cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
87
// qirx_map // qirx
90
95
typedef
struct
96
{
97
// Modules
98
i2c_master_t
i2c
;
100
// I2C slave address
101
uint8_t
slave_address
;
103
}
qirx_t
;
104
109
typedef
struct
110
{
111
pin_name_t
scl
;
112
pin_name_t
sda
;
114
uint32_t
i2c_speed
;
115
uint8_t
i2c_address
;
117
}
qirx_cfg_t
;
118
123
typedef
enum
124
{
125
QIRX_OK
= 0,
126
QIRX_ERROR
= -1
127
128
}
qirx_return_value_t
;
129
145
void
qirx_cfg_setup
(
qirx_cfg_t
*cfg );
146
161
err_t
qirx_init
(
qirx_t
*ctx,
qirx_cfg_t
*cfg );
162
170
uint16_t
qirx_read_data
(
qirx_t
*ctx );
171
180
uint16_t
qirx_read_voltage
(
qirx_t
*ctx, uint16_t
v_ref
);
181
182
#ifdef __cplusplus
183
}
184
#endif
185
#endif // QIRX_H
186
// qirx
188
189
// ------------------------------------------------------------------------ END
qirx_cfg_setup
void qirx_cfg_setup(qirx_cfg_t *cfg)
Qi RX configuration object setup function.
qirx_cfg_t::i2c_speed
uint32_t i2c_speed
Definition:
qirx.h:114
qirx_t::i2c
i2c_master_t i2c
Definition:
qirx.h:98
qirx_t
Qi RX Click context object.
Definition:
qirx.h:96
qirx_cfg_t::sda
pin_name_t sda
Definition:
qirx.h:112
QIRX_ERROR
@ QIRX_ERROR
Definition:
qirx.h:126
qirx_cfg_t::scl
pin_name_t scl
Definition:
qirx.h:111
qirx_cfg_t
Qi RX Click configuration object.
Definition:
qirx.h:110
v_ref
uint16_t v_ref
Definition:
main.c:29
qirx_read_voltage
uint16_t qirx_read_voltage(qirx_t *ctx, uint16_t v_ref)
Read voltage function.
qirx_t::slave_address
uint8_t slave_address
Definition:
qirx.h:101
qirx_cfg_t::i2c_address
uint8_t i2c_address
Definition:
qirx.h:115
qirx_return_value_t
qirx_return_value_t
Qi RX Click return value data.
Definition:
qirx.h:124
QIRX_OK
@ QIRX_OK
Definition:
qirx.h:125
qirx_read_data
uint16_t qirx_read_data(qirx_t *ctx)
Read data function.
qirx_init
err_t qirx_init(qirx_t *ctx, qirx_cfg_t *cfg)
Qi RX initialization function.
Generated by
1.8.20