当前位置:网站首页>基于c8t6芯片开发RC522模块实现呼吸灯
基于c8t6芯片开发RC522模块实现呼吸灯
2022-07-28 02:12:00 【十年哞一剑】
RC522模块

射频识别,即RFID是Radio Frequency Ident ificat ion的缩写,
又称无线射频识别,是一.种通信技术,可通过无线电讯号识别特定目标并读写相关数据,
而无需识别系统与特定目标之间建立机械或光学接触。
工作 原理
看看就行了
RFID中间件的概念
比如 linux 的 cp 指令 cp xx.c xxx.c
xx.c 和 xxx.c 存放的目录有可能不同
也就是导致各个目录的属性不同
就引出了一个虚拟文件系统的概念
虚拟文件系统就是提供通用的接口
就可以实现cp 指令
即为中间件
代码
main.c
#include "usart.h"
#include "stm32f10x_spi.h"
#include "RC522.h"
#include "delay.h"
#include "string.h"
#include "spi_driver.h"
#include "stdio.h"
#include "pwm.h"
#include "beep.h"
#include "switch.h"
#include "kz.h"
#include "breth.h"
#include "led.h"
#include "timer.h"
#include "usart3.h"
#include "oled.h"
/* 接线 ******************************************************************* STM32F103C8T6 RC522模块 PA4£¨ SPI1_NSS£ SDA PA5£¨ SPI1_SCK£ SCK PA6£¨ SPI1_MISO£ MISO PA7£¨ SPI1_MOSI£ MOSI PA11 RS RST PB1 IRQ IRQ 不接 USART1_TX GPIOA.9 USART1_RX GPIOA.10 ********************************************************************* */
uint8_t Card_Type1[2];
uint8_t Card_ID[4];
uint8_t Card_KEY[6] = {
0xff,0xff,0xff,0xff,0xff,0xff}; //{0x11,0x11,0x11,0x11,0x11,0x11}; //ÃÜÂë
uint8_t Card_Data[16];
uint8_t status;
uint8_t flag;
uint8_t Run_flag=1;
uint8_t Lock_flag=0;
u16 led0pwmval=0;
u8 dir=1;
void bulecard(void); /*蓝卡的功能函数*/
void Pwm_init(void);/*呼吸灯函数init*/
void pwm_led(void);/*º呼吸灯函数*/
void delay(uint32_t t)
{
while(t--);
}
int main(void)
{
Card_Type1[0]=0x04;
Card_Type1[1]=0x00;
delay_init();
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //
uart_init(115200);
RC522_IO_Init();
PcdReset(); //复位引脚配置
PcdAntennaOff(); //关闭天线
delay_ms(100);
PcdAntennaOn(); //开启天线
LED_Init();//
Pwm_init();// 呼吸灯初始化
Switch_Init();
delay_ms(500);
printf("\r\n*****************************RC522*****************************\r\n");
while(Run_flag)
{
bulecard();/*¼ì²âÀ¶¿¨Èç¹û´æÔÚÒ»´Î ¾ÍµÆÁÁ ±£³ÖÒ»¸ö״̬*/
}
}
void bulecard(void)
{
if(MI_OK==PcdRequest(0x52, Card_Type1)) //Ѱ¿¨º¯Êý£¬Èç¹û³É¹¦·µ»ØMI_OK ´òÓ¡¶à´Î¿¨ºÅ
{
uint16_t cardType = (Card_Type1[0]<<8)|Card_Type1[1];//¶Á²»Í¬¿¨µÄÀàÐÍ
printf("¿¨ÀàÐÍ£º(0x%04X)\r\n",cardType); //"Card Type(0x%04X):"
switch(cardType)
{
case 0x4400:
printf("Mifare UltraLight\r\n");
break;
case 0x0400:
printf("Mifare One(S50)\r\n");
break;
case 0x0200:
printf("Mifare One(S70)\r\n");
break;
case 0x0800:
printf("Mifare Pro(X)\r\n");
break;
case 0x4403:
printf("Mifare DESFire\r\n");
break;
default:
printf("Unknown Card\r\n");
break;
}
status = PcdAnticoll(Card_ID);//·À³åײ Èç¹û³É¹¦·µ»ØMI_OK
if(status != MI_OK)
{
printf("Anticoll Error\r\n");
}else
{
printf("Serial Number:%d %d %d %d\r\n",Card_ID[0],Card_ID[1],Card_ID[2],Card_ID[3]);
flag=data_kz(Card_ID);
printf("flag=%d \r\n",flag);
flag=0; /*细节处理*/
/* 根据串口打印flag值而改*/
if(flag==0)
{
pwm_led();/*呼吸灯效果*/
}
else
BEEP_FAIL();
flag=1; /* 保证flag==0 不发生*/
}
status = PcdSelect(Card_ID); //Ñ¡¿¨ Èç¹û³É¹¦·µ»ØMI_OK
if(status != MI_OK){
printf("Select Card Error\r\n");
}
else
printf("Select Card OK\r\n");
status = PcdHalt(); //¿¨Æ¬½øÈëÐÝÃß״̬
if(status != MI_OK){
printf("PcdHalt Error\r\n");
}
else
{
printf("PcdHalt OK\r\n");
}
}
}
void Pwm_init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
GPIO_InitStruct.GPIO_Mode =GPIO_Mode_Out_PP;
GPIO_InitStruct.GPIO_Pin =GPIO_Pin_7;
GPIO_InitStruct.GPIO_Speed =GPIO_Speed_50MHz;
GPIO_Init(GPIOB,&GPIO_InitStruct);
GPIO_SetBits(GPIOA,GPIO_Pin_7);
}
void pwm_led(void)
{
unsigned int f=0;
unsigned int g=6000;
for(f=0;f<6000;f++)
{
GPIO_ResetBits(GPIOB,GPIO_Pin_7);
delay(f);
GPIO_SetBits(GPIOB,GPIO_Pin_7);
delay(g-f);
}
}
详细 可以私聊 哞哞
边栏推荐
- Ah Han's story
- MySQL index learning
- 意外收获史诗级分布式资源,从基础到进阶都干货满满,大佬就是强!
- clientY vs pageY
- Is it you who are not suitable for learning programming?
- 牛客-TOP101-BM340
- Docker advanced -redis cluster configuration in docker container
- [QNX hypervisor 2.2 user manual]9.10 pass
- els 显示一个随机方块
- Unexpected harvest of epic distributed resources, from basic to advanced are full of dry goods, big guys are strong!
猜你喜欢

