usbuartiso 2.1.0.0
usbuartiso.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 USBUARTISO_H
29#define USBUARTISO_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_uart.h"
52
74#define USBUARTISO_TX_DRV_BUFFER_SIZE 100
75#define USBUARTISO_RX_DRV_BUFFER_SIZE 300
76
77 // usbuartiso_cmd
78
93#define USBUARTISO_MAP_MIKROBUS( cfg, mikrobus ) \
94 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
95 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
96 cfg.slp = MIKROBUS( mikrobus, MIKROBUS_AN ); \
97 cfg.cts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
98 cfg.pwr = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
99 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_INT );
100
101 // usbuartiso_map
102 // usbuartiso
103
108typedef struct
109{
110 // Output pins
111 digital_out_t cts;
112 digital_out_t pwr;
114 // Input pins
115 digital_in_t slp;
116 digital_in_t rts;
118 // Modules
119 uart_t uart;
121 // Buffers
122 uint8_t uart_rx_buffer[ USBUARTISO_RX_DRV_BUFFER_SIZE ];
123 uint8_t uart_tx_buffer[ USBUARTISO_TX_DRV_BUFFER_SIZE ];
126
131typedef struct
132{
133 // Communication gpio pins
134 pin_name_t rx_pin;
135 pin_name_t tx_pin;
137 // Additional gpio pins
138 pin_name_t slp;
139 pin_name_t cts;
140 pin_name_t pwr;
141 pin_name_t rts;
143 // Static variable
144 uint32_t baud_rate;
146 uart_data_bits_t data_bit;
147 uart_parity_t parity_bit;
148 uart_stop_bits_t stop_bit;
151
162
179
194
206
219err_t usbuartiso_generic_write ( usbuartiso_t *ctx, uint8_t *data_in, uint16_t len );
220
233err_t usbuartiso_generic_read ( usbuartiso_t *ctx, uint8_t *data_out, uint16_t len );
234
246
258
271
282
293void usbuartiso_clear_to_send ( usbuartiso_t *ctx, uint8_t cts );
294
295#ifdef __cplusplus
296}
297#endif
298#endif // USBUARTISO_H
299
300 // usbuartiso
301
302// ------------------------------------------------------------------------ END
#define USBUARTISO_TX_DRV_BUFFER_SIZE
USB UART ISO driver buffer size.
Definition usbuartiso.h:74
#define USBUARTISO_RX_DRV_BUFFER_SIZE
Definition usbuartiso.h:75
uint8_t usbuartiso_get_slp_ind(usbuartiso_t *ctx)
USB UART ISO sleep indicator function.
err_t usbuartiso_init(usbuartiso_t *ctx, usbuartiso_cfg_t *cfg)
USB UART ISO initialization function.
void usbuartiso_default_cfg(usbuartiso_t *ctx)
USB UART ISO default configuration function.
uint8_t usbuartiso_request_to_send(usbuartiso_t *ctx)
USB UART ISO request to send function.
void usbuartiso_power_on(usbuartiso_t *ctx)
USB UART ISO power on function.
void usbuartiso_clear_to_send(usbuartiso_t *ctx, uint8_t cts)
USB UART ISO clear to send function.
void usbuartiso_power_off(usbuartiso_t *ctx)
USB UART ISO power off function.
err_t usbuartiso_generic_read(usbuartiso_t *ctx, uint8_t *data_out, uint16_t len)
USB UART ISO data reading function.
void usbuartiso_cfg_setup(usbuartiso_cfg_t *cfg)
USB UART ISO configuration object setup function.
err_t usbuartiso_generic_write(usbuartiso_t *ctx, uint8_t *data_in, uint16_t len)
USB UART ISO data writing function.
USB UART ISO Click configuration object.
Definition usbuartiso.h:132
pin_name_t rts
Definition usbuartiso.h:141
uint32_t baud_rate
Definition usbuartiso.h:144
pin_name_t cts
Definition usbuartiso.h:139
pin_name_t slp
Definition usbuartiso.h:138
bool uart_blocking
Definition usbuartiso.h:145
uart_data_bits_t data_bit
Definition usbuartiso.h:146
pin_name_t tx_pin
Definition usbuartiso.h:135
pin_name_t pwr
Definition usbuartiso.h:140
pin_name_t rx_pin
Definition usbuartiso.h:134
uart_stop_bits_t stop_bit
Definition usbuartiso.h:148
uart_parity_t parity_bit
Definition usbuartiso.h:147
USB UART ISO Click context object.
Definition usbuartiso.h:109
digital_out_t pwr
Definition usbuartiso.h:112
digital_in_t slp
Definition usbuartiso.h:115
uart_t uart
Definition usbuartiso.h:119
digital_in_t rts
Definition usbuartiso.h:116
digital_out_t cts
Definition usbuartiso.h:111
usbuartiso_return_value_t
USB UART ISO Click return value data.
Definition usbuartiso.h:157
@ USBUARTISO_ERROR
Definition usbuartiso.h:159
@ USBUARTISO_OK
Definition usbuartiso.h:158