|
#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"
#include "./font/fonts.h"
/**
* @brief 測試函數(shù)
* @param 無
* @retval 無
*/
void IC_test ( void )
{
//char cStr [ 30 ];
uint8_t ucArray_ID [ 4 ]; /*先后存放IC卡的類型和UID(IC卡序列號)*/
uint8_t ucStatusReturn; /*返回狀態(tài) */
char asc_16[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
static uint8_t ucLineCount = 0;
while ( 1 )
{ //printf ( "ready");
/*尋卡*/
if ( ( ucStatusReturn = PcdRequest ( PICC_REQALL, ucArray_ID ) ) != MI_OK )
/*若失敗再次尋卡*/
ucStatusReturn = PcdRequest ( PICC_REQALL, ucArray_ID );
if ( ucStatusReturn == MI_OK )
{
/*防沖撞(當(dāng)有多張卡進(jìn)入讀寫器操作范圍時,防沖突機(jī)制會從其中選擇一張進(jìn)行操作)*/
if ( PcdAnticoll ( ucArray_ID ) == MI_OK )
{
printf ("The Card ID is: %c\n\n",
asc_16[ucArray_ID [ 0 ]/16]
);
//printf ( "%s\r\n",cStr );
//ILI9341_DispStringLine_EN(LINE(ucLineCount), cStr );
ucLineCount ++;
if ( ucLineCount == 10 ) ucLineCount = 0;
}
}
}
}
/**
* @brief 主函數(shù)
* @param 無
* @retval 無
*/
int main ( void )
{
/*滴答時鐘初始化*/
SysTick_Init ();
/*USART1 配置模式為 115200 8-N-1,中斷接收 */
USART1_Config ();
/*RC522模塊所需外設(shè)的初始化配置*/
RC522_Init ();
/*LCD 初始化*/
//LCD_Init ();
//ILI9341_GramScan ( 6 );
printf ( "WF-RC522 Test\n" );
//LCD_SetFont(&Font8x16);
//LCD_SetColors(RED,BLACK);
/* 清屏,顯示全黑 */
//ILI9341_Clear(0,0,LCD_X_LENGTH,LCD_Y_LENGTH);
//ILI9341_DispStringLine_EN(LINE(13),
printf("Please put the IC card on WF-RC522 antenna area ..." );
//LCD_SetTextColor(BLUE);
PcdReset ();
/*設(shè)置工作方式*/
M500PcdConfigISOType ( 'A' );
while ( 1 )
{
/*IC卡檢測 */
IC_test ();
}
}
/****************************END OF FILE**********************/
|
|