标题: stm32 RFID-RC522识别卡片例程(各大开发板的程序汇总) [打印本页]

作者: 1016399120    时间: 2018-10-22 01:40
标题: stm32 RFID-RC522识别卡片例程(各大开发板的程序汇总)
在学习RFID-RC522过程中总总结一些历程,希望对大家有所帮助。


所有资料51hei提供下载:
RFID-RC522各大开发板配套例程.rar (2.46 MB, 下载次数: 231)

stm32单片机源程序如下:
  1. #include "stm32f10x.h"
  2. #include "./usart/bsp_usart.h"        
  3. #include "./lcd/bsp_ili9341_lcd.h"
  4. #include "./flash/bsp_spi_flash.h"
  5. #include "./SysTick/bsp_SysTick.h"
  6. #include "rc522_config.h"
  7. #include "rc522_function.h"
  8. #include <stdbool.h>


  9. /**
  10.   * @brief  IC测试函数
  11.   * @param  无
  12.   * @retval 无
  13.   */
  14. void IC_test ( void )
  15. {
  16.         char cStr [ 30 ];
  17.   uint8_t ucArray_ID [ 4 ];    /*先后存放IC卡的类型和UID(IC卡序列号)*/                                                                                         
  18.         uint8_t ucStatusReturn;      /*返回状态*/                                                                                          
  19.   static uint8_t ucLineCount = 0;

  20.   while ( 1 )
  21.   {
  22.                
  23.     /*寻卡*/
  24.                 if ( ( ucStatusReturn = PcdRequest ( PICC_REQALL, ucArray_ID ) ) != MI_OK )  
  25.        /*若失败再次寻卡*/
  26.                         ucStatusReturn = PcdRequest ( PICC_REQALL, ucArray_ID );                                                               

  27.                 if ( ucStatusReturn == MI_OK  )
  28.                 {
  29.       /*防冲撞(当有多张卡进入读写器操作范围时,防冲突机制会从其中选择一张进行操作)*/
  30.                         if ( PcdAnticoll ( ucArray_ID ) == MI_OK )                                                                  
  31.                         {
  32.                                 sprintf ( cStr, "The Card ID is: %02X%02X%02X%02X",
  33.                   ucArray_ID [ 0 ],
  34.                   ucArray_ID [ 1 ],
  35.                   ucArray_ID [ 2 ],
  36.                   ucArray_ID [ 3 ] );
  37.         
  38.                 printf ( "%s\r\n",cStr );         
  39.                                 
  40.                                 if ( ucLineCount == 0 )
  41.           LCD_SetTextColor(RED);         
  42.                                 
  43.                                 ILI9341_DispStringLine_EN(LINE(ucLineCount) , (char* )cStr );
  44.       
  45.                                 
  46.                                 ucLineCount ++;
  47.                                 
  48.                                 if ( ucLineCount == 17 ) ucLineCount = 0;                                
  49.                         }               
  50.                 }               
  51.   }        
  52. }

  53. /**
  54.   * @brief  主函数
  55.   * @param  无
  56.   * @retval 无
  57.   */
  58. int main(void)
  59. {        
  60.   /*滴答时钟初始化*/
  61.   SysTick_Init ();     
  62.         /*LCD 初始化*/
  63.         ILI9341_Init ();         

  64.         /* USART config */
  65.         USART_Config();
  66.   
  67.   /*RC522模块所需外设的初始化配置*/
  68.   RC522_Init ();     
  69.         
  70.   printf ( "WF-RC522 Test\n" );
  71.         
  72.   /*其中0、3、5、6 模式适合从左至右显示文字,*/
  73.         ILI9341_GramScan ( 6 );
  74.   LCD_SetFont(&Font8x16);
  75.         LCD_SetColors(BLACK,BLACK);
  76.   
  77.   /* 清屏,显示全黑 */
  78.   ILI9341_Clear(0,0,LCD_X_LENGTH,LCD_Y_LENGTH);
  79.   
  80.         /********显示字符串示例*******/
  81.   LCD_SetTextColor(RED);  

  82.   ILI9341_DispStringLine_EN(LINE(18),
  83.        (char* )"Please put the IC card on WF-RC522 antenna area ...");
  84.   
  85.   LCD_SetTextColor(YELLOW);
  86.   
  87.   PcdReset ();
  88.    
  89.   /*设置工作方式*/   
  90.         M500PcdConfigISOType ( 'A' );
  91.   
  92.   while(1)
  93.   {
  94.     /*IC卡检测        */   
  95.     IC_test ();               
  96.   }

  97. }


  98. /* ------------------------------------------end of file---------------------------------------- */
复制代码


作者: admin    时间: 2018-11-2 15:18
好资料,51黑有你更精彩!!!
作者: woshige    时间: 2018-11-19 15:18
资料有了 但是还是调试不成功啊 难受
作者: wjordan    时间: 2021-1-6 17:23
好资料,51黑有你更精彩!!!




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1