rfid2 2.0.0.0
rfid2.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 RFID2_H
29#define RFID2_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 RFID2_CARD_IS_SUCCESSFULLY_READ 0x00
74
80#define DRV_BUFFER_SIZE 200
81
82 // rfid2_cmd
83
98#define RFID2_MAP_MIKROBUS( cfg, mikrobus ) \
99 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
100 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
101 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
102 cfg.cp = MIKROBUS( mikrobus, MIKROBUS_INT );
103
104 // rfid2_map
105 // rfid2
106
111typedef struct
112{
113 // Output pins
114 digital_out_t rst;
116 // Input pins
117 digital_in_t cp;
119 // Modules
120 uart_t uart;
122 // Buffers
123 char uart_rx_buffer[ DRV_BUFFER_SIZE ];
124 char uart_tx_buffer[ DRV_BUFFER_SIZE ];
126} rfid2_t;
127
132typedef struct
133{
134 // Communication gpio pins
135 pin_name_t rx_pin;
136 pin_name_t tx_pin;
138 // Additional gpio pins
139 pin_name_t rst;
140 pin_name_t cp;
142 // Static variable
143 uint32_t baud_rate;
145 uart_data_bits_t data_bit;
146 uart_parity_t parity_bit;
147 uart_stop_bits_t stop_bit;
150
155typedef enum
156{
158 RFID2_ERROR = -1
159
161
178
193err_t rfid2_init ( rfid2_t *ctx, rfid2_cfg_t *cfg );
194
208err_t rfid2_generic_write ( rfid2_t *ctx, char *data_buf, uint16_t len );
209
223err_t rfid2_generic_read ( rfid2_t *ctx, char *data_buf, uint16_t max_len );
224
235
245void rfid2_reset( rfid2_t *ctx );
246
247#ifdef __cplusplus
248}
249#endif
250#endif // RFID2_H
251
252 // rfid2
253
254// ------------------------------------------------------------------------ END
#define DRV_BUFFER_SIZE
RFID 2 driver buffer size.
Definition rfid2.h:80
void rfid2_cfg_setup(rfid2_cfg_t *cfg)
RFID 2 configuration object setup function.
void rfid2_reset(rfid2_t *ctx)
RFID 2 reset chip function.
uint8_t rfid2_get_interrupt(rfid2_t *ctx)
RFID 2 read state interrupt(INT) pin function.
err_t rfid2_generic_read(rfid2_t *ctx, char *data_buf, uint16_t max_len)
RFID 2 data reading function.
err_t rfid2_init(rfid2_t *ctx, rfid2_cfg_t *cfg)
RFID 2 initialization function.
err_t rfid2_generic_write(rfid2_t *ctx, char *data_buf, uint16_t len)
RFID 2 data writing function.
rfid2_return_value_t
RFID 2 Click return value data.
Definition rfid2.h:156
@ RFID2_ERROR
Definition rfid2.h:158
@ RFID2_OK
Definition rfid2.h:157
RFID 2 Click configuration object.
Definition rfid2.h:133
uint32_t baud_rate
Definition rfid2.h:143
pin_name_t cp
Definition rfid2.h:140
bool uart_blocking
Definition rfid2.h:144
uart_data_bits_t data_bit
Definition rfid2.h:145
pin_name_t tx_pin
Definition rfid2.h:136
pin_name_t rx_pin
Definition rfid2.h:135
uart_stop_bits_t stop_bit
Definition rfid2.h:147
uart_parity_t parity_bit
Definition rfid2.h:146
pin_name_t rst
Definition rfid2.h:139
RFID 2 Click context object.
Definition rfid2.h:112
uart_t uart
Definition rfid2.h:120
digital_out_t rst
Definition rfid2.h:114
digital_in_t cp
Definition rfid2.h:117