当前位置:网站首页>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
边栏推荐
- 数据挖掘-02
- BRD,MRD,PRD的区别
- input 上传文件并回显 FileReader并限制选择文件时的类型
- STM32 RT thread virtual file system mount operation
- Responsive high-end website template source code Gallery material resource download platform source code
- Super easy to use PC end long screenshot tool
- Screenshot of deepstream detection results
- Lightpicture - exquisite drawing bed system
- 高等数学(第七版)同济大学 习题3-4 个人解答(前8题)
- conda虚拟环境总结与解读
猜你喜欢

【图像分类】2021-MLP-Mixer NIPS

Super nice PHP program source code of nteam official website

LightPicture – 精致图床系统

接口自动化测试,完整入门篇

MySQL Basics (create, manage, add, delete, and modify tables)

TypeError: ufunc ‘bitwise_ and‘ not supported for the input types, and the inputs could not be safely

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

Greedy - 53. Maximum subarray sum

Lightpicture - exquisite drawing bed system

【原型与原型链】初识原型与原型链~
随机推荐
单调栈——42. 接雨水——面大厂必须会的困难题
Leetcode 0141. circular linked list - three solutions
Advanced Mathematics (Seventh Edition) Tongji University exercises 3-4 personal solutions (the last 8 questions)
动态规划——62. 不同路径
Leetcode 0140. word splitting II
Greed 122. The best time to buy and sell stocks II
【OPENVX】对象基本使用之vx_pyramid
Tensorboard usage record
Prefix-Tuning: Optimizing Continuous Prompts for Generation
静态博客搭建工具汇总
Monotonic stack - 739. Daily temperature
基于SSM实现在线租房系统
[prototype and prototype chain] get to know prototype and prototype chain~
Capacity expansion and reduction of RBD block storage device (VI)
Selenium--WEB自动化测试工具
LightPicture – 精致图床系统
[错题]Mocha and Railgun
Dynamic planning - 63. Different paths II
贪心——45. 跳跃游戏 II
[image classification] 2021 MLP mixer nips