stm32的單片機源程序如下:- #include "stm32f10x.h"
- #include "bsp_SysTick.h"
- #include "bsp_usart1.h"
- #include "rc522_config.h"
- #include "rc522_function.h"
- #include <stdbool.h>
- #include "bsp_lcd.h"
- void IC_test ( void )
- {
- char cStr [ 30 ];
- u8 ucArray_ID [ 4 ]; //先后存放IC卡的類型和UID(IC卡序列號)
- u8 ucStatusReturn; //返回狀態
- static u8 ucLineCount = 0;
-
-
- while ( 1 )
- {
- if ( ( ucStatusReturn = PcdRequest ( PICC_REQALL, ucArray_ID ) ) != MI_OK ) //尋卡
- ucStatusReturn = PcdRequest ( PICC_REQALL, ucArray_ID ); //若失敗再次尋卡
- if ( ucStatusReturn == MI_OK )
- {
- if ( PcdAnticoll ( ucArray_ID ) == MI_OK ) //防沖撞(當有多張卡進入讀寫器操作范圍時,防沖突機制會從其中選擇一張進行操作)
- {
- sprintf ( cStr, "The Card ID is: %02X%02X%02X%02X", ucArray_ID [ 0 ], ucArray_ID [ 1 ], ucArray_ID [ 2 ], ucArray_ID [ 3 ] );
-
-
- printf ( "%s\r\n",cStr );
-
- if ( ucLineCount == 0 )
- ILI9341_Clear ( 0, 0, 240, 271, macBACKGROUND);
-
- ILI9341_DispString_EN ( 0, ucLineCount * 16, cStr, macBACKGROUND, macBLUE );
-
- ucLineCount ++;
-
- if ( ucLineCount == 17 ) ucLineCount = 0;
-
-
- }
-
- }
-
- }
-
-
- }
- /**
- * @brief 主函數
- * @param 無
- * @retval 無
- */
- int main ( void )
- {
- SysTick_Init (); //滴答時鐘初始化
-
- USART1_Config (); //USART1 配置模式為 115200 8-N-1,中斷接收
-
- RC522_Init (); //RC522模塊所需外設的初始化配置
-
- LCD_Init (); //LCD 初始化
-
-
- printf ( "WF-RC522 Test\n" );
-
-
- ILI9341_Clear ( 0, 0, 240, 320, macBACKGROUND);
- ILI9341_Clear ( 0, 272, 240, 2, macGREEN);
- ILI9341_DispString_EN ( 0, 280, "Please put the IC card on WF-RC522 antenna area ...", macBACKGROUND, macRED );
-
-
- PcdReset ();
- M500PcdConfigISOType ( 'A' );//設置工作方式
-
-
- while ( 1 )
- {
- IC_test ();//IC卡檢測
- }
-
-
- }
- /****************************END OF FILE**********************/
復制代碼
所有資料51hei提供下載:
ISO-V2.rar
(322.06 KB, 下載次數: 68)
2017-12-27 09:42 上傳
點擊文件名下載附件
|