irda4 2.1.0.0
irda4.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 IRDA4_H
29#define IRDA4_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
73#define IRDA4_SHUTDOWN_DISABLED 0x00
74#define IRDA4_SHUTDOWN_ENABLED 0x01
75
80#define IRDA4_RESET_DISABLED 0x00
81#define IRDA4_RESET_ENABLED 0x01
87#define IRDA4_DRV_BUFFER_SIZE 300
88
89 // irda4_cmd
90
105#define IRDA4_MAP_MIKROBUS( cfg, mikrobus ) \
106 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
107 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
108 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
109 cfg.sd = MIKROBUS( mikrobus, MIKROBUS_PWM );
110
111 // irda4_map
112 // irda4
113
118typedef struct
119{
120 // Output pins
121 digital_out_t rst;
122 digital_out_t sd;
124 // Modules
125 uart_t uart;
127 // Buffers
128 uint8_t uart_rx_buffer[ IRDA4_DRV_BUFFER_SIZE ];
129 uint8_t uart_tx_buffer[ IRDA4_DRV_BUFFER_SIZE ];
131} irda4_t;
132
137typedef struct
138{
139 // Communication gpio pins
140 pin_name_t rx_pin;
141 pin_name_t tx_pin;
143 // Additional gpio pins
144 pin_name_t rst;
145 pin_name_t sd;
147 // Static variable
148 uint32_t baud_rate;
150 uart_data_bits_t data_bit;
151 uart_parity_t parity_bit;
152 uart_stop_bits_t stop_bit;
155
160typedef enum
161{
163 IRDA4_ERROR = -1
164
166
183
197err_t irda4_init ( irda4_t *ctx, irda4_cfg_t *cfg );
198
211err_t irda4_generic_write ( irda4_t *ctx, uint8_t *data_in, uint16_t len );
212
225err_t irda4_generic_read ( irda4_t *ctx, uint8_t *data_out, uint16_t len );
226
236void irda4_set_tx_shutdown ( irda4_t *ctx, uint8_t sd_state );
237
247void irda4_set_reset_state ( irda4_t *ctx, uint8_t rst_state );
248
257void irda_hw_reset ( irda4_t *ctx );
258
259#ifdef __cplusplus
260}
261#endif
262#endif // IRDA4_H
263
264 // irda4
265
266// ------------------------------------------------------------------------ END
#define IRDA4_DRV_BUFFER_SIZE
IrDA 4 driver buffer size.
Definition irda4.h:87
void irda4_set_tx_shutdown(irda4_t *ctx, uint8_t sd_state)
IrDA 4 TX shutdown function.
err_t irda4_init(irda4_t *ctx, irda4_cfg_t *cfg)
IrDA 4 initialization function.
void irda4_cfg_setup(irda4_cfg_t *cfg)
IrDA 4 configuration object setup function.
err_t irda4_generic_write(irda4_t *ctx, uint8_t *data_in, uint16_t len)
IrDA 4 data writing function.
void irda4_set_reset_state(irda4_t *ctx, uint8_t rst_state)
IrDA 4 set reset pin state function.
void irda_hw_reset(irda4_t *ctx)
IrDA 4 hardware reset function.
err_t irda4_generic_read(irda4_t *ctx, uint8_t *data_out, uint16_t len)
IrDA 4 data reading function.
irda4_return_value_t
IrDA 4 Click return value data.
Definition irda4.h:161
@ IRDA4_OK
Definition irda4.h:162
@ IRDA4_ERROR
Definition irda4.h:163
IrDA 4 Click configuration object.
Definition irda4.h:138
pin_name_t sd
Definition irda4.h:145
uint32_t baud_rate
Definition irda4.h:148
bool uart_blocking
Definition irda4.h:149
uart_data_bits_t data_bit
Definition irda4.h:150
pin_name_t tx_pin
Definition irda4.h:141
pin_name_t rx_pin
Definition irda4.h:140
uart_stop_bits_t stop_bit
Definition irda4.h:152
uart_parity_t parity_bit
Definition irda4.h:151
pin_name_t rst
Definition irda4.h:144
IrDA 4 Click context object.
Definition irda4.h:119
digital_out_t sd
Definition irda4.h:122
uart_t uart
Definition irda4.h:125
digital_out_t rst
Definition irda4.h:121