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
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_i2c_master.h"
38#include "drv_uart.h"
39
60#define EZOCARRIERPH_CMD_BAUD "Baud"
61#define EZOCARRIERPH_CMD_CONT_READ "C"
62#define EZOCARRIERPH_CMD_CAL "Cal"
63#define EZOCARRIERPH_CMD_EXPORT "Export"
64#define EZOCARRIERPH_CMD_FACTORY "Factory"
65#define EZOCARRIERPH_CMD_FIND "Find"
66#define EZOCARRIERPH_CMD_DEV_INFO "i"
67#define EZOCARRIERPH_CMD_I2C "I2C"
68#define EZOCARRIERPH_CMD_IMPORT "Import"
69#define EZOCARRIERPH_CMD_LED "L"
70#define EZOCARRIERPH_CMD_NAME "Name"
71#define EZOCARRIERPH_CMD_EXTENDED_PH "pHext"
72#define EZOCARRIERPH_CMD_PROTOCOL_LOCK "Plock"
73#define EZOCARRIERPH_CMD_SINGLE_READ "R"
74#define EZOCARRIERPH_CMD_SLEEP "Sleep"
75#define EZOCARRIERPH_CMD_SLOPE "Slope"
76#define EZOCARRIERPH_CMD_STATUS "Status"
77#define EZOCARRIERPH_CMD_TEMP_COMPENSATION "T"
78#define EZOCARRIERPH_CMD_RESP_CODES "*OK"
79#define EZOCARRIERPH_CMD_END_COMMAND "\r"
80
85#define EZOCARRIERPH_RSP_OK "*OK"
86#define EZOCARRIERPH_RSP_ERROR "*ER"
87#define EZOCARRIERPH_RSP_OVER_VOLT "*OV"
88#define EZOCARRIERPH_RSP_UNDER_VOLT "*UV"
89#define EZOCARRIERPH_RSP_RESET "*RS"
90#define EZOCARRIERPH_RSP_READY "*RE"
91#define EZOCARRIERPH_RSP_SLEEP "*SL"
92#define EZOCARRIERPH_RSP_WAKE_UP "*WA"
93
99#define EZOCARRIERPH_TX_DRV_BUFFER_SIZE 100
100#define EZOCARRIERPH_RX_DRV_BUFFER_SIZE 300
101 // ezocarrierph_cmd
103
109#define EZOCARRIERPH_DEVICE_ADDRESS 0x61
110
125#define EZOCARRIERPH_MAP_MIKROBUS( cfg, mikrobus ) \
126 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
127 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
128 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
129 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX );
130 // ezocarrierph_map // ezocarrierph
133
138typedef enum
139{
144
149typedef struct
150{
151 // Modules
152 uart_t uart;
153 i2c_master_t i2c;
155 // Buffers
156 uint8_t uart_rx_buffer[ EZOCARRIERPH_RX_DRV_BUFFER_SIZE ];
157 uint8_t uart_tx_buffer[ EZOCARRIERPH_TX_DRV_BUFFER_SIZE ];
164
169typedef struct
170{
171 // Communication gpio pins
172 pin_name_t rx_pin;
173 pin_name_t tx_pin;
174 pin_name_t scl;
175 pin_name_t sda;
177 // Static variable
178 uint32_t baud_rate;
180 uart_data_bits_t data_bit;
181 uart_parity_t parity_bit;
182 uart_stop_bits_t stop_bit;
183 uint32_t i2c_speed;
184 uint8_t i2c_address;
188
193typedef enum
194{
198
200
217
233
248
261err_t ezocarrierph_generic_write ( ezocarrierph_t *ctx, uint8_t *data_in, uint16_t len );
262
275err_t ezocarrierph_generic_read ( ezocarrierph_t *ctx, uint8_t *data_out, uint16_t len );
276
277
287void ezocarrierph_send_cmd ( ezocarrierph_t *ctx, uint8_t *cmd );
288
299void ezocarrierph_send_cmd_with_par ( ezocarrierph_t *ctx, uint8_t *cmd, uint8_t *param_buf );
300
310void ezocarrierph_send_cmd_check ( ezocarrierph_t *ctx, uint8_t *cmd );
311
312#ifdef __cplusplus
313}
314#endif
315#endif // EZOCARRIERPH_H
316 // ezocarrierph
318
319// ------------------------------------------------------------------------ END
ezocarrierph_drv_t
EZO Carrier pH Click driver selector.
Definition: ezocarrierph.h:139
@ EZOCARRIERPH_DRV_SEL_UART
Definition: ezocarrierph.h:141
@ EZOCARRIERPH_DRV_SEL_I2C
Definition: ezocarrierph.h:140
ezocarrierph_return_value_t
EZO Carrier pH Click return value data.
Definition: ezocarrierph.h:194
@ EZOCARRIERPH_ERROR_TIMEOUT
Definition: ezocarrierph.h:197
@ EZOCARRIERPH_OK
Definition: ezocarrierph.h:195
@ EZOCARRIERPH_ERROR
Definition: ezocarrierph.h:196
#define EZOCARRIERPH_TX_DRV_BUFFER_SIZE
EZO Carrier pH driver buffer size.
Definition: ezocarrierph.h:99
#define EZOCARRIERPH_RX_DRV_BUFFER_SIZE
Definition: ezocarrierph.h:100
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:170
uint32_t baud_rate
Definition: ezocarrierph.h:178
uint32_t i2c_speed
Definition: ezocarrierph.h:183
bool uart_blocking
Definition: ezocarrierph.h:179
uart_data_bits_t data_bit
Definition: ezocarrierph.h:180
pin_name_t tx_pin
Definition: ezocarrierph.h:173
pin_name_t rx_pin
Definition: ezocarrierph.h:172
uart_stop_bits_t stop_bit
Definition: ezocarrierph.h:182
pin_name_t scl
Definition: ezocarrierph.h:174
ezocarrierph_drv_t drv_sel
Definition: ezocarrierph.h:185
uart_parity_t parity_bit
Definition: ezocarrierph.h:181
pin_name_t sda
Definition: ezocarrierph.h:175
uint8_t i2c_address
Definition: ezocarrierph.h:184
EZO Carrier pH Click context object.
Definition: ezocarrierph.h:150
uart_t uart
Definition: ezocarrierph.h:152
i2c_master_t i2c
Definition: ezocarrierph.h:153
uint8_t slave_address
Definition: ezocarrierph.h:159
ezocarrierph_drv_t drv_sel
Definition: ezocarrierph.h:161