//Search card begin, return 0x01 if card is present
do {
UART_1_CmdReset(); // Reset Command Buffer
for (i=0;i<15;i++)
{
UART_1_PutChar(0x01); // Send a character to UART TX port
}
Delay50uTimes(1);
c = UART_1_cGetChar();
}while (c == 0);
//Search card end, return 0x01 if card is present
if (c == 0x01)//check the card available
{
LCD_clr_line(0);
LCD_clr_line(1);
LCD_1_Position(0,0);
LCD_1_PrCString("Card in ");
UART_1_CmdReset(); // Reset Command Buffer
//send AB 02 01 until get a valid response begin
do {
for (i=0;i<3;i++)
{
UART_1_PutChar(sel_card[i]); // Send a character to UART TX port
}
Delay50uTimes(1);
//Waits for a valid character in UART RX and returns its value.
byte_length = UART_1_cGetChar();
}while (byte_length == 0);
//send AB 02 01 until get a valid response end
//Returns length of characters in the command buffer. This command returns the current command
//length, whether a command terminator has been received or not.
byte_length = UART_1_bCmdLength();
LCD_1_PrHexByte(byte_length);
for (i=0;i<byte_length;i++)
{
RxdataBuff[i] = UART_1_cGetChar(); // Get a character from UART RX data register
}