標(biāo)題: stm32 RC522 RFID讀卡器源碼 [打印本頁]

作者: 其木王王子    時(shí)間: 2017-12-27 09:42
標(biāo)題: stm32 RC522 RFID讀卡器源碼
stm32的單片機(jī)源程序如下:
  1. #include "stm32f10x.h"
  2. #include "bsp_SysTick.h"
  3. #include "bsp_usart1.h"
  4. #include "rc522_config.h"
  5. #include "rc522_function.h"
  6. #include <stdbool.h>
  7. #include "bsp_lcd.h"



  8. void IC_test ( void )
  9. {
  10.         char cStr [ 30 ];
  11.   u8 ucArray_ID [ 4 ];                                                                                             //先后存放IC卡的類型和UID(IC卡序列號(hào))
  12.         u8 ucStatusReturn;                                                                                               //返回狀態(tài)
  13.   static u8 ucLineCount = 0;
  14.        
  15.        
  16.   while ( 1 )
  17.   {
  18.                 if ( ( ucStatusReturn = PcdRequest ( PICC_REQALL, ucArray_ID ) ) != MI_OK )                                    //尋卡
  19.                         ucStatusReturn = PcdRequest ( PICC_REQALL, ucArray_ID );                                                                 //若失敗再次尋卡

  20.                 if ( ucStatusReturn == MI_OK  )
  21.                 {
  22.                         if ( PcdAnticoll ( ucArray_ID ) == MI_OK )                                                                   //防沖撞(當(dāng)有多張卡進(jìn)入讀寫器操作范圍時(shí),防沖突機(jī)制會(huì)從其中選擇一張進(jìn)行操作)
  23.                         {
  24.                                 sprintf ( cStr, "The Card ID is: %02X%02X%02X%02X", ucArray_ID [ 0 ], ucArray_ID [ 1 ], ucArray_ID [ 2 ], ucArray_ID [ 3 ] );
  25.                                
  26.                                
  27.                                 printf ( "%s\r\n",cStr );
  28.                                

  29.                                 if ( ucLineCount == 0 )
  30.                                   ILI9341_Clear ( 0, 0, 240, 271, macBACKGROUND);       
  31.                                
  32.                                 ILI9341_DispString_EN ( 0, ucLineCount * 16, cStr, macBACKGROUND, macBLUE );
  33.                                
  34.                                 ucLineCount ++;
  35.                                
  36.                                 if ( ucLineCount == 17 ) ucLineCount = 0;
  37.                                
  38.                                
  39.                         }
  40.                        
  41.                 }
  42.                
  43.   }
  44.        
  45.        
  46. }




  47. /**
  48.   * @brief  主函數(shù)
  49.   * @param  無
  50.   * @retval 無
  51.   */
  52. int main ( void )
  53. {
  54.         SysTick_Init ();   //滴答時(shí)鐘初始化
  55.        
  56.         USART1_Config ();  //USART1 配置模式為 115200 8-N-1,中斷接收
  57.        
  58.         RC522_Init ();     //RC522模塊所需外設(shè)的初始化配置
  59.        
  60.         LCD_Init ();         //LCD 初始化
  61.        
  62.        
  63.         printf ( "WF-RC522 Test\n" );
  64.        
  65.        
  66.         ILI9341_Clear ( 0,   0, 240, 320, macBACKGROUND);       
  67.         ILI9341_Clear ( 0, 272, 240,   2, macGREEN);
  68.         ILI9341_DispString_EN ( 0, 280, "Please put the IC card on WF-RC522 antenna area ...", macBACKGROUND, macRED );
  69.        
  70.        
  71.         PcdReset ();
  72.         M500PcdConfigISOType ( 'A' );//設(shè)置工作方式
  73.        
  74.        
  75.   while ( 1 )
  76.   {
  77.     IC_test ();//IC卡檢測(cè)       

  78.   }
  79.        
  80.        
  81. }


  82. /****************************END OF FILE**********************/

復(fù)制代碼

所有資料51hei提供下載:
ISO-V2.rar (322.06 KB, 下載次數(shù): 68)




作者: jxchen    時(shí)間: 2019-1-20 21:03

下載學(xué)習(xí),謝謝分享




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1