irda3 2.0.0.0
irda3.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 IRDA3_H
29#define IRDA3_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 DRV_BUFFER_SIZE 500
75
76 // irda3_set
77
92#define IRDA3_MAP_MIKROBUS( cfg, mikrobus ) \
93 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
94 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
95 cfg.mod = MIKROBUS( mikrobus, MIKROBUS_AN ); \
96 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
97 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
98
99 // irda3_map
100 // irda3
101
106typedef struct
107{
108 // Output pins
109
110 digital_out_t mod;
111 digital_out_t rst;
112 digital_out_t en;
114 // Modules
115
116 uart_t uart;
118 // Buffers
119
120 char uart_rx_buffer[ DRV_BUFFER_SIZE ];
121 char uart_tx_buffer[ DRV_BUFFER_SIZE ];
123} irda3_t;
124
129typedef struct
130{
131 // Communication gpio pins
132
133 pin_name_t rx_pin;
134 pin_name_t tx_pin;
136 // Additional gpio pins
137
138 pin_name_t mod;
139 pin_name_t rst;
140 pin_name_t en;
142 // Static variable
143
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
156typedef enum
157{
159 IRDA3_ERROR = -1
160
162
166typedef enum
167{
170
172
176typedef enum
177{
180
182
199
214err_t irda3_init ( irda3_t *ctx, irda3_cfg_t *cfg );
215
230
241
252
262void irda3_reset( irda3_t *ctx );
263
273void irda3_generic_multiple_send( irda3_t *ctx, char *tx_data );
274
287void irda3_generic_multiple_receive( irda3_t *ctx, char *rx_data, char termination_char );
288
298void irda3_generic_single_send( irda3_t *ctx, char tx_data );
299
310#ifdef __cplusplus
311}
312#endif
313#endif // IRDA3_H
314
315 // irda3
#define DRV_BUFFER_SIZE
IrDA 3 driver buffer size.
Definition irda3.h:74
void irda3_cfg_setup(irda3_cfg_t *cfg)
IrDA 3 configuration object setup function.
void irda3_generic_multiple_send(irda3_t *ctx, char *tx_data)
Generic Multiple Send function.
void irda3_mode_setup(irda3_t *ctx, irda3_mode_t state)
Mode Setup function.
void irda3_generic_single_send(irda3_t *ctx, char tx_data)
Generic Single Send function.
void irda3_default_cfg(irda3_t *ctx)
IrDA 3 default configuration function.
char irda3_generic_single_receive(irda3_t *ctx)
Generic Single Receive function.
void irda3_generic_multiple_receive(irda3_t *ctx, char *rx_data, char termination_char)
Generic Multiple Receive function.
void irda3_reset(irda3_t *ctx)
Reset function.
void irda3_pwr_setup(irda3_t *ctx, irda3_pwr_t state)
Power Setup function.
err_t irda3_init(irda3_t *ctx, irda3_cfg_t *cfg)
IrDA 3 initialization function.
irda3_mode_t
Click mode settings.
Definition irda3.h:167
@ IRDA3_MODE_DATA
Definition irda3.h:169
@ IRDA3_MODE_CMD
Definition irda3.h:168
irda3_return_value_t
IrDA 3 Click return value data.
Definition irda3.h:157
@ IRDA3_OK
Definition irda3.h:158
@ IRDA3_ERROR
Definition irda3.h:159
irda3_pwr_t
Click power mode settings.
Definition irda3.h:177
@ IRDA3_PWR_ON
Definition irda3.h:179
@ IRDA3_PWR_OFF
Definition irda3.h:178
IrDA 3 Click configuration object.
Definition irda3.h:130
uint32_t baud_rate
Definition irda3.h:144
bool uart_blocking
Definition irda3.h:145
uart_data_bits_t data_bit
Definition irda3.h:146
pin_name_t mod
Definition irda3.h:138
pin_name_t tx_pin
Definition irda3.h:134
pin_name_t rx_pin
Definition irda3.h:133
uart_stop_bits_t stop_bit
Definition irda3.h:148
pin_name_t en
Definition irda3.h:140
uart_parity_t parity_bit
Definition irda3.h:147
pin_name_t rst
Definition irda3.h:139
IrDA 3 Click context object.
Definition irda3.h:107
digital_out_t mod
Definition irda3.h:110
uart_t uart
Definition irda3.h:116
digital_out_t en
Definition irda3.h:112
digital_out_t rst
Definition irda3.h:111