ozone3 2.0.0.0
ozone3.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 OZONE3_H
29#define OZONE3_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_i2c_master.h"
38
39
60#define OZONE3_REG_STATUS 0x00
61#define OZONE3_REG_LOCK 0x01
62#define OZONE3_REG_TIACN 0x10
63#define OZONE3_REG_REFCN 0x11
64#define OZONE3_REG_MODECN 0x12
65 // ozone3_reg
67
87#define OZONE3_WRITE_MODE 0x00
88#define OZONE3_READ_ONLY_MODE 0x01
89
94#define OZONE3_RES_TIA_EXT 0x00
95#define OZONE3_RES_TIA_2750_Ohm 0x04
96#define OZONE3_RES_TIA_3500_Ohm 0x08
97#define OZONE3_RES_TIA_7K_Ohm 0x0C
98#define OZONE3_RES_TIA_14K_Ohm 0x10
99#define OZONE3_RES_TIA_35K_Ohm 0x14
100#define OZONE3_RES_TIA_120K_Ohm 0x18
101#define OZONE3_RES_TIA_350K_Ohm 0x1C
102#define OZONE3_RES_LOAD_10_Ohm 0x00
103#define OZONE3_RES_LOAD_33_Ohm 0x01
104#define OZONE3_RES_LOAD_50_Ohm 0x02
105#define OZONE3_RES_LOAD_100_Ohm 0x03
106
111#define OZONE3_VREF_INT 0x00
112#define OZONE3_VREF_EXT 0x80
113#define OZONE3_PERCENTS_INT_ZERO_20 0x00
114#define OZONE3_PERCENTS_INT_ZERO_50 0x20
115#define OZONE3_PERCENTS_INT_ZERO_67 0x40
116#define OZONE3_INT_ZERO_BYPASSED 0x60
117#define OZONE3_BIAS_POL_NEGATIVE 0x00
118#define OZONE3_BIAS_POL_POSITIVE 0x10
119#define OZONE3_PERCENTS_BIAS_0 0x00
120#define OZONE3_PERCENTS_BIAS_1 0x01
121#define OZONE3_PERCENTS_BIAS_2 0x02
122#define OZONE3_PERCENTS_BIAS_4 0x03
123#define OZONE3_PERCENTS_BIAS_6 0x04
124#define OZONE3_PERCENTS_BIAS_8 0x05
125#define OZONE3_PERCENTS_BIAS_10 0x06
126#define OZONE3_PERCENTS_BIAS_12 0x07
127#define OZONE3_PERCENTS_BIAS_14 0x08
128#define OZONE3_PERCENTS_BIAS_16 0x09
129#define OZONE3_PERCENTS_BIAS_18 0x0A
130#define OZONE3_PERCENTS_BIAS_20 0x0B
131#define OZONE3_PERCENTS_BIAS_22 0x0C
132#define OZONE3_PERCENTS_BIAS_24 0x0D
133#define OZONE3_FET_DIS 0x00
134#define OZONE3_FET_EN 0x80
135#define OZONE3_DEEP_SLEEP_MODE 0x00
136#define OZONE3_LEAD_MODE_2 0x01
137#define OZONE3_STANDBY_MODE 0x02
138#define OZONE3_LEAD_MODE_3 0x03
139#define OZONE3_TEMP_MODE_TIA_OFF 0x06
140#define OZONE3_TEMP_MODE_TIA_ON 0x07
141#define OZONE3_DEVICE_ENABLE 0x00
142#define OZONE3_DEVICE_DISABLE 0x01
143
149#define OZONE3_SET_DEV_ADDR 0x48
150#define OZONE3_ADC_DEVICE_ADDR 0x4D
151 // ozone3_set
153
168#define OZONE3_MAP_MIKROBUS( cfg, mikrobus ) \
169 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
170 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
171 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
172 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST )
173 // ozone3_map // ozone3
176
181typedef struct
182{
183 // Output pins
184
185 digital_out_t rst;
187 // Input pins
188
189 digital_in_t an;
191 // Modules
192
193 i2c_master_t i2c;
195 // I2C slave address
196
199} ozone3_t;
200
205typedef struct
206{
207 pin_name_t scl;
208 pin_name_t sda;
210 pin_name_t an;
211 pin_name_t rst;
213 uint32_t i2c_speed;
214 uint8_t i2c_address;
217
222typedef enum
223{
225 OZONE3_ERROR = -1
226
228
247
264err_t ozone3_init ( ozone3_t *ctx, ozone3_cfg_t *cfg );
265
282
300err_t ozone3_generic_write ( ozone3_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
301
319err_t ozone3_generic_read ( ozone3_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
320
336err_t ozone3_enable ( ozone3_t *ctx, uint8_t state );
337
355err_t ozone3_write_byte ( ozone3_t *ctx, uint8_t reg, uint8_t dev_data );
356
372uint8_t ozone3_read_byte ( ozone3_t *ctx, uint8_t reg );
373
388uint16_t ozone3_read_adc ( ozone3_t *ctx );
389
404
419
420#ifdef __cplusplus
421}
422#endif
423#endif // OZONE3_H
424 // ozone3
426
427// ------------------------------------------------------------------------ END
err_t ozone3_default_cfg(ozone3_t *ctx)
Ozone 3 default configuration function.
err_t ozone3_generic_write(ozone3_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Ozone 3 I2C writing function.
err_t ozone3_enable(ozone3_t *ctx, uint8_t state)
Ozone 3 enable function.
err_t ozone3_init(ozone3_t *ctx, ozone3_cfg_t *cfg)
Ozone 3 initialization function.
uint16_t ozone3_read_adc(ozone3_t *ctx)
Ozone 3 read ADC function.
err_t ozone3_write_byte(ozone3_t *ctx, uint8_t reg, uint8_t dev_data)
Ozone 3 write byte function.
float ozone3_get_o3_ppm(ozone3_t *ctx)
Ozone 3 get O3 ppm function.
uint8_t ozone3_read_byte(ozone3_t *ctx, uint8_t reg)
Ozone 3 read byte function.
void ozone3_wait_ready(ozone3_t *ctx)
Ozone 3 wait ready function.
void ozone3_cfg_setup(ozone3_cfg_t *cfg)
Ozone 3 configuration object setup function.
err_t ozone3_generic_read(ozone3_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Ozone 3 I2C reading function.
ozone3_return_value_t
Ozone 3 Click return value data.
Definition: ozone3.h:223
@ OZONE3_OK
Definition: ozone3.h:224
@ OZONE3_ERROR
Definition: ozone3.h:225
Ozone 3 Click configuration object.
Definition: ozone3.h:206
uint32_t i2c_speed
Definition: ozone3.h:213
pin_name_t scl
Definition: ozone3.h:207
pin_name_t sda
Definition: ozone3.h:208
pin_name_t rst
Definition: ozone3.h:211
pin_name_t an
Definition: ozone3.h:210
uint8_t i2c_address
Definition: ozone3.h:214
Ozone 3 Click context object.
Definition: ozone3.h:182
i2c_master_t i2c
Definition: ozone3.h:193
digital_in_t an
Definition: ozone3.h:189
digital_out_t rst
Definition: ozone3.h:185
uint8_t slave_address
Definition: ozone3.h:197