- UID
- 1029342
- 性别
- 男
|
基于STM32单片机光学指纹识别模块(FPM10A)全教程(转)(3)
这样,我们就轻松把指纹模块搞定!
下面我附上基于STM32单片机光学指纹识别模块(FPM10A)打包好的函数库
第一个是 FPM10A.c
#include "stm32f10x.h"
#include "stm32f10x_usart.h"
#include "misc.h"
unsigned char dat[18];
//FINGERPRINT通信协议定义
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 charFP_Search[11]={0x01,0x0,0x08,0x04,0x01,0x0,0x0,0x03,0xA1,0x0,0xB2}; //搜索指纹搜索范围0 - 929
unsigned charFP_Search_0_9[11]={0x01,0x0,0x08,0x04,0x01,0x0,0x0,0x0,0x13,0x0,0x21};//搜索0-9号指纹
unsigned charFP_Img_To_Buffer1[7]={0x01,0x0,0x04,0x02,0x01,0x0,0x08}; //将图像放入到BUFFER1
unsigned charFP_Img_To_Buffer2[7]={0x01,0x0,0x04,0x02,0x02,0x0,0x09}; //将图像放入到BUFFER2
unsigned char FP_Reg_Model[6]={0x01,0x0,0x03,0x05,0x0,0x09}; //将BUFFER1跟BUFFER2合成特征模版
unsigned charFP_Delet_All_Model[6]={0x01,0x0,0x03,0x0d,0x00,0x11}; //删除指纹模块里所有的模版
unsigned charFP_Save_Finger[9]={0x01,0x00,0x06,0x06,0x01,0x00,0x0B,0x00,0x19}; //将BUFFER1中的特征码存放到指定的位置
unsigned charFP_Delete_Model[10]={0x01,0x00,0x07,0x0C,0x0,0x0,0x0,0x1,0x0,0x0}; //删除指定的模版
//从 USART1 发送一个字节
void USART1_SendByte(unsigned char temp)
{
USART_SendData(USART1, temp);
while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
}
//从 USART1 读取一个字节
unsigned char USART1_ReceivByte()
{
unsignedchar recev;
while(USART_GetFlagStatus(USART1,USART_FLAG_RXNE) == RESET);
recev =USART_ReceiveData(USART1);
return recev;
}
//FINGERPRINT命令字
//FINGERPRINT_获得指纹图像命令
void FINGERPRINT_Cmd_Get_Img(void)
{
unsignedchar i;
for(i=0;i<6;i++) //发送包头
USART1_SendByte(FP_Pack_Head);
for(i=0;i<6;i++) //发送命令 0x1d
USART1_SendByte(FP_Get_Img);
for(i=0;i<12;i++)//读回应答信息
dat=USART1_ReceivByte();
}
//删除所有指纹模版
void FINGERPRINT_Cmd_Delete_All_Model(void)
{
unsignedchar i;
for(i=0;i<6;i++) //发送包头
USART1_SendByte(FP_Pack_Head);
for(i=0;i<6;i++) //发送命令 0x1d
USART1_SendByte(FP_Delet_All_Model);
for(i=0;i<12;i++)//读回应答信息
dat=USART1_ReceivByte();
}
//讲图像转换成特征码存放在Buffer1中
void FINGERPRINT_Cmd_Img_To_Buffer1(void)
{
unsignedchar i;
for(i=0;i<6;i++) //发送包头
{
USART1_SendByte(FP_Pack_Head);
}
for(i=0;i<7;i++) //发送命令 将图像转换成 特征码 存放在 CHAR_buffer1
{
USART1_SendByte(FP_Img_To_Buffer1);
}
for(i=0;i<12;i++)//读应答信息
{
dat=USART1_ReceivByte();//把应答数据存放到缓冲区
}
}
//将图像转换成特征码存放在Buffer2中
void FINGERPRINT_Cmd_Img_To_Buffer2(void)
{
unsigned char i;
for(i=0;i<6;i++) //发送包头
{
USART1_SendByte(FP_Pack_Head);
}
for(i=0;i<7;i++) //发送命令 将图像转换成 特征码 存放在 CHAR_buffer1
{
USART1_SendByte(FP_Img_To_Buffer2);
}
for(i=0;i<12;i++)
{
dat=USART1_ReceivByte();//读回应答信息
}
}
//将BUFFER1 跟 BUFFER2 中的特征码合并成指纹模版
void FINGERPRINT_Cmd_Reg_Model(void)
{
unsignedchar i;
for(i=0;i<6;i++) //包头
{
USART1_SendByte(FP_Pack_Head);
}
for(i=0;i<6;i++) //命令合并指纹模版
{
USART1_SendByte(FP_Reg_Model);
}
for(i=0;i<12;i++)
{
dat=USART1_ReceivByte();
}
} |
|