fingerprint3 2.0.0.0
fingerprint3.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 FINGERPRINT3_H
36#define FINGERPRINT3_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 FINGERPRINT3_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
69 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
70 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
71 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
78#define FINGERPRINT3_RETVAL uint8_t
79
80#define FINGERPRINT3_OK 0x00
81#define FINGERPRINT3_INIT_ERROR 0xFF
89#define FINGERPRINT3_CMD_GET_IMAGE 0x01
90#define FINGERPRINT3_CMD_IMAGE_2_TZ 0x02
91#define FINGERPRINT3_CMD_MATCH 0x03
92#define FINGERPRINT3_CMD_SEARCH 0x04
93#define FINGERPRINT3_CMD_REG_MODEL 0x05
94#define FINGERPRINT3_CMD_STORE 0x06
95#define FINGERPRINT3_CMD_LOAD_CHAR 0x07
96#define FINGERPRINT3_CMD_UPLOAD_CHAR 0x08
97#define FINGERPRINT3_CMD_DOWNLOAD_CHAR 0x09
98#define FINGERPRINT3_CMD_UPLOAD_IMAGE 0x0A
99#define FINGERPRINT3_CMD_DOWNLOAD_IMAGE 0x0B
100#define FINGERPRINT3_CMD_DELETE_CHAR 0x0C
101#define FINGERPRINT3_CMD_EMPTY 0x0D
102#define FINGERPRINT3_CMD_SET_SYS_PARAM 0x0E
103#define FINGERPRINT3_CMD_READ_SYS_PARAM 0x0F
104#define FINGERPRINT3_CMD_SET_PASSWORD 0x12
105#define FINGERPRINT3_CMD_VERIFY_PASSWORD 0x13
106#define FINGERPRINT3_CMD_GET_RANDOM_CODE 0x14
107#define FINGERPRINT3_CMD_SET_ADDRESS 0x15
108#define FINGERPRINT3_CMD_READ_INFO_PAGE 0x16
109#define FINGERPRINT3_CMD_PORT_CONTROL 0x17
110#define FINGERPRINT3_CMD_WRITE_NOTEPAD 0x18
111#define FINGERPRINT3_CMD_READ_NOTEPAD 0x19
112#define FINGERPRINT3_CMD_TEMPLATE_NUM 0x1D
113#define FINGERPRINT3_CMD_READ_INDEX_TEMPLATE 0x1F
114#define FINGERPRINT3_CMD_GET_IMAGE_EXT 0x28
115#define FINGERPRINT3_CMD_CANCEL 0x30
116#define FINGERPRINT3_CMD_AURA_CONTROL 0x35
117#define FINGERPRINT3_CMD_CHECK_SENSOR 0x36
118#define FINGERPRINT3_CMD_GET_ALG_VERSION 0x39
119#define FINGERPRINT3_CMD_GET_FW_VERSION 0x3A
120#define FINGERPRINT3_CMD_READ_PRODUCT_INFO 0x3C
121#define FINGERPRINT3_CMD_SOFT_RESET 0x3D
122#define FINGERPRINT3_CMD_HAND_SHAKE 0x40
129#define FINGERPRINT3_CONF_CMD_OK 0x00
130#define FINGERPRINT3_CONF_PACKET_RECEIVE_ERROR 0x01
131#define FINGERPRINT3_CONF_NO_FINGER 0x02
132#define FINGERPRINT3_CONF_ENROLL_FAIL 0x03
133#define FINGERPRINT3_CONF_OVER_DISORDERLY_FAIL 0x06
134#define FINGERPRINT3_CONF_OVER_SMALLNESS_FAIL 0x07
135#define FINGERPRINT3_CONF_NO_MATCH 0x08
136#define FINGERPRINT3_CONF_NOT_FOUND 0x09
137#define FINGERPRINT3_CONF_FAIL_TO_COMBINE 0x0A
138#define FINGERPRINT3_CONF_BAD_LOCATION 0x0B
139#define FINGERPRINT3_CONF_READ_TEMPLATE_FAIL 0x0C
140#define FINGERPRINT3_CONF_UPLOAD_TEMPLATE_FAIL 0x0D
141#define FINGERPRINT3_CONF_PACKET_RECEIVE_FAIL 0x0E
142#define FINGERPRINT3_CONF_UPLOAD_IMAGE_FAIL 0x0F
143#define FINGERPRINT3_CONF_DELETE_TEMPLATE_FAIL 0x10
144#define FINGERPRINT3_CONF_LIBRARY_CLEAR_FAIL 0x11
145#define FINGERPRINT3_CONF_WRONG_PASSWORD 0x13
146#define FINGERPRINT3_CONF_GENERATE_IMAGE_FAIL 0x15
147#define FINGERPRINT3_CONF_FLASH_WRITE_ERROR 0x18
148#define FINGERPRINT3_CONF_NO_DEFINITION_ERROR 0x19
149#define FINGERPRINT3_CONF_INVALID_REG_NUM 0x1A
150#define FINGERPRINT3_CONF_INCORRECT_REG_CONFIG 0x1B
151#define FINGERPRINT3_CONF_WRONG_PAGE_NUM 0x1C
152#define FINGERPRINT3_CONF_COM_PORT_FAIL 0x1D
159#define FINGERPRINT3_HEADER 0xEF01
160#define FINGERPRINT3_HEADER_MSB 0xEF
161#define FINGERPRINT3_HEADER_LSB 0x01
168#define FINGERPRINT3_DEFAULT_ADDRESS 0xFFFFFFFFul
169#define FINGERPRINT3_DEFAULT_PASSWORD 0x00000000ul
176#define FINGERPRINT3_COMMAND_PACKET 0x01
177#define FINGERPRINT3_DATA_PACKET 0x02
178#define FINGERPRINT3_ACK_PACKET 0x07
179#define FINGERPRINT3_END_DATA_PACKET 0x08
186#define FINGERPRINT3_DETECT_FINGER 0x00
187#define FINGERPRINT3_DETECT_NO_FINGER 0x01
194#define FINGERPRINT3_ERR_TIMEOUT 0xFB
195#define FINGERPRINT3_ERR_PACKAGE_LEN 0xFC
196#define FINGERPRINT3_ERR_CHKSUM 0xFD
197#define FINGERPRINT3_ERR_RESPONSE 0xFE
198#define FINGERPRINT3_ERR_HEADER 0xFF
205#define FINGERPRINT3_AURA_LED_RED 0x01
206#define FINGERPRINT3_AURA_LED_BLUE 0x02
207#define FINGERPRINT3_AURA_LED_PURPLE 0x03
208
209#define FINGERPRINT3_AURA_CTRL_BREATH 0x01
210#define FINGERPRINT3_AURA_CTRL_FLASH 0x02
211#define FINGERPRINT3_AURA_CTRL_ON 0x03
212#define FINGERPRINT3_AURA_CTRL_OFF 0x04
213#define FINGERPRINT3_AURA_CTRL_GRADUAL_ON 0x05
214#define FINGERPRINT3_AURA_CTRL_GRADUAL_OFF 0x06
215
216#define FINGERPRINT3_AURA_TIME_INFINITE 0x00
223#define FINGERPRINT3_MAX_PACKAGE_LENGTH 256
230#define FINGERPRINT3_DRV_TX_BUFFER_SIZE 500
231#define FINGERPRINT3_DRV_RX_BUFFER_SIZE 500
238#define FINGERPRINT3_TIMEOUT 500
242 // End group macro
243// --------------------------------------------------------------- PUBLIC TYPES
253typedef struct
254{
255 uint16_t header;
256 uint32_t addr;
257 uint8_t pkg_id;
258 uint16_t pkg_len;
259 uint8_t pkg_content[ FINGERPRINT3_MAX_PACKAGE_LENGTH ];
260 uint16_t checksum;
261
263
267typedef struct
268{
269 uint8_t module_type[ 16 ];
270 uint8_t module_batch_number[ 4 ];
271 uint8_t module_serial_number[ 8 ];
272 uint8_t hardware_version[ 2 ];
273 uint8_t sensor_type[ 8 ];
274 uint16_t sensor_width;
278
280
295
299typedef struct
300{
301 // Output pins
302 digital_out_t rst;
303
304 // Input pins
305 digital_in_t int_pin;
306
307 // Modules
308 uart_t uart;
309
310 uint8_t uart_rx_buffer[ FINGERPRINT3_DRV_RX_BUFFER_SIZE ];
311 uint8_t uart_tx_buffer[ FINGERPRINT3_DRV_TX_BUFFER_SIZE ];
312
316 uint32_t address;
317 uint32_t password;
318
320
324typedef struct
325{
326 // Communication gpio pins
327 pin_name_t rx_pin;
328 pin_name_t tx_pin;
329
330 // Additional gpio pins
331 pin_name_t rst;
332 pin_name_t int_pin;
333
334 // static variable
335 uint32_t baud_rate; // Clock speed.
337 uart_data_bits_t data_bit; // Data bits.
338 uart_parity_t parity_bit; // Parity bit.
339 uart_stop_bits_t stop_bit; // Stop bits.
340
342
347 // End types group
348// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
349
355#ifdef __cplusplus
356extern "C"{
357#endif
358
368
377
390uint8_t fingerprint3_set_config ( fingerprint3_t *ctx, uint32_t addr, uint32_t pass );
391
403void fingerprint3_set_rst_pin ( fingerprint3_t *ctx, uint8_t rst_pin );
404
412void fingerprint3_generic_write ( fingerprint3_t *ctx, uint8_t *data_buf, uint16_t len );
413
423int32_t fingerprint3_generic_read ( fingerprint3_t *ctx, uint8_t *data_buf, uint16_t max_len );
424
438uint8_t fingerprint3_send_package ( fingerprint3_t *ctx, uint8_t pkg_id, uint8_t *pkg_content, uint16_t pkg_len );
439
448
467uint8_t fingerprint3_aura_control ( fingerprint3_t *ctx, uint8_t control, uint8_t speed,
468 uint8_t color, uint8_t times );
469
480uint8_t fingerprint3_verify_password ( fingerprint3_t *ctx, uint32_t pass );
481
492
503
516uint8_t fingerprint3_set_security_lvl ( fingerprint3_t *ctx, uint8_t lvl );
517
528
539
550
572uint8_t fingerprint3_read_index_table ( fingerprint3_t *ctx, uint8_t *table, uint8_t page );
573
584
596uint8_t fingerprint3_extract_features ( fingerprint3_t *ctx, uint8_t char_buffer );
597
610
622uint8_t fingerprint3_store_template ( fingerprint3_t *ctx, uint8_t char_buffer, uint16_t location );
623
634uint8_t fingerprint3_delete_template ( fingerprint3_t *ctx, uint16_t location );
635
646
658uint8_t fingerprint3_load_template ( fingerprint3_t *ctx, uint8_t char_buffer, uint16_t location );
659
670uint8_t fingerprint3_match_finger ( fingerprint3_t *ctx, uint16_t *score );
671
684uint8_t fingerprint3_search_finger ( fingerprint3_t *ctx, uint8_t char_buffer, uint16_t *location, uint16_t *score );
685
686#ifdef __cplusplus
687}
688#endif
689#endif // _FINGERPRINT3_H_
690
691 // End public_function group
693
694// ------------------------------------------------------------------------- END
#define FINGERPRINT3_DRV_TX_BUFFER_SIZE
Definition fingerprint3.h:230
#define FINGERPRINT3_DRV_RX_BUFFER_SIZE
Definition fingerprint3.h:231
#define FINGERPRINT3_MAX_PACKAGE_LENGTH
Definition fingerprint3.h:223
uint8_t fingerprint3_match_finger(fingerprint3_t *ctx, uint16_t *score)
Empty the library function.
uint8_t fingerprint3_finger_indicator(fingerprint3_t *ctx)
Finger indicator function.
void fingerprint3_generic_write(fingerprint3_t *ctx, uint8_t *data_buf, uint16_t len)
Generic write function.
uint8_t fingerprint3_delete_template(fingerprint3_t *ctx, uint16_t location)
Delete template function.
uint8_t fingerprint3_soft_reset(fingerprint3_t *ctx)
Soft reset function.
uint8_t fingerprint3_aura_control(fingerprint3_t *ctx, uint8_t control, uint8_t speed, uint8_t color, uint8_t times)
Aura LED control function.
uint8_t fingerprint3_load_template(fingerprint3_t *ctx, uint8_t char_buffer, uint16_t location)
Create template function.
uint8_t fingerprint3_search_finger(fingerprint3_t *ctx, uint8_t char_buffer, uint16_t *location, uint16_t *score)
Empty the library function.
uint8_t fingerprint3_read_product_info(fingerprint3_t *ctx)
Read product info function.
uint8_t fingerprint3_check_sensor(fingerprint3_t *ctx)
Check sensor function.
uint8_t fingerprint3_set_security_lvl(fingerprint3_t *ctx, uint8_t lvl)
Set security level function.
uint8_t fingerprint3_read_sys_param(fingerprint3_t *ctx)
Read system parameter function.
uint8_t fingerprint3_read_index_table(fingerprint3_t *ctx, uint8_t *table, uint8_t page)
Read index table function.
uint8_t fingerprint3_extract_features(fingerprint3_t *ctx, uint8_t char_buffer)
Extract features function.
void fingerprint3_set_rst_pin(fingerprint3_t *ctx, uint8_t rst_pin)
Set RST pin state function.
uint8_t fingerprint3_set_config(fingerprint3_t *ctx, uint32_t addr, uint32_t pass)
Set config function.
void fingerprint3_cfg_setup(fingerprint3_cfg_t *cfg)
Config Object Initialization function.
uint8_t fingerprint3_store_template(fingerprint3_t *ctx, uint8_t char_buffer, uint16_t location)
Create template function.
err_t fingerprint3_init(fingerprint3_t *ctx, fingerprint3_cfg_t *cfg)
Initialization function.
uint8_t fingerprint3_create_template(fingerprint3_t *ctx)
Create template function.
uint8_t fingerprint3_send_package(fingerprint3_t *ctx, uint8_t pkg_id, uint8_t *pkg_content, uint16_t pkg_len)
Send package function.
uint8_t fingerprint3_verify_password(fingerprint3_t *ctx, uint32_t pass)
Verify password function.
uint8_t fingerprint3_hand_shake(fingerprint3_t *ctx)
Hand shake function.
int32_t fingerprint3_generic_read(fingerprint3_t *ctx, uint8_t *data_buf, uint16_t max_len)
Generic read function.
uint8_t fingerprint3_take_image(fingerprint3_t *ctx)
Take image function.
uint8_t fingerprint3_empty_library(fingerprint3_t *ctx)
Empty the library function.
Click configuration structure definition.
Definition fingerprint3.h:325
uint32_t baud_rate
Definition fingerprint3.h:335
bool uart_blocking
Definition fingerprint3.h:336
uart_data_bits_t data_bit
Definition fingerprint3.h:337
pin_name_t tx_pin
Definition fingerprint3.h:328
pin_name_t rx_pin
Definition fingerprint3.h:327
uart_stop_bits_t stop_bit
Definition fingerprint3.h:339
pin_name_t int_pin
Definition fingerprint3.h:332
uart_parity_t parity_bit
Definition fingerprint3.h:338
pin_name_t rst
Definition fingerprint3.h:331
Package structure.
Definition fingerprint3.h:254
uint16_t header
Definition fingerprint3.h:255
uint16_t checksum
Definition fingerprint3.h:260
uint8_t pkg_id
Definition fingerprint3.h:257
uint32_t addr
Definition fingerprint3.h:256
uint16_t pkg_len
Definition fingerprint3.h:258
Product Info structure.
Definition fingerprint3.h:268
uint16_t sensor_height
Definition fingerprint3.h:275
uint16_t database_size
Definition fingerprint3.h:277
uint16_t sensor_width
Definition fingerprint3.h:274
uint16_t template_size
Definition fingerprint3.h:276
System Parameters structure.
Definition fingerprint3.h:285
uint16_t system_identifier_code
Definition fingerprint3.h:287
uint32_t device_address
Definition fingerprint3.h:290
uint16_t security_level
Definition fingerprint3.h:289
uint16_t finger_library_size
Definition fingerprint3.h:288
uint16_t status_register
Definition fingerprint3.h:286
uint16_t data_package_size
Definition fingerprint3.h:291
uint32_t baudrate
Definition fingerprint3.h:292
Click ctx object definition.
Definition fingerprint3.h:300
fingerprint3_product_info_t product_info
Definition fingerprint3.h:314
uart_t uart
Definition fingerprint3.h:308
fingerprint3_pkg_t rsp
Definition fingerprint3.h:313
digital_in_t int_pin
Definition fingerprint3.h:305
uint32_t password
Definition fingerprint3.h:317
uint32_t address
Definition fingerprint3.h:316
digital_out_t rst
Definition fingerprint3.h:302
fingerprint3_sys_parameter_t system_parameters
Definition fingerprint3.h:315