RC522串口驱动代码
时间: 2023-09-14 15:10:52 浏览: 223
RC522驱动源码
以下是一个使用串口进行RC522读写的驱动程序的示例代码:
```c
#include "stm32f10x.h"
#include "uart.h"
#include "sys.h"
#include "rc522.h"
int main(void) {
u8 IC\[50\] = {0};
delay_init();
UART1_init();
delay_ms(2000);
RC522_Init();
printf("RC522_UART_TEST...\r\n");
printf("写卡开始...\r\n");
while(!RC522_WRITE((u8 *)"12121212")){};
printf("写卡成功...\r\n");
while(1){
if(RC522_READ(IC)){
printf("%s\r\n",IC);
delay_ms(500);
}
delay_ms(100);
printf("waitting...\r\n");
}
}
```
这段代码是在Linux系统下编写MF-RC522模块驱动的示例。它使用了串口进行通信,并配合应用层完成IC卡号的读取、扇区的读写和密码验证等操作。该代码是针对友善之臂Tiny4412开发板和三星的EXYNOS4412芯片编写的,没有采用SPI子系统,而是直接控制IO口模拟SPI时序与MF-RC522进行通信。代码中包含了写卡和读卡的测试,经过亲测可以正常使用。
#### 引用[.reference_title]
- *1* *3* [STM32 RC522串口驱动程序 (简单直接)](https://blog.csdn.net/qq_42074368/article/details/109316451)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [Linux驱动开发-编写RFID-RC522射频刷卡模块驱动](https://blog.csdn.net/m0_67401545/article/details/123626524)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文