rs4855v  2.0.0.0
rs4855v.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 RS4855V_H
29 #define RS4855V_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  // rs4855v_set
63 
78 #define RS4855V_MAP_MIKROBUS( cfg, mikrobus ) \
79  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
80  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
81  cfg.rw = MIKROBUS( mikrobus, MIKROBUS_PWM )
82  // rs4855v_map // rs4855v
85 
90 typedef struct
91 {
92  // Output pins
93 
94  digital_out_t rw;
95 
96  // Modules
97 
98  uart_t uart;
100  // Buffers
101 
102  char uart_rx_buffer[ DRV_BUFFER_SIZE ];
103  char uart_tx_buffer[ DRV_BUFFER_SIZE ];
104 
105 } rs4855v_t;
106 
111 typedef struct
112 {
113  // Communication gpio pins
114 
115  pin_name_t rx_pin;
116  pin_name_t tx_pin;
118  // Additional gpio pins
119 
120  pin_name_t rw;
121 
122  // Static variable
123 
124  uint32_t baud_rate;
125  bool uart_blocking;
126  uart_data_bits_t data_bit;
127  uart_parity_t parity_bit;
128  uart_stop_bits_t stop_bit;
130 } rs4855v_cfg_t;
131 
136 typedef enum
137 {
139  RS4855V_ERROR = -1
140 
142 
158 void rs4855v_cfg_setup ( rs4855v_cfg_t *cfg );
159 
174 err_t rs4855v_init ( rs4855v_t *ctx, rs4855v_cfg_t *cfg );
175 
186 void rs4855v_generic_write ( rs4855v_t *ctx, char *data_buf, uint16_t len );
187 
201 err_t rs4855v_generic_read ( rs4855v_t *ctx, char *data_buf, uint16_t max_len );
202 
209 void rs4855v_send_command ( rs4855v_t *ctx, char *command );
210 #ifdef __cplusplus
211 }
212 #endif
213 #endif // RS4855V_H
214  // rs4855v
216 
217 // ------------------------------------------------------------------------ END
rs4855v_init
err_t rs4855v_init(rs4855v_t *ctx, rs4855v_cfg_t *cfg)
RS485 5V initialization function.
rs4855v_send_command
void rs4855v_send_command(rs4855v_t *ctx, char *command)
Send command.
rs4855v_generic_write
void rs4855v_generic_write(rs4855v_t *ctx, char *data_buf, uint16_t len)
RS485 5V data writing function.
DRV_BUFFER_SIZE
#define DRV_BUFFER_SIZE
RS485 5V driver buffer size.
Definition: rs4855v.h:59
RS4855V_ERROR
Definition: rs4855v.h:138
rs4855v_cfg_setup
void rs4855v_cfg_setup(rs4855v_cfg_t *cfg)
RS485 5V configuration object setup function.
RS4855V_OK
Definition: rs4855v.h:137
rs4855v_cfg_t
RS485 5V Click configuration object.
Definition: rs4855v.h:110
rs4855v_generic_read
err_t rs4855v_generic_read(rs4855v_t *ctx, char *data_buf, uint16_t max_len)
RS485 5V data reading function.
rs4855v_t
RS485 5V Click context object.
Definition: rs4855v.h:89
rs4855v_return_value_t
rs4855v_return_value_t
RS485 5V Click return value data.
Definition: rs4855v.h:135