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
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_uart.h"
38
59#define IRDA4_SHUTDOWN_DISABLED 0x00
60#define IRDA4_SHUTDOWN_ENABLED 0x01
61
67#define IRDA4_DRV_BUFFER_SIZE 300
68 // irda4_cmd
70
85#define IRDA4_MAP_MIKROBUS( cfg, mikrobus ) \
86 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
87 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
88 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
89 cfg.sd = MIKROBUS( mikrobus, MIKROBUS_PWM );
90 // irda4_map // irda4
93
98typedef struct
99{
100 // Output pins
101 digital_out_t rst;
102 digital_out_t sd;
104 // Modules
105 uart_t uart;
107 // Buffers
108 uint8_t uart_rx_buffer[ IRDA4_DRV_BUFFER_SIZE ];
109 uint8_t uart_tx_buffer[ IRDA4_DRV_BUFFER_SIZE ];
111} irda4_t;
112
117typedef struct
118{
119 // Communication gpio pins
120 pin_name_t rx_pin;
121 pin_name_t tx_pin;
123 // Additional gpio pins
124 pin_name_t rst;
125 pin_name_t sd;
127 // Static variable
128 uint32_t baud_rate;
130 uart_data_bits_t data_bit;
131 uart_parity_t parity_bit;
132 uart_stop_bits_t stop_bit;
135
140typedef enum
141{
143 IRDA4_ERROR = -1
144
146
163
177err_t irda4_init ( irda4_t *ctx, irda4_cfg_t *cfg );
178
191err_t irda4_generic_write ( irda4_t *ctx, uint8_t *data_in, uint16_t len );
192
205err_t irda4_generic_read ( irda4_t *ctx, uint8_t *data_out, uint16_t len );
206
216void irda4_set_tx_shutdown ( irda4_t *ctx, uint8_t sd_state );
217
226void irda_hw_reset ( irda4_t *ctx );
227
228#ifdef __cplusplus
229}
230#endif
231#endif // IRDA4_H
232 // irda4
234
235// ------------------------------------------------------------------------ END
#define IRDA4_DRV_BUFFER_SIZE
IrDA 4 driver buffer size.
Definition: irda4.h:67
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 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:141
@ IRDA4_OK
Definition: irda4.h:142
@ IRDA4_ERROR
Definition: irda4.h:143
IrDA 4 Click configuration object.
Definition: irda4.h:118
pin_name_t sd
Definition: irda4.h:125
uint32_t baud_rate
Definition: irda4.h:128
bool uart_blocking
Definition: irda4.h:129
uart_data_bits_t data_bit
Definition: irda4.h:130
pin_name_t tx_pin
Definition: irda4.h:121
pin_name_t rx_pin
Definition: irda4.h:120
uart_stop_bits_t stop_bit
Definition: irda4.h:132
uart_parity_t parity_bit
Definition: irda4.h:131
pin_name_t rst
Definition: irda4.h:124
IrDA 4 Click context object.
Definition: irda4.h:99
digital_out_t sd
Definition: irda4.h:102
uart_t uart
Definition: irda4.h:105
digital_out_t rst
Definition: irda4.h:101