基于STM32单片机开发光学指纹识别模块(FPM10A)全教程
时间:11-20
来源:互联网
点击:
- 应答信息
- }
- }
- //将BUFFER1 跟 BUFFER2 中的特征码合并成指纹模版
- void FINGERPRINT_Cmd_Reg_Model(void)
- {
- unsigned char i;
- for(i=0;i<6;i++) //包头
- {
- USART1_SendByte(FP_Pack_Head[i]);
- }
- for(i=0;i<6;i++) //命令合并指纹模版
- {
- USART1_SendByte(FP_Reg_Model[i]);
- }
- for(i=0;i<12;i++)
- {
- dat[i]=USART1_ReceivByte();
- }
- }
- //存储模版到特定地址
- 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();
- }
- //获得指纹模板数量
- void FINGERPRINT_Cmd_Get_Templete_Num(void)
- {
- unsigned int i;
- for(i=0;i<6;i++) //包头
- USART1_SendByte(FP_Pack_Head[i]);
- //发送命令 0x1d
- for(i=0;i<6;i++)
- USART1_SendByte(FP_Templete_Num[i]);
- for(i=0;i<12;i++)
- dat[i]=USART1_ReceivByte();
- }
- //搜索全部用户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();
- }
- }
- //搜索用户0~9枚
- void FINGERPRINT_Cmd_Search_Finger_Admin(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_0_9[i]);
- }
- for(i=0;i<12;i++)
- dat[i]=USART1_ReceivByte();
- }
- //添加一个新的指纹
- unsigned char FP_add_new_user(unsigned char ucH_user,unsigned char ucL_user)
- {
- do
- {
- FINGERPRINT_Cmd_Get_Img(); //获得指纹图像
- } while ( dat[9]!=0x0 ); //检测是否成功的按了指纹
- FINGERPRINT_Cmd_Img_To_Buffer1(); //将图像转换成特征码存放在Buffer1中
- do
- {
- FINGERPRINT_Cmd_Get_Img(); //获得指纹图像
- } while( dat[9]!=0x0 );
- FINGERPRINT_Cmd_Img_To_Buffer2(); //将图像转换成特征码存放在Buffer2中
- FINGERPRINT_Cmd_Reg_Model(); //转换成特征码
- FINGERPRINT_Cmd_Save_Finger(ucH_user,ucL_user);
- return 0;
- }
第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)
- {
- uint32_t j;
- while(nCount--)
- {
- j=8;
- while(j--);
- }
- }
- void Delay_ms1(uint32_t nCount)
- {
- while(nCount--)
- Delay_nus1(1100);
- }
- unsigned char test_fig()//检测指纹模块录入指纹情况,返回00表示录入成功;02无手指;03录入失败
- {
- unsigned char fig_dat;
- FINGERPRINT_Cmd_Get_Img();
- Delay_ms1(20);
- fig_dat=dat[9];
- return(fig_dat);
- }
- #endif
有了这两个东西,加入到你的工程中,就可以直接调用啦!
STM32单片机开发光学指纹识别模块FPM10 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)