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
35#include "mikrosdk_version.h"
36
37#ifdef __GNUC__
38#if mikroSDK_GET_VERSION < 20800ul
39#include "rcu_delays.h"
40#else
41#include "delays.h"
42#endif
43#endif
44
45#include "drv_digital_out.h"
46#include "drv_digital_in.h"
47#include "drv_i2c_master.h"
48#include "drv_uart.h"
49
70#define EZOCARRIERORP_CMD_BAUD "Baud"
71#define EZOCARRIERORP_CMD_CONT_READ "C"
72#define EZOCARRIERORP_CMD_CAL "Cal"
73#define EZOCARRIERORP_CMD_EXPORT "Export"
74#define EZOCARRIERORP_CMD_FACTORY "Factory"
75#define EZOCARRIERORP_CMD_FIND "Find"
76#define EZOCARRIERORP_CMD_DEV_INFO "i"
77#define EZOCARRIERORP_CMD_I2C "I2C"
78#define EZOCARRIERORP_CMD_IMPORT "Import"
79#define EZOCARRIERORP_CMD_LED "L"
80#define EZOCARRIERORP_CMD_NAME "Name"
81#define EZOCARRIERORP_CMD_PROTOCOL_LOCK "Plock"
82#define EZOCARRIERORP_CMD_SINGLE_READ "R"
83#define EZOCARRIERORP_CMD_SLEEP "Sleep"
84#define EZOCARRIERORP_CMD_STATUS "Status"
85#define EZOCARRIERORP_CMD_RESP_CODES "*OK"
86#define EZOCARRIERORP_CMD_END_COMMAND "\r"
87
92#define EZOCARRIERORP_RSP_OK "*OK"
93#define EZOCARRIERORP_RSP_ERROR "*ER"
94#define EZOCARRIERORP_RSP_OVER_VOLT "*OV"
95#define EZOCARRIERORP_RSP_UNDER_VOLT "*UV"
96#define EZOCARRIERORP_RSP_RESET "*RS"
97#define EZOCARRIERORP_RSP_READY "*RE"
98#define EZOCARRIERORP_RSP_SLEEP "*SL"
99#define EZOCARRIERORP_RSP_WAKE_UP "*WA"
100
106#define EZOCARRIERORP_TX_DRV_BUFFER_SIZE 100
107#define EZOCARRIERORP_RX_DRV_BUFFER_SIZE 300
108 // ezocarrierorp_cmd
110
116#define EZOCARRIERORP_DEVICE_ADDRESS 0x61
117
132#define EZOCARRIERORP_MAP_MIKROBUS( cfg, mikrobus ) \
133 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
134 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
135 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
136 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX )
137 // ezocarrierorp_map // ezocarrierorp
140
145typedef enum
146{
151
156typedef struct
157{
158 // Modules
159 uart_t uart;
160 i2c_master_t i2c;
162 // Buffers
163 uint8_t uart_rx_buffer[ EZOCARRIERORP_RX_DRV_BUFFER_SIZE ];
164 uint8_t uart_tx_buffer[ EZOCARRIERORP_TX_DRV_BUFFER_SIZE ];
171
176typedef struct
177{
178 // Communication gpio pins
179 pin_name_t rx_pin;
180 pin_name_t tx_pin;
181 pin_name_t scl;
182 pin_name_t sda;
184 // Static variable
185 uint32_t baud_rate;
187 uart_data_bits_t data_bit;
188 uart_parity_t parity_bit;
189 uart_stop_bits_t stop_bit;
190 uint32_t i2c_speed;
191 uint8_t i2c_address;
195
200typedef enum
201{
205
207
224
240
255
268err_t ezocarrierorp_generic_write ( ezocarrierorp_t *ctx, uint8_t *data_in, uint16_t len );
269
282err_t ezocarrierorp_generic_read ( ezocarrierorp_t *ctx, uint8_t *data_out, uint16_t len );
283
293void ezocarrierorp_send_cmd ( ezocarrierorp_t *ctx, uint8_t *cmd );
294
305void ezocarrierorp_send_cmd_with_par ( ezocarrierorp_t *ctx, uint8_t *cmd, uint8_t *param_buf );
306
317
318#ifdef __cplusplus
319}
320#endif
321#endif // EZOCARRIERORP_H
322 // ezocarrierorp
324
325// ------------------------------------------------------------------------ END
ezocarrierorp_drv_t
EZO Carrier EC Click driver selector.
Definition: ezocarrierorp.h:146
@ EZOCARRIERORP_DRV_SEL_UART
Definition: ezocarrierorp.h:148
@ EZOCARRIERORP_DRV_SEL_I2C
Definition: ezocarrierorp.h:147
ezocarrierorp_return_value_t
EZO Carrier ORP Click return value data.
Definition: ezocarrierorp.h:201
@ EZOCARRIERORP_ERROR
Definition: ezocarrierorp.h:203
@ EZOCARRIERORP_ERROR_TIMEOUT
Definition: ezocarrierorp.h:204
@ EZOCARRIERORP_OK
Definition: ezocarrierorp.h:202
#define EZOCARRIERORP_RX_DRV_BUFFER_SIZE
Definition: ezocarrierorp.h:107
#define EZOCARRIERORP_TX_DRV_BUFFER_SIZE
EZO Carrier ORP driver buffer size.
Definition: ezocarrierorp.h:106
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:177
uint32_t baud_rate
Definition: ezocarrierorp.h:185
ezocarrierorp_drv_t drv_sel
Definition: ezocarrierorp.h:192
uint32_t i2c_speed
Definition: ezocarrierorp.h:190
bool uart_blocking
Definition: ezocarrierorp.h:186
uart_data_bits_t data_bit
Definition: ezocarrierorp.h:187
pin_name_t tx_pin
Definition: ezocarrierorp.h:180
pin_name_t rx_pin
Definition: ezocarrierorp.h:179
uart_stop_bits_t stop_bit
Definition: ezocarrierorp.h:189
pin_name_t scl
Definition: ezocarrierorp.h:181
uart_parity_t parity_bit
Definition: ezocarrierorp.h:188
pin_name_t sda
Definition: ezocarrierorp.h:182
uint8_t i2c_address
Definition: ezocarrierorp.h:191
EZO Carrier ORP Click context object.
Definition: ezocarrierorp.h:157
ezocarrierorp_drv_t drv_sel
Definition: ezocarrierorp.h:168
uart_t uart
Definition: ezocarrierorp.h:159
i2c_master_t i2c
Definition: ezocarrierorp.h:160
uint8_t slave_address
Definition: ezocarrierorp.h:166