ezocarrierorp 2.1.0.0
ezocarrierorp.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 EZOCARRIERORP_H
29#define EZOCARRIERORP_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 EZOCARRIERORP_CMD_BAUD "Baud"
75#define EZOCARRIERORP_CMD_CONT_READ "C"
76#define EZOCARRIERORP_CMD_CAL "Cal"
77#define EZOCARRIERORP_CMD_EXPORT "Export"
78#define EZOCARRIERORP_CMD_FACTORY "Factory"
79#define EZOCARRIERORP_CMD_FIND "Find"
80#define EZOCARRIERORP_CMD_DEV_INFO "i"
81#define EZOCARRIERORP_CMD_I2C "I2C"
82#define EZOCARRIERORP_CMD_IMPORT "Import"
83#define EZOCARRIERORP_CMD_LED "L"
84#define EZOCARRIERORP_CMD_NAME "Name"
85#define EZOCARRIERORP_CMD_PROTOCOL_LOCK "Plock"
86#define EZOCARRIERORP_CMD_SINGLE_READ "R"
87#define EZOCARRIERORP_CMD_SLEEP "Sleep"
88#define EZOCARRIERORP_CMD_STATUS "Status"
89#define EZOCARRIERORP_CMD_RESP_CODES "*OK"
90#define EZOCARRIERORP_CMD_END_COMMAND "\r"
91
96#define EZOCARRIERORP_RSP_OK "*OK"
97#define EZOCARRIERORP_RSP_ERROR "*ER"
98#define EZOCARRIERORP_RSP_OVER_VOLT "*OV"
99#define EZOCARRIERORP_RSP_UNDER_VOLT "*UV"
100#define EZOCARRIERORP_RSP_RESET "*RS"
101#define EZOCARRIERORP_RSP_READY "*RE"
102#define EZOCARRIERORP_RSP_SLEEP "*SL"
103#define EZOCARRIERORP_RSP_WAKE_UP "*WA"
104
110#define EZOCARRIERORP_TX_DRV_BUFFER_SIZE 100
111#define EZOCARRIERORP_RX_DRV_BUFFER_SIZE 300
112
113 // ezocarrierorp_cmd
114
120#define EZOCARRIERORP_DEVICE_ADDRESS 0x61
121
136#define EZOCARRIERORP_MAP_MIKROBUS( cfg, mikrobus ) \
137 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
138 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
139 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
140 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX )
141
142 // ezocarrierorp_map
143 // ezocarrierorp
144
155
160typedef struct
161{
162 // Modules
163 uart_t uart;
164 i2c_master_t i2c;
166 // Buffers
167 uint8_t uart_rx_buffer[ EZOCARRIERORP_RX_DRV_BUFFER_SIZE ];
168 uint8_t uart_tx_buffer[ EZOCARRIERORP_TX_DRV_BUFFER_SIZE ];
175
180typedef struct
181{
182 // Communication gpio pins
183 pin_name_t rx_pin;
184 pin_name_t tx_pin;
185 pin_name_t scl;
186 pin_name_t sda;
188 // Static variable
189 uint32_t baud_rate;
191 uart_data_bits_t data_bit;
192 uart_parity_t parity_bit;
193 uart_stop_bits_t stop_bit;
194 uint32_t i2c_speed;
195 uint8_t i2c_address;
199
211
228
244
259
272err_t ezocarrierorp_generic_write ( ezocarrierorp_t *ctx, uint8_t *data_in, uint16_t len );
273
286err_t ezocarrierorp_generic_read ( ezocarrierorp_t *ctx, uint8_t *data_out, uint16_t len );
287
297void ezocarrierorp_send_cmd ( ezocarrierorp_t *ctx, uint8_t *cmd );
298
309void ezocarrierorp_send_cmd_with_par ( ezocarrierorp_t *ctx, uint8_t *cmd, uint8_t *param_buf );
310
321
322#ifdef __cplusplus
323}
324#endif
325#endif // EZOCARRIERORP_H
326
327 // ezocarrierorp
328
329// ------------------------------------------------------------------------ END
ezocarrierorp_drv_t
EZO Carrier EC Click driver selector.
Definition ezocarrierorp.h:150
@ EZOCARRIERORP_DRV_SEL_UART
Definition ezocarrierorp.h:152
@ EZOCARRIERORP_DRV_SEL_I2C
Definition ezocarrierorp.h:151
ezocarrierorp_return_value_t
EZO Carrier ORP Click return value data.
Definition ezocarrierorp.h:205
@ EZOCARRIERORP_ERROR
Definition ezocarrierorp.h:207
@ EZOCARRIERORP_ERROR_TIMEOUT
Definition ezocarrierorp.h:208
@ EZOCARRIERORP_OK
Definition ezocarrierorp.h:206
#define EZOCARRIERORP_RX_DRV_BUFFER_SIZE
Definition ezocarrierorp.h:111
#define EZOCARRIERORP_TX_DRV_BUFFER_SIZE
EZO Carrier ORP driver buffer size.
Definition ezocarrierorp.h:110
err_t ezocarrierorp_init(ezocarrierorp_t *ctx, ezocarrierorp_cfg_t *cfg)
EZO Carrier ORP initialization function.
err_t ezocarrierorp_generic_read(ezocarrierorp_t *ctx, uint8_t *data_out, uint16_t len)
EZO Carrier ORP data reading function.
err_t ezocarrierorp_generic_write(ezocarrierorp_t *ctx, uint8_t *data_in, uint16_t len)
EZO Carrier ORP data writing function.
void ezocarrierorp_cfg_setup(ezocarrierorp_cfg_t *cfg)
EZO Carrier ORP configuration object setup function.
void ezocarrierorp_drv_interface_sel(ezocarrierorp_cfg_t *cfg, ezocarrierorp_drv_t drv_sel)
EZO Carrier EC driver interface setup function.
void ezocarrierorp_send_cmd_check(ezocarrierorp_t *ctx, uint8_t *cmd)
Check the sent command.
void ezocarrierorp_send_cmd_with_par(ezocarrierorp_t *ctx, uint8_t *cmd, uint8_t *param_buf)
Send command function with parameter.
void ezocarrierorp_send_cmd(ezocarrierorp_t *ctx, uint8_t *cmd)
Send command function.
EZO Carrier ORP Click configuration object.
Definition ezocarrierorp.h:181
uint32_t baud_rate
Definition ezocarrierorp.h:189
ezocarrierorp_drv_t drv_sel
Definition ezocarrierorp.h:196
uint32_t i2c_speed
Definition ezocarrierorp.h:194
bool uart_blocking
Definition ezocarrierorp.h:190
uart_data_bits_t data_bit
Definition ezocarrierorp.h:191
pin_name_t tx_pin
Definition ezocarrierorp.h:184
pin_name_t rx_pin
Definition ezocarrierorp.h:183
uart_stop_bits_t stop_bit
Definition ezocarrierorp.h:193
pin_name_t scl
Definition ezocarrierorp.h:185
uart_parity_t parity_bit
Definition ezocarrierorp.h:192
pin_name_t sda
Definition ezocarrierorp.h:186
uint8_t i2c_address
Definition ezocarrierorp.h:195
EZO Carrier ORP Click context object.
Definition ezocarrierorp.h:161
ezocarrierorp_drv_t drv_sel
Definition ezocarrierorp.h:172
uart_t uart
Definition ezocarrierorp.h:163
i2c_master_t i2c
Definition ezocarrierorp.h:164
uint8_t slave_address
Definition ezocarrierorp.h:170