irda2 2.0.0.0
irda2.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 IRDA2_H
29#define IRDA2_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 IRDA2_TX_DRV_BUFFER_SIZE 100
75#define IRDA2_RX_DRV_BUFFER_SIZE 300
76
77 // irda2_set
78
93#define IRDA2_MAP_MIKROBUS( cfg, mikrobus ) \
94 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
95 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
96 cfg.mod = MIKROBUS( mikrobus, MIKROBUS_AN ); \
97 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
98 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
99
100 // irda2_map
101 // irda2
102
107typedef struct
108{
109 // Output pins
110 digital_out_t mod;
111 digital_out_t rst;
112 digital_out_t en;
114 // Modules
115 uart_t uart;
117 // Buffers
118 uint8_t uart_rx_buffer[ IRDA2_RX_DRV_BUFFER_SIZE ];
119 uint8_t uart_tx_buffer[ IRDA2_TX_DRV_BUFFER_SIZE ];
121} irda2_t;
122
127typedef struct
128{
129 // Communication gpio pins
130 pin_name_t rx_pin;
131 pin_name_t tx_pin;
133 // Additional gpio pins
134 pin_name_t mod;
135 pin_name_t rst;
136 pin_name_t en;
138 // Static variable
139 uint32_t baud_rate;
141 uart_data_bits_t data_bit;
142 uart_parity_t parity_bit;
143 uart_stop_bits_t stop_bit;
146
151typedef enum
152{
154 IRDA2_ERROR = -1
155
157
161typedef enum
162{
165
167
171typedef enum
172{
175
177
194
208err_t irda2_init ( irda2_t *ctx, irda2_cfg_t *cfg );
209
223
234
245
254void irda2_reset( irda2_t *ctx );
255
268err_t irda2_generic_write ( irda2_t *ctx, uint8_t *data_in, uint16_t len );
269
282err_t irda2_generic_read ( irda2_t *ctx, uint8_t *data_out, uint16_t len );
283
284#ifdef __cplusplus
285}
286#endif
287#endif // IRDA2_H
288
289 // irda2
290
291// ------------------------------------------------------------------------ END
#define IRDA2_RX_DRV_BUFFER_SIZE
Definition irda2.h:75
#define IRDA2_TX_DRV_BUFFER_SIZE
IrDA 2 driver buffer size.
Definition irda2.h:74
void irda2_pwr_setup(irda2_t *ctx, irda2_pwr_t state)
Power Setup function.
err_t irda2_generic_read(irda2_t *ctx, uint8_t *data_out, uint16_t len)
IrDA 2 data reading function.
void irda2_reset(irda2_t *ctx)
Reset function.
err_t irda2_generic_write(irda2_t *ctx, uint8_t *data_in, uint16_t len)
IrDA 2 data writing function.
void irda2_default_cfg(irda2_t *ctx)
IrDA 2 default configuration function.
void irda2_cfg_setup(irda2_cfg_t *cfg)
IrDA 2 configuration object setup function.
err_t irda2_init(irda2_t *ctx, irda2_cfg_t *cfg)
IrDA 2 initialization function.
void irda2_mode_setup(irda2_t *ctx, irda2_mode_t state)
Mode Setup function.
irda2_pwr_t
Click power mode settings.
Definition irda2.h:172
@ IRDA2_PWR_ON
Definition irda2.h:174
@ IRDA2_PWR_OFF
Definition irda2.h:173
irda2_mode_t
Click mode settings.
Definition irda2.h:162
@ IRDA2_MODE_DATA
Definition irda2.h:164
@ IRDA2_MODE_CMD
Definition irda2.h:163
irda2_return_value_t
IrDA 2 Click return value data.
Definition irda2.h:152
@ IRDA2_OK
Definition irda2.h:153
@ IRDA2_ERROR
Definition irda2.h:154
IrDA 2 Click configuration object.
Definition irda2.h:128
uint32_t baud_rate
Definition irda2.h:139
bool uart_blocking
Definition irda2.h:140
uart_data_bits_t data_bit
Definition irda2.h:141
pin_name_t mod
Definition irda2.h:134
pin_name_t tx_pin
Definition irda2.h:131
pin_name_t rx_pin
Definition irda2.h:130
uart_stop_bits_t stop_bit
Definition irda2.h:143
pin_name_t en
Definition irda2.h:136
uart_parity_t parity_bit
Definition irda2.h:142
pin_name_t rst
Definition irda2.h:135
IrDA 2 Click context object.
Definition irda2.h:108
digital_out_t mod
Definition irda2.h:110
uart_t uart
Definition irda2.h:115
digital_out_t en
Definition irda2.h:112
digital_out_t rst
Definition irda2.h:111