当前位置:网站首页>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
边栏推荐
- A 404 page source code imitating win10 blue screen
- Greedy - 53. Maximum subarray sum
- Recursion and non recursion are used to calculate the nth Fibonacci number respectively
- WordPress simple mkblog blog theme template v2.1
- Qt:QMessageBox消息框、自定义信号和槽
- 一个仿win10蓝屏的404页面源码
- Implementation of online rental system based on SSM
- 8000 word explanation of OBSA principle and application practice
- Lightpicture - exquisite drawing bed system
- Dynamic programming - 416. Segmentation and subsets
猜你喜欢

常用的接口测试工具

贪心——53. 最大子数组和
![[force deduction] 1337. Row K with the weakest combat effectiveness in the matrix](/img/6c/b5fd3350886fd74557439f5361e7f8.png)
[force deduction] 1337. Row K with the weakest combat effectiveness in the matrix

ES6 from getting started to mastering 08: extended object functions

Protocols in swift

Leetcode58. 最后一个单词的长度

leetcode刷题:动态规划09(最后一块石头的重量 II)

高等数学(第七版)同济大学 习题3-5 个人解答

高等数学(第七版)同济大学 习题3-4 个人解答(前8题)
![[leetcode] 34. Find the first and last positions of elements in the sorted array](/img/f0/3eaa33fa7b13abe5f27b136239507d.png)
[leetcode] 34. Find the first and last positions of elements in the sorted array
随机推荐
Container related concepts
In December, the PMP Exam adopted the new syllabus for the first time. How to learn?
Practical scripts of mangopapa (contents)
Vertical align align the elements in the row are vertically centered
conda虚拟环境总结与解读
How to solve MySQL deep paging problem
【P4】 查看库文件两个历史版本的区别
【原型与原型链】初识原型与原型链~
LeetCode 0141. 环形链表 - 三种方法解决
95后阿里P7晒出工资单:真的是狠狠扎心了...
Dynamic programming - 509. Fibonacci number
Mysql基础篇(创建、管理、增删改表)
[openvx] VX for basic use of objects_ matrix
《剑指offer》| 刷题小记
LightPicture – 精致图床系统
贪心——45. 跳跃游戏 II
Volvo: what on earth does the deep-rooted "sense of security" rely on?
Leetcode 0141. circular linked list - three solutions
单调栈——739. 每日温度
Day08 redis的基础知识