usbuart5  2.1.0.0
usbuart5.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 USBUART5_H
29 #define USBUART5_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 USBUART5_SUSPEND_MODE_DISABLE 0
61 #define USBUART5_SUSPEND_MODE_ENABLE 1
62 
68 #define USBUART5_TX_DRV_BUFFER_SIZE 100
69 #define USBUART5_RX_DRV_BUFFER_SIZE 300
70  // usbuart5_cmd
72 
87 #define USBUART5_MAP_MIKROBUS( cfg, mikrobus ) \
88  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
89  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
90  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
91  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
92  cfg.cts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
93  cfg.rts = MIKROBUS( mikrobus, MIKROBUS_INT );
94  // usbuart5_map // usbuart5
97 
102 typedef struct
103 {
104  // Output pins
105  digital_out_t an;
106  digital_out_t rst;
107  digital_out_t rts;
109  // Input pins
110  digital_in_t cts;
112  // Modules
113  uart_t uart;
115  // Buffers
116  char uart_rx_buffer[ USBUART5_RX_DRV_BUFFER_SIZE ];
117  char uart_tx_buffer[ USBUART5_TX_DRV_BUFFER_SIZE ];
119 } usbuart5_t;
120 
125 typedef struct
126 {
127  // Communication gpio pins
128  pin_name_t rx_pin;
129  pin_name_t tx_pin;
131  // Additional gpio pins
132  pin_name_t an;
133  pin_name_t rst;
134  pin_name_t cts;
135  pin_name_t rts;
137  // Static variable
138  uint32_t baud_rate;
140  uart_data_bits_t data_bit;
141  uart_parity_t parity_bit;
142  uart_stop_bits_t stop_bit;
145 
150 typedef enum
151 {
153  USBUART5_ERROR = -1
154 
156 
161 typedef enum
162 {
165 
167 
184 
199 
213 
226 err_t usbuart5_generic_write ( usbuart5_t *ctx, char *data_in, uint16_t len );
227 
240 err_t usbuart5_generic_read ( usbuart5_t *ctx, char *data_out, uint16_t len );
241 
253 
265 
280 
294 void usbuart5_suspend_mode ( usbuart5_t *ctx, uint8_t mode );
295 
309 
323 err_t usbuart5_send_data ( usbuart5_t *ctx, uint8_t *data_out );
324 
325 #ifdef __cplusplus
326 }
327 #endif
328 #endif // USBUART5_H
329  // usbuart5
331 
332 // ------------------------------------------------------------------------ END
usbuart5_cfg_t
USB UART 5 Click configuration object.
Definition: usbuart5.h:126
usbuart5_suspend_mode
void usbuart5_suspend_mode(usbuart5_t *ctx, uint8_t mode)
USB UART 5 suspend mode function.
usbuart5_t::rts
digital_out_t rts
Definition: usbuart5.h:107
usbuart5_t::rst
digital_out_t rst
Definition: usbuart5.h:106
usbuart5_get_cts_pin
uint8_t usbuart5_get_cts_pin(usbuart5_t *ctx)
USB UART 5 get RTS pin state function.
usbuart5_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: usbuart5.h:141
usbuart5_generic_write
err_t usbuart5_generic_write(usbuart5_t *ctx, char *data_in, uint16_t len)
USB UART 5 data writing function.
usbuart5_t::uart
uart_t uart
Definition: usbuart5.h:113
usbuart5_t
USB UART 5 Click context object.
Definition: usbuart5.h:103
usbuart5_cfg_setup
void usbuart5_cfg_setup(usbuart5_cfg_t *cfg)
USB UART 5 configuration object setup function.
usbuart5_cfg_t::rst
pin_name_t rst
Definition: usbuart5.h:133
USBUART5_ERROR
@ USBUART5_ERROR
Definition: usbuart5.h:153
usbuart5_generic_read
err_t usbuart5_generic_read(usbuart5_t *ctx, char *data_out, uint16_t len)
USB UART 5 data reading function.
usbuart5_cfg_t::rts
pin_name_t rts
Definition: usbuart5.h:135
usbuart5_default_cfg
err_t usbuart5_default_cfg(usbuart5_t *ctx)
USB UART 5 default configuration function.
USBUART5_TX_DRV_BUFFER_SIZE
#define USBUART5_TX_DRV_BUFFER_SIZE
USB UART 5 driver buffer size.
Definition: usbuart5.h:68
usbuart5_cfg_t::baud_rate
uint32_t baud_rate
Definition: usbuart5.h:138
usbuart5_init
err_t usbuart5_init(usbuart5_t *ctx, usbuart5_cfg_t *cfg)
USB UART 5 initialization function.
USBUART5_OK
@ USBUART5_OK
Definition: usbuart5.h:152
usbuart5_cfg_t::tx_pin
pin_name_t tx_pin
Definition: usbuart5.h:129
usbuart5_t::cts
digital_in_t cts
Definition: usbuart5.h:110
usbuart5_cfg_t::cts
pin_name_t cts
Definition: usbuart5.h:134
usbuart5_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: usbuart5.h:142
usbuart5_t::an
digital_out_t an
Definition: usbuart5.h:105
usbuart5_pin_state_t
usbuart5_pin_state_t
USB UART 5 Click pin state.
Definition: usbuart5.h:162
USBUART5_RX_DRV_BUFFER_SIZE
#define USBUART5_RX_DRV_BUFFER_SIZE
Definition: usbuart5.h:69
usbuart5_cfg_t::uart_blocking
bool uart_blocking
Definition: usbuart5.h:139
USBUART5_PIN_STATE_LOW
@ USBUART5_PIN_STATE_LOW
Definition: usbuart5.h:163
usbuart5_send_data
err_t usbuart5_send_data(usbuart5_t *ctx, uint8_t *data_out)
USB UART 5 send data function.
usbuart5_return_value_t
usbuart5_return_value_t
USB UART 5 Click return value data.
Definition: usbuart5.h:151
usbuart5_cfg_t::an
pin_name_t an
Definition: usbuart5.h:132
usbuart5_set_rts_pin
void usbuart5_set_rts_pin(usbuart5_t *ctx, usbuart5_pin_state_t state)
USB UART 5 set RTS pin state function.
USBUART5_PIN_STATE_HIGH
@ USBUART5_PIN_STATE_HIGH
Definition: usbuart5.h:164
usbuart5_reset_device
void usbuart5_reset_device(usbuart5_t *ctx)
USB UART 5 reset the device function.
usbuart5_cfg_t::rx_pin
pin_name_t rx_pin
Definition: usbuart5.h:128
usbuart5_enable_device
void usbuart5_enable_device(usbuart5_t *ctx)
USB UART 5 enable the device function.
usbuart5_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: usbuart5.h:140