JVM memory layout detailed, illustrated, well written!

Kubernetes-----介绍

MySQL索引学习

JS 事件对象 offsetX/Y clientX Y PageX Y

Why is it that when logging in, you clearly use the account information already in the database, but still display "user does not exist"?

Record of a cross domain problem

Chapter III queue

CNN training cycle reconstruction - hyperparametric test | pytorch series (XXVIII)

Center-based 3D Object Detection and Tracking(基于中心的3D目标检测和跟踪 / CenterPoint)论文笔记

JS 事件对象2 e.charcode字符码 e.keyCode键码 盒子上下左右移动
随机推荐
[wechat applet development (VI)] draw the circular progress bar of the music player
Deep residual learning for image recognition shallow reading and Implementation
MySQL essay
写英文IEEE论文的技巧
style=“width: ___“ VS width=“___“
方案分享 | 高手云集 共同探索重口音AI语音识别
Canvas from getting started to persuading friends to give up (graphic version)
Job 7.27 IO process
Docker advanced -redis cluster configuration in docker container
【微信小程序开发(六)】绘制音乐播放器环形进度条
els 定时器
Explanation of CNN circular training | pytorch series (XXII)
RTSP/Onvif协议EasyNVR视频平台一键升级方案的开发设计逻辑
NPDP candidates! The exam requirements for July 31 are here!
Flutter神操作学习之(满级攻略)
"29 years old, general function test, how do I get five offers in a week?"
Center Based 3D object detection and tracking (centerpoint) paper notes
Opengauss Developer Day 2022 sincerely invites you to visit the "database kernel SQL Engine sub forum" of Yunhe enmo
Niuke-top101-bm340
NPDP考生!7月31号考试要求在这里看!