找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3006|回复: 2
收起左侧

MFRC522+esp8266+stm32测试程序

[复制链接]
ID:290707 发表于 2018-3-12 11:46 | 显示全部楼层 |阅读模式


1. 利用位带操作,重写按键扫描;
2. KEY1:查询余额;
3. KEY2:充值;
4. KEY3:扣款;

要求:
一上电:串口输出:

***************************
1. KEY1:查询余额;
2. KEY2:充值;
3. KEY3:扣款;
**************************

利用串口,输入要充值的金额;
利用串口,输入要消费的金额;

0.png
单片机源程序如下:
  1. /**********************RC522实验开发板例程************************

  2. /------------------------------------------------*/
  3. //#include "lpcreg.h"
  4. #include "mfrc522.h"
  5. #include  <STDIO.H>
  6. #include <string.h>
  7. #include "delay.h"
  8. #include "usart.h"
  9. #include "core_cm4.h"
  10. #include "key.h"
  11. #include "ESP8266.h"
  12. #include "exti.h"
  13. #include "AT24C02.h"
  14. #include "W25Q64.h"
  15. #include "lcd.h"
  16. #include "pic.h"
  17. #include "sram.h"
  18. #include "touch.h"
  19. #include "rtc.h"
  20. #include "iwdg.h"
  21. #include "wwdg.h"
  22. #include "dma.h"
  23. #include "adc.h"

  24. //unsigned char  data1[16] = {0x12,0x34,0x56,0x78,0xED,0xCB,0xA9,0x87,0x12,0x34,0x56,0x78,0x01,0xFE,0x01,0xFE};
  25. ////M1卡的某一块写为如下格式,则该块为钱包,可接收扣款和充值命令
  26. ////4字节金额(低字节在前)+4字节金额取反+4字节金额+1字节块地址+1字节块地址取反+1字节块地址+1字节块地址取反
  27. //unsigned char data2[4]  = {0,0,0,0x01};
  28. //unsigned char DefaultKey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

  29. //unsigned char g_ucTempbuf[20];

  30. //函数声明
  31. //void Disp_Info(void);
  32. //void Block_Proc(u32 dat,u8 addr);

  33. const unsigned char *p = NULL;


  34. u16 sram_buf[100] __attribute__((at(0x68000000)));

  35. int main( )
  36. {   
  37.         u8 ret = 0;
  38.         u8 dat = 0;
  39.         u16 times = 0;
  40.         u16 col = 0;
  41.         u16 i,j;
  42.         u8 key = 0xff;
  43.        
  44.         char buf[20] = "hello,xyd!\r\n";
  45.         char buf1[20] = {0};
  46.         char buf2[20] = "hello,STM32F407!\r\n";

  47.         NVIC_SetPriorityGrouping(7-2);
  48.        
  49.         RCC522_init();
  50.         Key_Init();
  51.         Usart1_Init(9600);
  52.         ESP8266_Init();
  53.         LED_Init();
  54.         AT24C02_Init();                                                //24c02初始化
  55.         W25Q64_Init();
  56.         LCD_Init();
  57.         SRAM_Init();
  58.         ADC1_CH4_Init();
  59.        
  60.        
  61. //        TS_Init();
  62. //        rtc_init();
  63. //        iwdg_init();
  64. //        wwdg_init();
  65.        
  66. //        DMA_Usart1Tx_Init();
  67. //        DMA_Usart1Rx_Init();
  68. //        Usart1_EnableDMA();
  69.        

  70.         //将字库所在的1M空间保护起来
  71.         W25Q64_WriteStatusReg(PROTECT_TOP_1M);

  72.         while(1)
  73.         {
  74. //                key = Key_Scan();
  75. //                if(key == KEY1_DOWN)
  76. //                        DMA_Usart1Tx_Conf((u32 *)buf2,sizeof(buf2));
  77.         }       
  78. }

复制代码


所有资料51hei提供下载:
MFRC522测试程序.rar (1.02 MB, 下载次数: 60)
回复

使用道具 举报

ID:251494 发表于 2018-4-3 12:38 | 显示全部楼层
谢谢楼主的分享
回复

使用道具 举报

ID:272722 发表于 2018-6-24 19:56 | 显示全部楼层
被扣了2次分,一次内部错误, 不是8266直接SPI读写MRC522的,是STM32 用AT透传方式读取MRC522,然后给8266发送的。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表