当前位置:网站首页>Developing rc522 module based on c8t6 chip to realize breathing lamp
Developing rc522 module based on c8t6 chip to realize breathing lamp
2022-07-28 03:48:00 【Ten years moo a sword】
RC522 modular

RFID , namely RFID yes Radio Frequency Ident ificat ion Abbreviation ,
Also known as radio frequency identification , It's one . It's a communication technology , Specific target can be identified by radio signal and related data can be read and written ,
There is no need to establish mechanical or optical contact between the recognition system and specific targets .
Work principle 
Just have a look
RFID Middleware concept 
such as linux Of cp Instructions cp xx.c xxx.c
xx.c and xxx.c The stored directory may be different
That is, the attributes of each directory are different
This leads to the concept of a virtual file system
Virtual file system is to provide a common interface
Can be realized cp Instructions
Middleware
Code
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"
/* connection ******************************************************************* STM32F103C8T6 RC522 modular PA4£¨ SPI1_NSS£ SDA PA5£¨ SPI1_SCK£ SCK PA6£¨ SPI1_MISO£ MISO PA7£¨ SPI1_MOSI£ MOSI PA11 RS RST PB1 IRQ IRQ Don't pick up 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); /* Blue card function */
void Pwm_init(void);/* Breathing lamp function init*/
void pwm_led(void);/*º Breathing lamp function */
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(); // Reset pin configuration
PcdAntennaOff(); // Turn off the antenna
delay_ms(100);
PcdAntennaOn(); // Turn on the antenna
LED_Init();//
Pwm_init();// Breathing lamp initialization
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; /* Details */
/* Print according to serial port flag Change with value */
if(flag==0)
{
pwm_led();/* Effect of breathing lamp */
}
else
BEEP_FAIL();
flag=1; /* Guarantee flag==0 It doesn't happen */
}
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);
}
}
detailed You can talk in private Moo
边栏推荐
- Greed 122. The best time to buy and sell stocks II
- Daily practice ----- realize the lottery function of two-color ball. Rules: Six non repeating numbers are randomly selected from 36 red balls, and one from 15 basketball is randomly selected to form a
- 数据挖掘-01
- Interface automation test, complete introduction
- AI chief architect 12 AICA Baidu OCR vertical large-scale landing practice
- Unity backpack system
- How to solve MySQL deep paging problem
- Appnium--APP自动化测试工具
- 数据挖掘-02
- 高等数学(第七版)同济大学 习题3-5 个人解答
猜你喜欢
随机推荐
How to solve MySQL deep paging problem
Unity backpack system
Responsive high-end website template source code Gallery material resource download platform source code
[openvx] VX for basic use of objects_ image
Day08 redis的基础知识
【OPENVX】对象基本使用之vx_lut
Leetcode 0140. word splitting II
【原型与原型链】初识原型与原型链~
接口自动化测试,完整入门篇
Dynamic planning - 1049. Weight of the last stone II
动态规划——416. 分割等和子集
[错题]Mocha and Railgun
Daily practice ----- realize the lottery function of two-color ball. Rules: Six non repeating numbers are randomly selected from 36 red balls, and one from 15 basketball is randomly selected to form a
Selenium--WEB自动化测试工具
高等数学(第七版)同济大学 习题3-4 个人解答(后8题)
Collection | 0 basic open source data visualization platform flyfish large screen development guide
基于SSM实现在线租房系统
[image classification] 2021 MLP mixer nips
Swift中的协议
8000 word explanation of OBSA principle and application practice









