当前位置:网站首页>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
边栏推荐
- 动态规划——474. 一和零
- 一文读懂Plato Farm的ePLATO,以及其高溢价缘由
- 动态规划——416. 分割等和子集
- Push chart written by helm to harbor warehouse
- 【原型与原型链】初识原型与原型链~
- Vertical align align the elements in the row are vertically centered
- 【OPENVX】对象基本使用之vx_pyramid
- 单调栈——739. 每日温度
- [paper notes] mobile robot autonomous navigation experimental platform based on deep learning
- [leetcode] 34. Find the first and last positions of elements in the sorted array
猜你喜欢

How to solve MySQL deep paging problem

In December, the PMP Exam adopted the new syllabus for the first time. How to learn?

Server memory failure prediction can actually do this!

4-day excel practical training camp, 0.01 yuan special offer for only three days, 200 sets of learning kits
![[prototype and prototype chain] get to know prototype and prototype chain~](/img/8a/d6362fdd50dc883ff817a997ab9e1e.png)
[prototype and prototype chain] get to know prototype and prototype chain~

【力扣】1337.矩阵中战斗力最弱的k行

Monotonic stack - 739. Daily temperature

BRD,MRD,PRD的区别

Collection | 0 basic open source data visualization platform flyfish large screen development guide

Dynamic planning - 63. Different paths II
随机推荐
Greed 45. Jumping game II
MangoPapa 的实用小脚本(目录篇)
STM32 RT thread virtual file system mount operation
Mouse operation and response
Advanced Mathematics (Seventh Edition) Tongji University exercises 3-4 personal solutions (the last 8 questions)
2022 summary of the latest Android handler related interview questions
Capacity expansion and reduction of RBD block storage device (VI)
【OPENVX】对象基本使用之vx_distribution
[force deduction] 1337. Row K with the weakest combat effectiveness in the matrix
Use of custom annotations
高等数学(第七版)同济大学 习题3-4 个人解答(前8题)
Common interface testing tools
test case management tool
pip-script.py‘ is not present Verifying transaction: failed
[openvx] VX for basic use of objects_ lut
面试必备杀技:SQL查询专项训练!
AI chief architect 12 AICA Baidu OCR vertical large-scale landing practice
数据挖掘-02
The latest version of pagoda installs the zip extension, and PHP -m does not display the processing method
Common weak network testing tools