当前位置:网站首页>基于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);
}
}
详细 可以私聊 哞哞
边栏推荐
- A brief analysis of the differences between functional testing and non functional testing, recommended by Shanghai haokoubei software testing company
- Commissioning experience of ROS
- [signal processing] weak signal detection in communication system based on the characteristics of high-order statistics with matlab code
- NPDP candidates! The exam requirements for July 31 are here!
- JVM memory layout detailed, illustrated, well written!
- 【stream】stream流基础知识
- Pychart shortcut key for quickly modifying all the same names on the whole page
- [QNX Hypervisor 2.2用户手册]9.10 pass
- Distributed transaction Senta (I)
- 数据湖:海量日志采集引擎Flume
猜你喜欢
![[image defogging] image defogging based on dark channel and non-mean filtering with matlab code](/img/39/6266eb14deac9f38b7e95f7291067e.png)
[image defogging] image defogging based on dark channel and non-mean filtering with matlab code

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

Kubernetes-----介绍

写英文IEEE论文的技巧

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

Unexpected harvest of epic distributed resources, from basic to advanced are full of dry goods, big guys are strong!

Pytest the best testing framework

"29 years old, general function test, how do I get five offers in a week?"

Skills in writing English IEEE papers

Distributed transaction Senta (I)
随机推荐
Superparameter adjustment and experiment - training depth neural network | pytorch series (26)
【微信小程序开发(五)】接口按照根据开发版体验版正式版智能配置
Consolidate the data foundation in the data center
els 键盘信息
Arm32 for remote debugging
[red team] att & CK - file hiding
Using pytorch's tensorboard visual deep learning indicators | pytorch series (25)
TFX airflow experience
Digital twin agriculture - Smart agriculture rice processing plant has changed from "watching the sky to eat" to "knowing the sky to work"
蓝桥杯原题
Intelligent industrial design software company Tianfu C round financing of hundreds of millions of yuan
JS 事件对象 offsetX/Y clientX Y PageX Y
数据中台建设(三):数据中台架构介绍
CNN training cycle reconstruction - hyperparametric test | pytorch series (XXVIII)
OA项目之我的审批(会议查询&会议签字)
【红队】ATT&CK - 文件隐藏
WEB安全基础 - - -命令执行漏洞
每日刷题巩固知识
Data Lake: flume, a massive log collection engine
Pytorch 相关-梯度回传