ezocarrierrtd 2.1.0.0
ezocarrierrtd.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 EZOCARRIERRTD_H
29#define EZOCARRIERRTD_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 EZOCARRIERRTD_CMD_BAUD "Baud"
75#define EZOCARRIERRTD_CMD_CONT_READ "C"
76#define EZOCARRIERRTD_CMD_CAL "Cal"
77#define EZOCARRIERRTD_CMD_DATA_LOGGER "D"
78#define EZOCARRIERRTD_CMD_EXPORT "Export"
79#define EZOCARRIERRTD_CMD_FACTORY "Factory"
80#define EZOCARRIERRTD_CMD_FIND "Find"
81#define EZOCARRIERRTD_CMD_DEV_INFO "i"
82#define EZOCARRIERRTD_CMD_I2C "I2C"
83#define EZOCARRIERRTD_CMD_IMPORT "Import"
84#define EZOCARRIERRTD_CMD_LED "L"
85#define EZOCARRIERRTD_CMD_MEM_RECALL "M"
86#define EZOCARRIERRTD_CMD_NAME "Name"
87#define EZOCARRIERRTD_CMD_PROTOCOL_LOCK "Plock"
88#define EZOCARRIERRTD_CMD_SINGLE_READ "R"
89#define EZOCARRIERRTD_CMD_SCALE "S"
90#define EZOCARRIERRTD_CMD_SLEEP "Sleep"
91#define EZOCARRIERRTD_CMD_STATUS "Status"
92#define EZOCARRIERRTD_CMD_RESP_CODES "*OK"
93#define EZOCARRIERRTD_CMD_END_COMMAND "\r"
94
99#define EZOCARRIERRTD_RSP_OK "*OK"
100#define EZOCARRIERRTD_RSP_ERROR "*ER"
101#define EZOCARRIERRTD_RSP_OVER_VOLT "*OV"
102#define EZOCARRIERRTD_RSP_UNDER_VOLT "*UV"
103#define EZOCARRIERRTD_RSP_RESET "*RS"
104#define EZOCARRIERRTD_RSP_READY "*RE"
105#define EZOCARRIERRTD_RSP_SLEEP "*SL"
106#define EZOCARRIERRTD_RSP_WAKE_UP "*WA"
107
113#define EZOCARRIERRTD_TX_DRV_BUFFER_SIZE 100
114#define EZOCARRIERRTD_RX_DRV_BUFFER_SIZE 300
115
116 // ezocarrierrtd_cmd
117
123#define EZOCARRIERRTD_DEVICE_ADDRESS 0x61
124
139#define EZOCARRIERRTD_MAP_MIKROBUS( cfg, mikrobus ) \
140 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
141 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
142 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
143 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX )
144
145 // ezocarrierrtd_map
146 // ezocarrierrtd
147
158
163typedef struct
164{
165 // Modules
166 uart_t uart;
167 i2c_master_t i2c;
169 // Buffers
170 uint8_t uart_rx_buffer[ EZOCARRIERRTD_RX_DRV_BUFFER_SIZE ];
171 uint8_t uart_tx_buffer[ EZOCARRIERRTD_TX_DRV_BUFFER_SIZE ];
178
183typedef struct
184{
185 // Communication gpio pins
186 pin_name_t rx_pin;
187 pin_name_t tx_pin;
188 pin_name_t scl;
189 pin_name_t sda;
191 // Static variable
192 uint32_t baud_rate;
194 uart_data_bits_t data_bit;
195 uart_parity_t parity_bit;
196 uart_stop_bits_t stop_bit;
197 uint32_t i2c_speed;
198 uint8_t i2c_address;
202
214
231
247
262
275err_t ezocarrierrtd_generic_write ( ezocarrierrtd_t *ctx, uint8_t *data_in, uint16_t len );
276
289err_t ezocarrierrtd_generic_read ( ezocarrierrtd_t *ctx, uint8_t *data_out, uint16_t len );
290
300void ezocarrierrtd_send_cmd ( ezocarrierrtd_t *ctx, uint8_t *cmd );
301
312void ezocarrierrtd_send_cmd_with_par ( ezocarrierrtd_t *ctx, uint8_t *cmd, uint8_t *param_buf );
313
324
325#ifdef __cplusplus
326}
327#endif
328#endif // EZOCARRIERRTD_H
329
330 // ezocarrierrtd
331
332// ------------------------------------------------------------------------ END
ezocarrierrtd_drv_t
EZO Carrier EC Click driver selector.
Definition ezocarrierrtd.h:153
@ EZOCARRIERRTD_DRV_SEL_UART
Definition ezocarrierrtd.h:155
@ EZOCARRIERRTD_DRV_SEL_I2C
Definition ezocarrierrtd.h:154
ezocarrierrtd_return_value_t
EZO Carrier RTD Click return value data.
Definition ezocarrierrtd.h:208
@ EZOCARRIERRTD_OK
Definition ezocarrierrtd.h:209
@ EZOCARRIERRTD_ERROR_TIMEOUT
Definition ezocarrierrtd.h:211
@ EZOCARRIERRTD_ERROR
Definition ezocarrierrtd.h:210
#define EZOCARRIERRTD_TX_DRV_BUFFER_SIZE
EZO Carrier RTD driver buffer size.
Definition ezocarrierrtd.h:113
#define EZOCARRIERRTD_RX_DRV_BUFFER_SIZE
Definition ezocarrierrtd.h:114
void ezocarrierrtd_drv_interface_sel(ezocarrierrtd_cfg_t *cfg, ezocarrierrtd_drv_t drv_sel)
EZO Carrier EC driver interface setup function.
void ezocarrierrtd_cfg_setup(ezocarrierrtd_cfg_t *cfg)
EZO Carrier RTD configuration object setup function.
err_t ezocarrierrtd_generic_read(ezocarrierrtd_t *ctx, uint8_t *data_out, uint16_t len)
EZO Carrier RTD data reading function.
void ezocarrierrtd_send_cmd_check(ezocarrierrtd_t *ctx, uint8_t *cmd)
Check the sent command.
void ezocarrierrtd_send_cmd(ezocarrierrtd_t *ctx, uint8_t *cmd)
Send command function.
err_t ezocarrierrtd_init(ezocarrierrtd_t *ctx, ezocarrierrtd_cfg_t *cfg)
EZO Carrier RTD initialization function.
err_t ezocarrierrtd_generic_write(ezocarrierrtd_t *ctx, uint8_t *data_in, uint16_t len)
EZO Carrier RTD data writing function.
void ezocarrierrtd_send_cmd_with_par(ezocarrierrtd_t *ctx, uint8_t *cmd, uint8_t *param_buf)
Send command function with parameter.
EZO Carrier RTD Click configuration object.
Definition ezocarrierrtd.h:184
uint32_t baud_rate
Definition ezocarrierrtd.h:192
uint32_t i2c_speed
Definition ezocarrierrtd.h:197
ezocarrierrtd_drv_t drv_sel
Definition ezocarrierrtd.h:199
bool uart_blocking
Definition ezocarrierrtd.h:193
uart_data_bits_t data_bit
Definition ezocarrierrtd.h:194
pin_name_t tx_pin
Definition ezocarrierrtd.h:187
pin_name_t rx_pin
Definition ezocarrierrtd.h:186
uart_stop_bits_t stop_bit
Definition ezocarrierrtd.h:196
pin_name_t scl
Definition ezocarrierrtd.h:188
uart_parity_t parity_bit
Definition ezocarrierrtd.h:195
pin_name_t sda
Definition ezocarrierrtd.h:189
uint8_t i2c_address
Definition ezocarrierrtd.h:198
EZO Carrier RTD Click context object.
Definition ezocarrierrtd.h:164
ezocarrierrtd_drv_t drv_sel
Definition ezocarrierrtd.h:175
uart_t uart
Definition ezocarrierrtd.h:166
i2c_master_t i2c
Definition ezocarrierrtd.h:167
uint8_t slave_address
Definition ezocarrierrtd.h:173