STM32的RFID射频读写控制装置

更新时间:2023-07-18 22:06:28 阅读: 评论:0

STM32的RFID射频读写控制装置
,⼤⼆上学期做的,过了很久,先上⼀下图:
这并不是做个最后⼀版;主体是RC552+STM32+1062;蜂鸣器,继电器,LED等;反正最后的效果就是,刷⼀下卡,1602显⽰⼀下持卡⼈(需要提前注册,注册⽅法也就是在数组⾥多添加⼏个编号,哈哈,毕竟没有数据库暂时也只能想到这样了);然后蜂鸣器响,灯亮,继电器开;
贴⼀下关键代码:
#include "delay.h"
#include "sys.h"
#include "usart.h"
#include "led.h"
#include "lcd1602.h"
#include "key.h"
#include <stdio.h>
#include "stm32f10x_gpio.h"
#include "stm32f10x_rcc.h"
#include "main.h"
#include "mfrc522.h"
#include "stm32f10x.h"
#include "exti.h"
铜钹
USART_InitTypeDef USART_InitStructure;
void GPIO_ini()
{
高二物理公式
GPIO_InitTypeDef  GPIO_InitStructure;
/* Enable the GPIO Clock */
RCC_APB2PeriphClockCmd(MF522_RST_CLK, ENABLE);
/
* Configure the GPIO pin */
GPIO_InitStructure.GPIO_Pin = MF522_RST_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(MF522_RST_PORT, &GPIO_InitStructure);
/* Enable the GPIO Clock */
RCC_APB2PeriphClockCmd(MF522_MISO_CLK, ENABLE);
/* Configure the GPIO pin */
GPIO_InitStructure.GPIO_Pin = MF522_MISO_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(MF522_MISO_PORT, &GPIO_InitStructure);
/* Enable the GPIO Clock */
RCC_APB2PeriphClockCmd(MF522_MOSI_CLK, ENABLE);
/* Configure the GPIO pin */
GPIO_InitStructure.GPIO_Pin = MF522_MOSI_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
颠沛的意思GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(MF522_MOSI_PORT, &GPIO_InitStructure);
/* Enable the GPIO Clock */
RCC_APB2PeriphClockCmd(MF522_SCK_CLK, ENABLE);
/* Configure the GPIO pin */
GPIO_InitStructure.GPIO_Pin = MF522_SCK_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(MF522_SCK_PORT, &GPIO_InitStructure);
/* Enable the GPIO Clock */
RCC_APB2PeriphClockCmd(MF522_NSS_CLK, ENABLE);
/* Configure the GPIO pin */
GPIO_InitStructure.GPIO_Pin = MF522_NSS_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(MF522_NSS_PORT, &GPIO_InitStructure);
/
* Enable the GPIO Clock */
RCC_APB2PeriphClockCmd(LED_CLK, ENABLE);
/* Configure the GPIO pin */
GPIO_InitStructure.GPIO_Pin = LED_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(LED_PORT, &GPIO_InitStructure);
}
void InitializeSystem()
{
//LED_OFF;
delay_10ms(10);
PcdRet();
PcdAntennaOff();
PcdAntennaOn();
M500PcdConfigISOType( 'A' );
//LED_ON;荆州市绩效
delay_10ms(10);
//LED_OFF;
delay_10ms(10);
//LED_ON;
delay_10ms(10);
/
/LED_OFF;
}
int main(void)
{
char status;
unsigned char snr, buf[16], TagType[2], SelectedSnr[4], DefaultKey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};    u8 t;蛰头的做法
u8 str[] = "Jiaomengke";
u8 str2[] = "Jiaomengke2";
u8 str3[] = "Jiaomengke";
母爱诗句
delay_init();
康力欣NVIC_Configuration();
uart_init(9600);
GPIO_Configuration();
KEY_Init();
LED_Init();
flog:
LCD1602_Init();
//LCD1602_Show_Str(0, 0, "Plea put card");
LCD1602_Show_Str(1, 0, "    Plea");
LCD1602_Show_Str(2, 1, "  put card");
GPIO_ini();
InitializeSystem( );
while(1)长隆野生动物园
{        status= PcdRequest(REQ_ALL,TagType);
if(!status)
{
status = PcdAnticoll(SelectedSnr);
if(!status)
{
status=PcdSelect(SelectedSnr);
if(!status)
{
snr = 0;
          status = PcdAuthState(KEYA, (snr*4+3), DefaultKey, SelectedSnr);// УÑé0ÉÈÇøÃÜÂë
{
if(!status)
{
status = PcdRead((snr*4+1), buf);  //PcdWrite((snr*4+1), buf);    // ¶ÁÈ¡0ÉÈÇø1¿éÊý¾Ý
if(!status && (SelectedSnr[2]==0x3e||SelectedSnr[2]==0xf6||SelectedSnr[2]==0xf4||SelectedSnr[2]==0xe7))                            {
LED_ON;
WaitCardOff();
while(1)
{  LCD1602_ClearScreen();
LCD1602_Show_Str(1, 0, " Welcome You");
if(SelectedSnr[2]==0x3e)
  LCD1602_Show_Str(2, 1, str);
if(SelectedSnr[2]==0xf6)
    LCD1602_Show_Str(2, 1, str1);
if(SelectedSnr[2]==0xf4)
  LCD1602_Show_Str(2, 1, str2);
if(SelectedSnr[2]==0xe7)
  LCD1602_Show_Str(2, 1, str3);
  delay_ms(1000);
    LED_OFF;
delay_ms(1000);
goto flog;
}
}
}
}
}
}
}
LED_OFF;
}
}

本文发布于:2023-07-18 22:06:28,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1086898.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:添加   注册   数据库   只能   读写   蜂鸣器
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图