ezocarrierdo 2.1.0.0
ezocarrierdo.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 EZOCARRIERDO_H
29#define EZOCARRIERDO_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 EZOCARRIERDO_CMD_BAUD "Baud"
75#define EZOCARRIERDO_CMD_CONT_READ "C"
76#define EZOCARRIERDO_CMD_CAL "Cal"
77#define EZOCARRIERDO_CMD_EXPORT "Export"
78#define EZOCARRIERDO_CMD_FACTORY "Factory"
79#define EZOCARRIERDO_CMD_FIND "Find"
80#define EZOCARRIERDO_CMD_DEV_INFO "i"
81#define EZOCARRIERDO_CMD_I2C "I2C"
82#define EZOCARRIERDO_CMD_IMPORT "Import"
83#define EZOCARRIERDO_CMD_LED "L"
84#define EZOCARRIERDO_CMD_NAME "Name"
85#define EZOCARRIERDO_CMD_PARAMETERS "O"
86#define EZOCARRIERDO_CMD_PRES_COMPENSATION "P"
87#define EZOCARRIERDO_CMD_PROTOCOL_LOCK "Plock"
88#define EZOCARRIERDO_CMD_SINGLE_READ "R"
89#define EZOCARRIERDO_CMD_SALINITY_COMPENSATION "S"
90#define EZOCARRIERDO_CMD_SLEEP "Sleep"
91#define EZOCARRIERDO_CMD_STATUS "Status"
92#define EZOCARRIERDO_CMD_TEMP_COMPENSATION "T"
93#define EZOCARRIERDO_CMD_RESP_CODES "*OK"
94#define EZOCARRIERDO_CMD_END_COMMAND "\r"
95
100#define EZOCARRIERDO_RSP_OK "*OK"
101#define EZOCARRIERDO_RSP_ERROR "*ER"
102#define EZOCARRIERDO_RSP_OVER_VOLT "*OV"
103#define EZOCARRIERDO_RSP_UNDER_VOLT "*UV"
104#define EZOCARRIERDO_RSP_RESET "*RS"
105#define EZOCARRIERDO_RSP_READY "*RE"
106#define EZOCARRIERDO_RSP_SLEEP "*SL"
107#define EZOCARRIERDO_RSP_WAKE_UP "*WA"
108
114#define EZOCARRIERDO_TX_DRV_BUFFER_SIZE 100
115#define EZOCARRIERDO_RX_DRV_BUFFER_SIZE 300
116
117 // ezocarrierdo_cmd
118
124#define EZOCARRIERDO_DEVICE_ADDRESS 0x61
125
140#define EZOCARRIERDO_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 // ezocarrierdo_map
147 // ezocarrierdo
148
159
164typedef struct
165{
166 // Modules
167 uart_t uart;
168 i2c_master_t i2c;
170 // Buffers
171 uint8_t uart_rx_buffer[ EZOCARRIERDO_RX_DRV_BUFFER_SIZE ];
172 uint8_t uart_tx_buffer[ EZOCARRIERDO_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 ezocarrierdo_generic_write ( ezocarrierdo_t *ctx, uint8_t *data_in, uint16_t len );
277
290err_t ezocarrierdo_generic_read ( ezocarrierdo_t *ctx, uint8_t *data_out, uint16_t len );
291
301void ezocarrierdo_send_cmd ( ezocarrierdo_t *ctx, uint8_t *cmd );
302
313void ezocarrierdo_send_cmd_with_par ( ezocarrierdo_t *ctx, uint8_t *cmd, uint8_t *param_buf );
314
324void ezocarrierdo_send_cmd_check ( ezocarrierdo_t *ctx, uint8_t *cmd );
325
326#ifdef __cplusplus
327}
328#endif
329#endif // EZOCARRIERDO_H
330
331 // ezocarrierdo
332
333// ------------------------------------------------------------------------ END
ezocarrierdo_return_value_t
EZO Carrier DO Click return value data.
Definition ezocarrierdo.h:209
@ EZOCARRIERDO_ERROR
Definition ezocarrierdo.h:211
@ EZOCARRIERDO_ERROR_TIMEOUT
Definition ezocarrierdo.h:212
@ EZOCARRIERDO_OK
Definition ezocarrierdo.h:210
ezocarrierdo_drv_t
EZO Carrier DO Click driver selector.
Definition ezocarrierdo.h:154
@ EZOCARRIERDO_DRV_SEL_UART
Definition ezocarrierdo.h:156
@ EZOCARRIERDO_DRV_SEL_I2C
Definition ezocarrierdo.h:155
#define EZOCARRIERDO_RX_DRV_BUFFER_SIZE
Definition ezocarrierdo.h:115
#define EZOCARRIERDO_TX_DRV_BUFFER_SIZE
EZO Carrier DO driver buffer size.
Definition ezocarrierdo.h:114
void ezocarrierdo_send_cmd(ezocarrierdo_t *ctx, uint8_t *cmd)
Send command function.
err_t ezocarrierdo_generic_read(ezocarrierdo_t *ctx, uint8_t *data_out, uint16_t len)
EZO Carrier DO data reading function.
err_t ezocarrierdo_generic_write(ezocarrierdo_t *ctx, uint8_t *data_in, uint16_t len)
EZO Carrier DO data writing function.
void ezocarrierdo_send_cmd_check(ezocarrierdo_t *ctx, uint8_t *cmd)
Check the sent command.
void ezocarrierdo_send_cmd_with_par(ezocarrierdo_t *ctx, uint8_t *cmd, uint8_t *param_buf)
Send command function with parameter.
err_t ezocarrierdo_init(ezocarrierdo_t *ctx, ezocarrierdo_cfg_t *cfg)
EZO Carrier DO initialization function.
void ezocarrierdo_cfg_setup(ezocarrierdo_cfg_t *cfg)
EZO Carrier DO configuration object setup function.
void ezocarrierdo_drv_interface_sel(ezocarrierdo_cfg_t *cfg, ezocarrierdo_drv_t drv_sel)
EZO Carrier DO driver interface setup function.
EZO Carrier DO Click configuration object.
Definition ezocarrierdo.h:185
ezocarrierdo_drv_t drv_sel
Definition ezocarrierdo.h:200
uint32_t baud_rate
Definition ezocarrierdo.h:193
uint32_t i2c_speed
Definition ezocarrierdo.h:198
bool uart_blocking
Definition ezocarrierdo.h:194
uart_data_bits_t data_bit
Definition ezocarrierdo.h:195
pin_name_t tx_pin
Definition ezocarrierdo.h:188
pin_name_t rx_pin
Definition ezocarrierdo.h:187
uart_stop_bits_t stop_bit
Definition ezocarrierdo.h:197
pin_name_t scl
Definition ezocarrierdo.h:189
uart_parity_t parity_bit
Definition ezocarrierdo.h:196
pin_name_t sda
Definition ezocarrierdo.h:190
uint8_t i2c_address
Definition ezocarrierdo.h:199
EZO Carrier DO Click context object.
Definition ezocarrierdo.h:165
ezocarrierdo_drv_t drv_sel
Definition ezocarrierdo.h:176
uart_t uart
Definition ezocarrierdo.h:167
i2c_master_t i2c
Definition ezocarrierdo.h:168
uint8_t slave_address
Definition ezocarrierdo.h:174