rs232isolator2  2.0.0.0
rs232isolator2.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 RS232ISOLATOR2_H
29 #define RS232ISOLATOR2_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_uart.h"
38 
60 #define DRV_BUFFER_SIZE 200
61  // rs232isolator2_set
63 
78 #define RS232ISOLATOR2_MAP_MIKROBUS( cfg, mikrobus ) \
79  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
80  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX );
81  // rs232isolator2_map // rs232isolator2
84 
89 typedef struct
90 {
91  // Modules
92 
93  uart_t uart;
95  // Buffers
96 
97  char uart_rx_buffer[ DRV_BUFFER_SIZE ];
98  char uart_tx_buffer[ DRV_BUFFER_SIZE ];
101 
106 typedef struct
107 {
108  // Communication gpio pins
109 
110  pin_name_t rx_pin;
111  pin_name_t tx_pin;
113  // Static variable
114 
115  uint32_t baud_rate;
116  bool uart_blocking;
117  uart_data_bits_t data_bit;
118  uart_parity_t parity_bit;
119  uart_stop_bits_t stop_bit;
122 
127 typedef enum
128 {
131 
133 
150 
166 
180 err_t rs232isolator2_generic_write ( rs232isolator2_t *ctx, char *data_buf, uint16_t len );
181 
195 err_t rs232isolator2_generic_read ( rs232isolator2_t *ctx, char *data_buf, uint16_t max_len );
196 
209 err_t rs232isolator2_send_data ( rs232isolator2_t *ctx, char *tx_data );
210 
211 #ifdef __cplusplus
212 }
213 #endif
214 #endif // RS232ISOLATOR2_H
215  // rs232isolator2
217 
218 // ------------------------------------------------------------------------ END
rs232isolator2_cfg_t
RS232 Isolator 2 Click configuration object.
Definition: rs232isolator2.h:105
rs232isolator2_cfg_setup
void rs232isolator2_cfg_setup(rs232isolator2_cfg_t *cfg)
RS232 Isolator 2 configuration object setup function.
RS232ISOLATOR2_OK
Definition: rs232isolator2.h:128
rs232isolator2_send_data
err_t rs232isolator2_send_data(rs232isolator2_t *ctx, char *tx_data)
RS232 Isolator 2 data writing function.
rs232isolator2_generic_read
err_t rs232isolator2_generic_read(rs232isolator2_t *ctx, char *data_buf, uint16_t max_len)
RS232 Isolator 2 data reading function.
rs232isolator2_t
RS232 Isolator 2 Click context object.
Definition: rs232isolator2.h:88
DRV_BUFFER_SIZE
#define DRV_BUFFER_SIZE
RS232 Isolator 2 driver buffer size.
Definition: rs232isolator2.h:59
rs232isolator2_return_value_t
rs232isolator2_return_value_t
RS232 Isolator 2 Click return value data.
Definition: rs232isolator2.h:126
RS232ISOLATOR2_ERROR
Definition: rs232isolator2.h:129
rs232isolator2_init
err_t rs232isolator2_init(rs232isolator2_t *ctx, rs232isolator2_cfg_t *cfg)
RS232 Isolator 2 initialization function.
rs232isolator2_generic_write
err_t rs232isolator2_generic_write(rs232isolator2_t *ctx, char *data_buf, uint16_t len)
RS232 Isolator 2 data writing function.