基于STM32单片机开发光学指纹识别模块(FPM10A)全教程
时间:11-20
来源:互联网
点击:
- user);
- return 0;
- }
- //存储模版到特定地址
- void FINGERPRINT_Cmd_Save_Finger( unsigned char ucH_Char, unsigned char ucL_Char)
- {
- unsigned long temp = 0;
- unsigned char i;
- FP_Save_Finger[5] = ucH_Char;
- FP_Save_Finger[6] = ucL_Char;
- for(i=0;i<7;i++) //计算校验和
- temp = temp + FP_Save_Finger[i];
- FP_Save_Finger[7]=(temp & 0x00FF00) >> 8; //存放校验数据
- FP_Save_Finger[8]= temp & 0x0000FF;
- for(i=0;i<6;i++)
- USART1_SendByte(FP_Pack_Head[i]); //发送包头
- for(i=0;i<9;i++)
- USART1_SendByte(FP_Save_Finger[i]) ;//发送命令将图像转换成特征码存放CHAR_buffer1
- for(i=0;i<12;i++)
- dat[i]=USART1_ReceivByte();
- }
8.如何删除一个模板?
- //删除所有指纹模版
- void FINGERPRINT_Cmd_Delete_All_Model(void)
- {
- unsigned char i;
- for(i=0;i<6;i++) //发送包头
- USART1_SendByte(FP_Pack_Head[i]);
- for(i=0;i<6;i++) //发送命令 0x1d
- USART1_SendByte(FP_Delet_All_Model[i]);
- for(i=0;i<12;i++)//读回应答信息
- dat[i]=USART1_ReceivByte();
- }
9.如何获取已经存取的指纹模板信息?
这个模块一共可以存储0~999枚指纹信息
- //搜索全部用户999枚
- void FINGERPRINT_Cmd_Search_Finger(void)
- {
- unsigned char i;
- //发送命令搜索指纹库
- for(i=0;i<6;i++)
- {
- USART1_SendByte(FP_Pack_Head[i]);
- }
- for(i=0;i<11;i++)
- {
- USART1_SendByte(FP_Search[i]);
- }
- for(i=0;i<16;i++)
- {
- dat[i]=USART1_ReceivByte();
- }
- }
根据用户手册,我们可以从应答包中得出模块中已经存在指纹数量的大小
这样,我们就轻松把指纹模块搞定!
下面我附上基于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 char FP_Search[11]={0x01,0x0,0x08,0x04,0x01,0x0,0x0,0x03,0xA1,0x0,0xB2}; //搜索指纹搜索范围0 - 929
- 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}; //将图像放入到BUFFER1
- unsigned char FP_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 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}; //将BUFFER1中的特征码存放到指定的位置
- unsigned char FP_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()
- {
- unsigned char recev;
- while(USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == RESET);
- recev = USART_ReceiveData(USART1);
- return recev;
- }
- //FINGERPRINT命令字
- //FINGERPRINT_获得指纹图像命令
- void FINGERPRINT_Cmd_Get_Img(void)
- {
- unsigned char i;
- for(i=0;i<6;i++) //发送包头
- USART1_SendByte(FP_Pack_Head[i]);
- for(i=0;i<6;i++) //发送命令 0x1d
- USART1_SendByte(FP_Get_Img[i]);
- for(i=0;i<12;i++)//读回应答信息
- dat[i]=USART1_ReceivByte();
- }
- //删除所有指纹模版
- void FINGERPRINT_Cmd_Delete_All_Model(void)
- {
- unsigned char i;
- for(i=0;i<6;i++) //发送包头
- USART1_SendByte(FP_Pack_Head[i]);
- for(i=0;i<6;i++) //发送命令 0x1d
- USART1_SendByte(FP_Delet_All_Model[i]);
- for(i=0;i<12;i++)//读回应答信息
- dat[i]=USART1_ReceivByte();
- }
- //讲图像转换成特征码存放在Buffer1中
- void FINGERPRINT_Cmd_Img_To_Buffer1(void)
- {
- unsigned char i;
- for(i=0;i<6;i++) //发送包头
- {
- USART1_SendByte(FP_Pack_Head[i]);
- }
- for(i=0;i<7;i++) //发送命令 将图像转换成 特征码 存放在 CHAR_buffer1
- {
- USART1_SendByte(FP_Img_To_Buffer1[i]);
- }
- for(i=0;i<12;i++)//读应答信息
- {
- dat[i]=USART1_ReceivByte();//把应答数据存放到缓冲区
- }
- }
- //将图像转换成特征码存放在Buffer2中
- void FINGERPRINT_Cmd_Img_To_Buffer2(void)
- {
- unsigned char i;
- for(i=0;i<6;i++) //发送包头
- {
- USART1_SendByte(FP_Pack_Head[i]);
- }
- for(i=0;i<7;i++) //发送命令 将图像转换成 特征码 存放在 CHAR_buffer1
- {
- USART1_SendByte(FP_Img_To_Buffer2[i]);
- }
- for(i=0;i<12;i++)
- {
- dat[i]=USART1_ReceivByte();//读回
STM32单片机开发光学指纹识别模块FPM10 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)