ezocarrierph 2.1.0.0
ezocarrierph.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 EZOCARRIERPH_H
29#define EZOCARRIERPH_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52#include "drv_uart.h"
53
74#define EZOCARRIERPH_CMD_BAUD "Baud"
75#define EZOCARRIERPH_CMD_CONT_READ "C"
76#define EZOCARRIERPH_CMD_CAL "Cal"
77#define EZOCARRIERPH_CMD_EXPORT "Export"
78#define EZOCARRIERPH_CMD_FACTORY "Factory"
79#define EZOCARRIERPH_CMD_FIND "Find"
80#define EZOCARRIERPH_CMD_DEV_INFO "i"
81#define EZOCARRIERPH_CMD_I2C "I2C"
82#define EZOCARRIERPH_CMD_IMPORT "Import"
83#define EZOCARRIERPH_CMD_LED "L"
84#define EZOCARRIERPH_CMD_NAME "Name"
85#define EZOCARRIERPH_CMD_EXTENDED_PH "pHext"
86#define EZOCARRIERPH_CMD_PROTOCOL_LOCK "Plock"
87#define EZOCARRIERPH_CMD_SINGLE_READ "R"
88#define EZOCARRIERPH_CMD_SLEEP "Sleep"
89#define EZOCARRIERPH_CMD_SLOPE "Slope"
90#define EZOCARRIERPH_CMD_STATUS "Status"
91#define EZOCARRIERPH_CMD_TEMP_COMPENSATION "T"
92#define EZOCARRIERPH_CMD_RESP_CODES "*OK"
93#define EZOCARRIERPH_CMD_END_COMMAND "\r"
94
99#define EZOCARRIERPH_RSP_OK "*OK"
100#define EZOCARRIERPH_RSP_ERROR "*ER"
101#define EZOCARRIERPH_RSP_OVER_VOLT "*OV"
102#define EZOCARRIERPH_RSP_UNDER_VOLT "*UV"
103#define EZOCARRIERPH_RSP_RESET "*RS"
104#define EZOCARRIERPH_RSP_READY "*RE"
105#define EZOCARRIERPH_RSP_SLEEP "*SL"
106#define EZOCARRIERPH_RSP_WAKE_UP "*WA"
107
113#define EZOCARRIERPH_TX_DRV_BUFFER_SIZE 100
114#define EZOCARRIERPH_RX_DRV_BUFFER_SIZE 300
115
116 // ezocarrierph_cmd
117
123#define EZOCARRIERPH_DEVICE_ADDRESS 0x61
124
139#define EZOCARRIERPH_MAP_MIKROBUS( cfg, mikrobus ) \
140 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
141 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
142 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
143 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX );
144
145 // ezocarrierph_map
146 // ezocarrierph
147
158
163typedef struct
164{
165 // Modules
166 uart_t uart;
167 i2c_master_t i2c;
169 // Buffers
170 uint8_t uart_rx_buffer[ EZOCARRIERPH_RX_DRV_BUFFER_SIZE ];
171 uint8_t uart_tx_buffer[ EZOCARRIERPH_TX_DRV_BUFFER_SIZE ];
178
183typedef struct
184{
185 // Communication gpio pins
186 pin_name_t rx_pin;
187 pin_name_t tx_pin;
188 pin_name_t scl;
189 pin_name_t sda;
191 // Static variable
192 uint32_t baud_rate;
194 uart_data_bits_t data_bit;
195 uart_parity_t parity_bit;
196 uart_stop_bits_t stop_bit;
197 uint32_t i2c_speed;
198 uint8_t i2c_address;
202
214
231
247
262
275err_t ezocarrierph_generic_write ( ezocarrierph_t *ctx, uint8_t *data_in, uint16_t len );
276
289err_t ezocarrierph_generic_read ( ezocarrierph_t *ctx, uint8_t *data_out, uint16_t len );
290
291
301void ezocarrierph_send_cmd ( ezocarrierph_t *ctx, uint8_t *cmd );
302
313void ezocarrierph_send_cmd_with_par ( ezocarrierph_t *ctx, uint8_t *cmd, uint8_t *param_buf );
314
324void ezocarrierph_send_cmd_check ( ezocarrierph_t *ctx, uint8_t *cmd );
325
326#ifdef __cplusplus
327}
328#endif
329#endif // EZOCARRIERPH_H
330
331 // ezocarrierph
332
333// ------------------------------------------------------------------------ END
ezocarrierph_drv_t
EZO Carrier pH Click driver selector.
Definition ezocarrierph.h:153
@ EZOCARRIERPH_DRV_SEL_UART
Definition ezocarrierph.h:155
@ EZOCARRIERPH_DRV_SEL_I2C
Definition ezocarrierph.h:154
ezocarrierph_return_value_t
EZO Carrier pH Click return value data.
Definition ezocarrierph.h:208
@ EZOCARRIERPH_ERROR_TIMEOUT
Definition ezocarrierph.h:211
@ EZOCARRIERPH_OK
Definition ezocarrierph.h:209
@ EZOCARRIERPH_ERROR
Definition ezocarrierph.h:210
#define EZOCARRIERPH_TX_DRV_BUFFER_SIZE
EZO Carrier pH driver buffer size.
Definition ezocarrierph.h:113
#define EZOCARRIERPH_RX_DRV_BUFFER_SIZE
Definition ezocarrierph.h:114
void ezocarrierph_send_cmd(ezocarrierph_t *ctx, uint8_t *cmd)
Send command function.
err_t ezocarrierph_generic_write(ezocarrierph_t *ctx, uint8_t *data_in, uint16_t len)
EZO Carrier pH data writing function.
err_t ezocarrierph_generic_read(ezocarrierph_t *ctx, uint8_t *data_out, uint16_t len)
EZO Carrier pH data reading function.
err_t ezocarrierph_init(ezocarrierph_t *ctx, ezocarrierph_cfg_t *cfg)
EZO Carrier pH initialization function.
void ezocarrierph_cfg_setup(ezocarrierph_cfg_t *cfg)
EZO Carrier pH configuration object setup function.
void ezocarrierph_drv_interface_sel(ezocarrierph_cfg_t *cfg, ezocarrierph_drv_t drv_sel)
EZO Carrier pH driver interface setup function.
void ezocarrierph_send_cmd_check(ezocarrierph_t *ctx, uint8_t *cmd)
Check the sent command.
void ezocarrierph_send_cmd_with_par(ezocarrierph_t *ctx, uint8_t *cmd, uint8_t *param_buf)
Send command function with parameter.
EZO Carrier pH Click configuration object.
Definition ezocarrierph.h:184
uint32_t baud_rate
Definition ezocarrierph.h:192
uint32_t i2c_speed
Definition ezocarrierph.h:197
bool uart_blocking
Definition ezocarrierph.h:193
uart_data_bits_t data_bit
Definition ezocarrierph.h:194
pin_name_t tx_pin
Definition ezocarrierph.h:187
pin_name_t rx_pin
Definition ezocarrierph.h:186
uart_stop_bits_t stop_bit
Definition ezocarrierph.h:196
pin_name_t scl
Definition ezocarrierph.h:188
ezocarrierph_drv_t drv_sel
Definition ezocarrierph.h:199
uart_parity_t parity_bit
Definition ezocarrierph.h:195
pin_name_t sda
Definition ezocarrierph.h:189
uint8_t i2c_address
Definition ezocarrierph.h:198
EZO Carrier pH Click context object.
Definition ezocarrierph.h:164
uart_t uart
Definition ezocarrierph.h:166
i2c_master_t i2c
Definition ezocarrierph.h:167
uint8_t slave_address
Definition ezocarrierph.h:173
ezocarrierph_drv_t drv_sel
Definition ezocarrierph.h:175