fingerprint2 2.0.0.0
fingerprint2.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef FINGERPRINT2_H
36#define FINGERPRINT2_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_uart.h"
55
56
57// -------------------------------------------------------------- PUBLIC MACROS
67#define FINGERPRINT2_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
69 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
70 cfg.ld1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
71 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
72 cfg.gp1 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
73 cfg.gp2 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
74 cfg.ld2 = MIKROBUS( mikrobus, MIKROBUS_INT )
81#define FINGERPRINT2_RETVAL uint8_t
82
83#define FINGERPRINT2_OK 0x00
84#define FINGERPRINT2_INIT_ERROR 0xFF
92#define FINGERPRINT2_CMD_GET_FW_VER "<C>GetFWVer</C>"
93#define FINGERPRINT2_CMD_GET_DS "<C>GetDS</C>"
94#define FINGERPRINT2_CMD_FP_CMP "<C>CompareFingerprint</C>"
95#define FINGERPRINT2_CMD_FP_REG "<C>RegisterFingerprint</C>"
96#define FINGERPRINT2_CMD_FP_CLR "<C>ClearRegisteredFp</C>"
97#define FINGERPRINT2_CMD_FP_IMG_INFO "<C>FpImageInformation</C>"
98#define FINGERPRINT2_CMD_FP_IMG_SCAN "<C>ScanFpImage</C>"
99#define FINGERPRINT2_CMD_FP_REG_NO "<C>CheckRegisteredNo</C>"
100#define FINGERPRINT2_CMD_LOCK_DEV "<C>LockDevice</C>"
101#define FINGERPRINT2_CMD_UNLOCK_DEV "<C>UnlockCompareFp</C>"
108#define MOD_NUM 10
109#define VAL_CHAR 48
116#define DRV_RX_BUFFER_SIZE 800
117#define DRV_TX_BUFFER_SIZE 100
121 // End group macro
122// --------------------------------------------------------------- PUBLIC TYPES
130typedef struct
131{
132 // Output pins
133
134 digital_out_t rst;
135 digital_out_t gp1;
136 digital_out_t gp2;
137
138 // Input pins
139
140 digital_in_t ld1;
141 digital_in_t ld2;
142
143 // Modules
144
145 uart_t uart;
146
147 char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
148 char uart_tx_buffer[ DRV_TX_BUFFER_SIZE ];
149
151
155typedef struct
156{
157 // Communication gpio pins
158
159 pin_name_t rx_pin;
160 pin_name_t tx_pin;
161
162 // Additional gpio pins
163
164 pin_name_t ld1;
165 pin_name_t rst;
166 pin_name_t gp1;
167 pin_name_t gp2;
168 pin_name_t ld2;
169
170 // static variable
171
172 uint32_t baud_rate; // Clock speed.
174 uart_data_bits_t data_bit; // Data bits.
175 uart_parity_t parity_bit; // Parity bit.
176 uart_stop_bits_t stop_bit; // Stop bits.
177
179
180 // End types group
181// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
182
188#ifdef __cplusplus
189extern "C"{
190#endif
191
201
211
221void fingerprint2_generic_write ( fingerprint2_t *ctx, char *data_buf, uint16_t len );
222
234int32_t fingerprint2_generic_read ( fingerprint2_t *ctx, char *data_buf, uint16_t max_len );
235
246
257
266void fingerprint2_set_rst_status ( fingerprint2_t *ctx, uint8_t status );
267
276void fingerprint2_set_gp1_status ( fingerprint2_t *ctx, uint8_t status );
277
286void fingerprint2_set_gp2_status ( fingerprint2_t *ctx, uint8_t status );
287
296
305void fingerprint2_reg_one_fp ( fingerprint2_t *ctx, uint8_t fp_index );
306
315void fingerprint2_delete_one_fp ( fingerprint2_t *ctx, uint8_t fp_index );
316
317#ifdef __cplusplus
318}
319#endif
320#endif // _FINGERPRINT2_H_
321
322 // End public_function group
324
325// ------------------------------------------------------------------------- END
#define DRV_RX_BUFFER_SIZE
Definition fingerprint2.h:116
#define DRV_TX_BUFFER_SIZE
Definition fingerprint2.h:117
#define FINGERPRINT2_RETVAL
Definition fingerprint2.h:81
void fingerprint2_set_gp1_status(fingerprint2_t *ctx, uint8_t status)
Generic function for setting gp1 pin status.
uint8_t fingerprint2_get_ld2_status(fingerprint2_t *ctx)
Generic function for reading ld2 pin status.
void fingerprint2_generic_write(fingerprint2_t *ctx, char *data_buf, uint16_t len)
Generic write function.
void fingerprint2_delete_one_fp(fingerprint2_t *ctx, uint8_t fp_index)
Function for deleting fingerprint on index.
void fingerprint2_cfg_setup(fingerprint2_cfg_t *cfg)
Config Object Initialization function.
void fingerprint2_reset(fingerprint2_t *ctx)
Function for restarting device.
void fingerprint2_set_rst_status(fingerprint2_t *ctx, uint8_t status)
Generic function for setting rst pin status.
uint8_t fingerprint2_get_ld1_status(fingerprint2_t *ctx)
Generic function for reading ld1 pin status.
void fingerprint2_reg_one_fp(fingerprint2_t *ctx, uint8_t fp_index)
Function for fingerprint registration on index.
int32_t fingerprint2_generic_read(fingerprint2_t *ctx, char *data_buf, uint16_t max_len)
Generic read function.
void fingerprint2_set_gp2_status(fingerprint2_t *ctx, uint8_t status)
Generic function for setting gp2 pin status.
FINGERPRINT2_RETVAL fingerprint2_init(fingerprint2_t *ctx, fingerprint2_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition fingerprint2.h:156
uint32_t baud_rate
Definition fingerprint2.h:172
pin_name_t gp2
Definition fingerprint2.h:167
bool uart_blocking
Definition fingerprint2.h:173
uart_data_bits_t data_bit
Definition fingerprint2.h:174
pin_name_t tx_pin
Definition fingerprint2.h:160
pin_name_t ld2
Definition fingerprint2.h:168
pin_name_t rx_pin
Definition fingerprint2.h:159
uart_stop_bits_t stop_bit
Definition fingerprint2.h:176
pin_name_t gp1
Definition fingerprint2.h:166
uart_parity_t parity_bit
Definition fingerprint2.h:175
pin_name_t ld1
Definition fingerprint2.h:164
pin_name_t rst
Definition fingerprint2.h:165
Click ctx object definition.
Definition fingerprint2.h:131
digital_out_t gp2
Definition fingerprint2.h:136
digital_in_t ld1
Definition fingerprint2.h:140
uart_t uart
Definition fingerprint2.h:145
digital_out_t gp1
Definition fingerprint2.h:135
digital_out_t rst
Definition fingerprint2.h:134
digital_in_t ld2
Definition fingerprint2.h:141