Hi,
when running the BasicDiscoveryLoop example you should get similar print out for Mifrare Ultralight like:
BasicDiscoveryLoop Example:
Card detected and activated successfully...
Technology : Type A
Card: 1
UID : 04 FD 7D 49 5B 23 80
SAK : 0x00
Type: Type 2 Tag
To enhance this example for reading Mifare Ultralight tags, you need to add a few lines of code:
Add the include for the additional Application Layer header:
#include <phalMful.h>
Declare one more AL variable:
phalMful_Sw_DataParams_t salMful;
Add it as a global variable after declaring the PAL variables.
In function NfcRdLibInit() add a initialization for the MFUL AL component. Add the following line after phpalMifare_Sw_Init():
/* Initialize the Mful AL component */
status = phalMful_Sw_Init(&salMful, sizeof(phalMful_Sw_DataParams_t), &spalMifare, NULL, NULL, NULL);
CHECK_STATUS(status);
In function BasicDiscoveryLoop_Demo() we will now perform the actual read operation.
First we need to add two more variable. So at the beginning of the function add:
uint8_t bTagType;
uint8_t bDataBuffer[PHAL_MFUL_READ_BLOCK_LENGTH];
Finally we can start with the read operation.
Search for these lines:
/* Get Detected Technology Type */
status = phacDiscLoop_GetConfig(pDataParams, PHAC_DISCLOOP_CONFIG_TECH_DETECTED, &wTagsDetected);
CHECK_STATUS(status);
PrintTagInfo(pDataParams, wNumberOfTags, wTagsDetected);
After these lines add the following code:
/* Check for Type A tag detection */
if (PHAC_DISCLOOP_CHECK_ANDMASK(wTagsDetected, PHAC_DISCLOOP_POS_BIT_MASK_A))
{
/* Bit b3 is set to zero, [Digital] 4.8.2 */
/* Mask out all other bits except for b7 and b6 */
bTagType = (sDiscLoop.sTypeATargetInfo.aTypeA_I3P3[0].aSak & 0x60);
bTagType = bTagType >> 5;
/* Check for Type 2 Tag */
if (bTagType == PHAC_DISCLOOP_TYPEA_TYPE2_TAG_CONFIG_MASK)
{
/* Read page 0x05, 0x06, 0x07 and 0x08 */
status = phalMful_Read(&salMful, 0x05, bDataBuffer);
PRINT_BUFF(&bDataBuffer[0], 16);
}
}
The read operation is done in line 13. In this code, page 0x05, 0x06, 0x07 and 0x08 are read. During one read operation always 16 Bytes or 4 pages are read. To start reading from another page you simply need to change the value.
Hope that helps,
Michael