ezocarrierec 2.1.0.0
ezocarrierec.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 EZOCARRIEREC_H
29#define EZOCARRIEREC_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 EZOCARRIEREC_CMD_BAUD "Baud"
75#define EZOCARRIEREC_CMD_CONT_READ "C"
76#define EZOCARRIEREC_CMD_CAL "Cal"
77#define EZOCARRIEREC_CMD_EXPORT "Export"
78#define EZOCARRIEREC_CMD_FACTORY "Factory"
79#define EZOCARRIEREC_CMD_FIND "Find"
80#define EZOCARRIEREC_CMD_DEV_INFO "i"
81#define EZOCARRIEREC_CMD_I2C "I2C"
82#define EZOCARRIEREC_CMD_IMPORT "Import"
83#define EZOCARRIEREC_CMD_SET_PROBE_TYPE "K"
84#define EZOCARRIEREC_CMD_LED "L"
85#define EZOCARRIEREC_CMD_NAME "Name"
86#define EZOCARRIEREC_CMD_PARAMETERS "O"
87#define EZOCARRIEREC_CMD_PROTOCOL_LOCK "Plock"
88#define EZOCARRIEREC_CMD_SINGLE_READ "R"
89#define EZOCARRIEREC_CMD_SLEEP "Sleep"
90#define EZOCARRIEREC_CMD_STATUS "Status"
91#define EZOCARRIEREC_CMD_TEMP_COMPENSATION "T"
92#define EZOCARRIEREC_CMD_TDS "TDS"
93#define EZOCARRIEREC_CMD_RESP_CODES "*OK"
94#define EZOCARRIEREC_CMD_END_COMMAND "\r"
95
100#define EZOCARRIEREC_RSP_OK "*OK"
101#define EZOCARRIEREC_RSP_ERROR "*ER"
102#define EZOCARRIEREC_RSP_OVER_VOLT "*OV"
103#define EZOCARRIEREC_RSP_UNDER_VOLT "*UV"
104#define EZOCARRIEREC_RSP_RESET "*RS"
105#define EZOCARRIEREC_RSP_READY "*RE"
106#define EZOCARRIEREC_RSP_SLEEP "*SL"
107#define EZOCARRIEREC_RSP_WAKE_UP "*WA"
108
114#define EZOCARRIEREC_TX_DRV_BUFFER_SIZE 100
115#define EZOCARRIEREC_RX_DRV_BUFFER_SIZE 300
116
117 // ezocarrierec_cmd
118
124#define EZOCARRIEREC_DEVICE_ADDRESS 0x61
125
140#define EZOCARRIEREC_MAP_MIKROBUS( cfg, mikrobus ) \
141 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
142 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
143 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
144 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX )
145
146 // ezocarrierec_map
147 // ezocarrierec
148
159
164typedef struct
165{
166 // Modules
167 uart_t uart;
168 i2c_master_t i2c;
170 // Buffers
171 uint8_t uart_rx_buffer[ EZOCARRIEREC_RX_DRV_BUFFER_SIZE ];
172 uint8_t uart_tx_buffer[ EZOCARRIEREC_TX_DRV_BUFFER_SIZE ];
179
184typedef struct
185{
186 // Communication gpio pins
187 pin_name_t rx_pin;
188 pin_name_t tx_pin;
189 pin_name_t scl;
190 pin_name_t sda;
192 // Static variable
193 uint32_t baud_rate;
195 uart_data_bits_t data_bit;
196 uart_parity_t parity_bit;
197 uart_stop_bits_t stop_bit;
198 uint32_t i2c_speed;
199 uint8_t i2c_address;
203
215
232
248
263
276err_t ezocarrierec_generic_write ( ezocarrierec_t *ctx, uint8_t *data_in, uint16_t len );
277
290err_t ezocarrierec_generic_read ( ezocarrierec_t *ctx, uint8_t *data_out, uint16_t len );
291
301void ezocarrierec_send_cmd ( ezocarrierec_t *ctx, uint8_t *cmd );
302
313void ezocarrierec_send_cmd_with_par ( ezocarrierec_t *ctx, uint8_t *cmd, uint8_t *param_buf );
314
324void ezocarrierec_send_cmd_check ( ezocarrierec_t *ctx, uint8_t *cmd );
325
326#ifdef __cplusplus
327}
328#endif
329#endif // EZOCARRIEREC_H
330
331 // ezocarrierec
332
333// ------------------------------------------------------------------------ END
ezocarrierec_return_value_t
EZO Carrier EC Click return value data.
Definition ezocarrierec.h:209
@ EZOCARRIEREC_ERROR_TIMEOUT
Definition ezocarrierec.h:212
@ EZOCARRIEREC_ERROR
Definition ezocarrierec.h:211
@ EZOCARRIEREC_OK
Definition ezocarrierec.h:210
ezocarrierec_drv_t
EZO Carrier EC Click driver selector.
Definition ezocarrierec.h:154
@ EZOCARRIEREC_DRV_SEL_I2C
Definition ezocarrierec.h:155
@ EZOCARRIEREC_DRV_SEL_UART
Definition ezocarrierec.h:156
void ezocarrierec_send_cmd(ezocarrierec_t *ctx, uint8_t *cmd)
Send command function.
void ezocarrierec_cfg_setup(ezocarrierec_cfg_t *cfg)
EZO Carrier EC configuration object setup function.
err_t ezocarrierec_init(ezocarrierec_t *ctx, ezocarrierec_cfg_t *cfg)
EZO Carrier EC initialization function.
void ezocarrierec_send_cmd_with_par(ezocarrierec_t *ctx, uint8_t *cmd, uint8_t *param_buf)
Send command function with parameter.
void ezocarrierec_send_cmd_check(ezocarrierec_t *ctx, uint8_t *cmd)
Check the sent command.
err_t ezocarrierec_generic_write(ezocarrierec_t *ctx, uint8_t *data_in, uint16_t len)
EZO Carrier EC data writing function.
err_t ezocarrierec_generic_read(ezocarrierec_t *ctx, uint8_t *data_out, uint16_t len)
EZO Carrier EC data reading function.
void ezocarrierec_drv_interface_sel(ezocarrierec_cfg_t *cfg, ezocarrierec_drv_t drv_sel)
EZO Carrier EC driver interface setup function.
EZO Carrier EC Click configuration object.
Definition ezocarrierec.h:185
uint32_t baud_rate
Definition ezocarrierec.h:193
uint32_t i2c_speed
Definition ezocarrierec.h:198
bool uart_blocking
Definition ezocarrierec.h:194
uart_data_bits_t data_bit
Definition ezocarrierec.h:195
pin_name_t tx_pin
Definition ezocarrierec.h:188
pin_name_t rx_pin
Definition ezocarrierec.h:187
uart_stop_bits_t stop_bit
Definition ezocarrierec.h:197
pin_name_t scl
Definition ezocarrierec.h:189
ezocarrierec_drv_t drv_sel
Definition ezocarrierec.h:200
uart_parity_t parity_bit
Definition ezocarrierec.h:196
pin_name_t sda
Definition ezocarrierec.h:190
uint8_t i2c_address
Definition ezocarrierec.h:199
EZO Carrier EC Click context object.
Definition ezocarrierec.h:165
uart_t uart
Definition ezocarrierec.h:167
i2c_master_t i2c
Definition ezocarrierec.h:168
uint8_t slave_address
Definition ezocarrierec.h:174
ezocarrierec_drv_t drv_sel
Definition ezocarrierec.h:176