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
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_uart.h"
38 
59 #define RFID2_CARD_IS_SUCCESSFULLY_READ 0x00
60 
66 #define DRV_BUFFER_SIZE 200
67  // rfid2_cmd
69 
84 #define RFID2_MAP_MIKROBUS( cfg, mikrobus ) \
85  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
86  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
87  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
88  cfg.cp = MIKROBUS( mikrobus, MIKROBUS_INT );
89  // rfid2_map // rfid2
92 
97 typedef struct
98 {
99  // Output pins
100  digital_out_t rst;
102  // Input pins
103  digital_in_t cp;
105  // Modules
106  uart_t uart;
108  // Buffers
109  char uart_rx_buffer[ DRV_BUFFER_SIZE ];
110  char uart_tx_buffer[ DRV_BUFFER_SIZE ];
112 } rfid2_t;
113 
118 typedef struct
119 {
120  // Communication gpio pins
121  pin_name_t rx_pin;
122  pin_name_t tx_pin;
124  // Additional gpio pins
125  pin_name_t rst;
126  pin_name_t cp;
128  // Static variable
129  uint32_t baud_rate;
131  uart_data_bits_t data_bit;
132  uart_parity_t parity_bit;
133  uart_stop_bits_t stop_bit;
135 } rfid2_cfg_t;
136 
141 typedef enum
142 {
143  RFID2_OK = 0,
144  RFID2_ERROR = -1
145 
147 
164 
179 err_t rfid2_init ( rfid2_t *ctx, rfid2_cfg_t *cfg );
180 
194 err_t rfid2_generic_write ( rfid2_t *ctx, char *data_buf, uint16_t len );
195 
209 err_t rfid2_generic_read ( rfid2_t *ctx, char *data_buf, uint16_t max_len );
210 
220 uint8_t rfid2_get_interrupt( rfid2_t *ctx );
221 
231 void rfid2_reset( rfid2_t *ctx );
232 
233 #ifdef __cplusplus
234 }
235 #endif
236 #endif // RFID2_H
237  // rfid2
239 
240 // ------------------------------------------------------------------------ END
rfid2_t
RFID 2 Click context object.
Definition: rfid2.h:98
rfid2_cfg_t::rx_pin
pin_name_t rx_pin
Definition: rfid2.h:121
rfid2_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: rfid2.h:133
rfid2_t::rst
digital_out_t rst
Definition: rfid2.h:100
rfid2_generic_read
err_t rfid2_generic_read(rfid2_t *ctx, char *data_buf, uint16_t max_len)
RFID 2 data reading function.
rfid2_cfg_t::rst
pin_name_t rst
Definition: rfid2.h:125
rfid2_init
err_t rfid2_init(rfid2_t *ctx, rfid2_cfg_t *cfg)
RFID 2 initialization function.
DRV_BUFFER_SIZE
#define DRV_BUFFER_SIZE
RFID 2 driver buffer size.
Definition: rfid2.h:66
rfid2_cfg_t::uart_blocking
bool uart_blocking
Definition: rfid2.h:130
rfid2_t::uart
uart_t uart
Definition: rfid2.h:106
rfid2_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: rfid2.h:132
rfid2_cfg_t::baud_rate
uint32_t baud_rate
Definition: rfid2.h:129
rfid2_return_value_t
rfid2_return_value_t
RFID 2 Click return value data.
Definition: rfid2.h:142
rfid2_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: rfid2.h:131
rfid2_get_interrupt
uint8_t rfid2_get_interrupt(rfid2_t *ctx)
RFID 2 read state interrupt(INT) pin function.
rfid2_cfg_t::tx_pin
pin_name_t tx_pin
Definition: rfid2.h:122
rfid2_t::cp
digital_in_t cp
Definition: rfid2.h:103
rfid2_reset
void rfid2_reset(rfid2_t *ctx)
RFID 2 reset chip function.
rfid2_generic_write
err_t rfid2_generic_write(rfid2_t *ctx, char *data_buf, uint16_t len)
RFID 2 data writing function.
rfid2_cfg_t::cp
pin_name_t cp
Definition: rfid2.h:126
RFID2_OK
@ RFID2_OK
Definition: rfid2.h:143
rfid2_cfg_t
RFID 2 Click configuration object.
Definition: rfid2.h:119
rfid2_cfg_setup
void rfid2_cfg_setup(rfid2_cfg_t *cfg)
RFID 2 configuration object setup function.
RFID2_ERROR
@ RFID2_ERROR
Definition: rfid2.h:144