基于STM32單片機光學指紋識別模塊
2.購買指紋模塊,可以獲得三份資料
3.硬件搭建
FPM10A光學指紋模塊共有5個管腳
2 為 GND
3 為 TXD
4 為 RXD
5 為 NC
4.模塊的測試工作
5.現(xiàn)在我們要進入編程環(huán)節(jié)了
這里我使用的STM32單片,所以這兩個程序如下:
// 從 USART1 發(fā)送一個字節(jié)
void USART1_SendByte(unsigned char temp)
{
}
// 從 USART1 讀取一個字節(jié)
unsigned char USART1_ReceivByte()
{
}
6.查看FPM10A用戶手冊 我們來實現(xiàn)比對一個指紋(我們這里假設指紋模塊中已經存在指紋模板)
//檢測指紋模塊錄入指紋情況,返回00表示錄入成功;02無手指;03錄入失敗
unsigned char test_fig()
{
}
因此,我們在主函數(shù)中可以這樣調用:
void main
{
}
7.如何錄入一個新的指紋信息呢?
//添加一個新的指紋
unsigned char FP_add_new_user(unsigned char ucH_user,unsigned char ucL_user)
{
}
//存儲模版到特定地址
void FINGERPRINT_Cmd_Save_Finger( unsigned char ucH_Char, unsigned char ucL_Char)
{
}
8.如何刪除一個模板?
//刪除所有指紋模版
void FINGERPRINT_Cmd_Delete_All_Model(void)
{
}
9.如何獲取已經存取的指紋模板信息?
這個模塊一共可以存儲0~999枚指紋信息
//搜索全部用戶999枚
void FINGERPRINT_Cmd_Search_Finger(void)
{
}
根據用戶手冊,我們可以從應答包中得出模塊中已經存在指紋數(shù)量的大小
這樣,我們就輕松把指紋模塊搞定!
下面我附上基于STM32單片機光學指紋識別模塊(FPM10A)打包好的函數(shù)庫
第一個是
#include "stm32f10x.h"
#include "stm32f10x_usart.h"
#include "misc.h"
unsigned char dat[18];
//FINGERPRINT通信協(xié)議定義
unsigned char FP_Pack_Head[6] = {0xEF,0x01,0xFF,0xFF,0xFF,0xFF};
unsigned char FP_Get_Img[6] = {0x01,0x00,0x03,0x01,0x0,0x05};
unsigned char FP_Templete_Num[6] ={0x01,0x00,0x03,0x1D,0x00,0x21 };
unsigned char FP_Search[11]={0x01,0x0,0x08,0x04,0x01,0x0,0x0,0x03,0xA1,0x0,0xB2};
unsigned char FP_Search_0_9[11]={0x01,0x0,0x08,0x04,0x01,0x0,0x0,0x0,0x13,0x0,0x21};//搜索0-9號指紋
unsigned char FP_Img_To_Buffer1[7]={0x01,0x0,0x04,0x02,0x01,0x0,0x08};
unsigned char FP_Img_To_Buffer2[7]={0x01,0x0,0x04,0x02,0x02,0x0,0x09};
unsigned char FP_Reg_Model[6]={0x01,0x0,0x03,0x05,0x0,0x09};
unsigned char FP_Delet_All_Model[6]={0x01,0x0,0x03,0x0d,0x00,0x11};
unsigned char FP_Save_Finger[9]={0x01,0x00,0x06,0x06,0x01,0x00,0x0B,0x00,0x19};
unsigned char FP_Delete_Model[10]={0x01,0x00,0x07,0x0C,0x0,0x0,0x0,0x1,0x0,0x0};
//從 USART1 發(fā)送一個字節(jié)
void USART1_SendByte(unsigned char temp)
{
}
//從 USART1 讀取一個字節(jié)
unsigned char USART1_ReceivByte()
{
}
//FINGERPRINT命令字
//FINGERPRINT_獲得指紋圖像命令
void FINGERPRINT_Cmd_Get_Img(void)
{
}
//刪除所有指紋模版
void FINGERPRINT_Cmd_Delete_All_Model(void)
{
}
//講圖像轉換成特征碼存放在Buffer1中
void FINGERPRINT_Cmd_Img_To_Buffer1(void)
{
}
//將圖像轉換成特征碼存放在Buffer2中
void FINGERPRINT_Cmd_Img_To_Buffer2(void)
{
}
//將BUFFER1 跟 BUFFER2 中的特征碼合并成指紋模版
void FINGERPRINT_Cmd_Reg_Model(void)
{
}
//存儲模版到特定地址
void FINGERPRINT_Cmd_Save_Finger( unsigned char ucH_Char, unsigned char ucL_Char)
{
}
//獲得指紋模板數(shù)量
void FINGERPRINT_Cmd_Get_Templete_Num(void)
{
}
//搜索全部用戶999枚
void FINGERPRINT_Cmd_Search_Finger(void)
{
}
//搜索用戶0~9枚
void FINGERPRINT_Cmd_Search_Finger_Admin(void)
{
}
//添加一個新的指紋
unsigned char FP_add_new_user(unsigned char ucH_user,unsigned char ucL_user)
{
}
第2個 FPM10A.h
#ifndef _FPM10A_H
#define _FPM10A_H
#include
extern unsigned char dat[18];
extern void FINGERPRINT_Cmd_Get_Img();
extern void FINGERPRINT_Cmd_Img_To_Buffer1();
extern void FINGERPRINT_Cmd_Img_To_Buffer2();
extern void FINGERPRINT_Cmd_Reg_Model();
extern void FINGERPRINT_Cmd_Delete_All_Model(void);
extern void FINGERPRINT_Cmd_Search_Finger(void);
extern void FINGERPRINT_Cmd_Get_Templete_Num(void);
extern void FINGERPRINT_Cmd_Search_Finger_Admin(void);
extern void FINGERPRINT_Cmd_Save_Finger( unsigned char ucH_Char, unsigned char ucL_Char);
extern unsigned char FP_add_new_user(unsigned char ucH_user,unsigned char ucL_user);
extern void USART1_SendByte(unsigned char temp);
extern unsigned char USART1_ReceivByte();
extern void Delay_ms1(uint32_t nCount);
void Delay_nus1(uint32_t nCount)
{
}
void Delay_ms1(uint32_t nCount)
{
}
unsigned char test_fig()//檢測指紋模塊錄入指紋情況,返回00表示錄入成功;02無手指;03錄入失敗
{
}
#endif
有了這兩個東西,加入到你的工程中,就可以直接調用啦!
評論