rs4853v3  2.0.0.0
rs4853v3.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 RS4853V3_H
29 #define RS4853V3_H
30 
31 #ifdef __cplusplus
32 extern "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_uart.h"
48 
70 #define DRV_BUFFER_SIZE 200
71  // rs4853v3_set
73 
88 #define RS4853V3_MAP_MIKROBUS( cfg, mikrobus ) \
89  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
90  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
91  cfg.rw = MIKROBUS( mikrobus, MIKROBUS_PWM )
92  // rs4853v3_map // rs4853v3
95 
100 typedef struct
101 {
102  // Output pins
103 
104  digital_out_t rw;
105 
106  // Modules
107 
108  uart_t uart;
110  // Buffers
111 
112  char uart_rx_buffer[ DRV_BUFFER_SIZE ];
113  char uart_tx_buffer[ DRV_BUFFER_SIZE ];
114 
115 } rs4853v3_t;
116 
121 typedef struct
122 {
123  // Communication gpio pins
124 
125  pin_name_t rx_pin;
126  pin_name_t tx_pin;
128  // Additional gpio pins
129 
130  pin_name_t rw;
131 
132  // Static variable
133 
134  uint32_t baud_rate;
136  uart_data_bits_t data_bit;
137  uart_parity_t parity_bit;
138  uart_stop_bits_t stop_bit;
141 
146 typedef enum
147 {
149  RS4853V3_ERROR = -1
150 
152 
169 
185 
196 void rs4853v3_generic_write ( rs4853v3_t *ctx, char *data_buf, uint16_t len );
197 
211 err_t rs4853v3_generic_read ( rs4853v3_t *ctx, char *data_buf, uint16_t max_len );
212 
219 void rs4853v3_send_command ( rs4853v3_t *ctx, char *command );
220 #ifdef __cplusplus
221 }
222 #endif
223 #endif // RS4853V3_H
224  // rs4853v3
226 
227 // ------------------------------------------------------------------------ END
rs4853v3_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: rs4853v3.h:138
rs4853v3_cfg_t::rx_pin
pin_name_t rx_pin
Definition: rs4853v3.h:125
rs4853v3_send_command
void rs4853v3_send_command(rs4853v3_t *ctx, char *command)
Send command.
rs4853v3_generic_read
err_t rs4853v3_generic_read(rs4853v3_t *ctx, char *data_buf, uint16_t max_len)
RS485 3V3 data reading function.
rs4853v3_cfg_t
RS485 3V3 Click configuration object.
Definition: rs4853v3.h:122
rs4853v3_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: rs4853v3.h:136
rs4853v3_t
RS485 3V3 Click context object.
Definition: rs4853v3.h:101
rs4853v3_t::uart
uart_t uart
Definition: rs4853v3.h:108
rs4853v3_init
err_t rs4853v3_init(rs4853v3_t *ctx, rs4853v3_cfg_t *cfg)
RS485 3V3 initialization function.
rs4853v3_return_value_t
rs4853v3_return_value_t
RS485 3V3 Click return value data.
Definition: rs4853v3.h:147
rs4853v3_cfg_setup
void rs4853v3_cfg_setup(rs4853v3_cfg_t *cfg)
RS485 3V3 configuration object setup function.
rs4853v3_generic_write
void rs4853v3_generic_write(rs4853v3_t *ctx, char *data_buf, uint16_t len)
RS485 3V3 data writing function.
rs4853v3_cfg_t::baud_rate
uint32_t baud_rate
Definition: rs4853v3.h:134
rs4853v3_cfg_t::tx_pin
pin_name_t tx_pin
Definition: rs4853v3.h:126
rs4853v3_cfg_t::uart_blocking
bool uart_blocking
Definition: rs4853v3.h:135
rs4853v3_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: rs4853v3.h:137
RS4853V3_OK
@ RS4853V3_OK
Definition: rs4853v3.h:148
RS4853V3_ERROR
@ RS4853V3_ERROR
Definition: rs4853v3.h:149
DRV_BUFFER_SIZE
#define DRV_BUFFER_SIZE
RS485 3V3 driver buffer size.
Definition: rs4853v3.h:70
rs4853v3_cfg_t::rw
pin_name_t rw
Definition: rs4853v3.h:130
rs4853v3_t::rw
digital_out_t rw
Definition: rs4853v3.h:104