The MCUXpresso SDK provides a driver for the RFID/NFC communication unit
The NFC HW block is based on a MIFARE Ultralight EV1 block which is responsible for the wireless NFC communication with an external reader.
The IC has a shared memory region which is overlayed on the EEPROM area of the MIFARE Ultralight EV1 block. The NFC shared memory can be accessed by the ARM core over the APB bus and also by an external contact-less reader. The access by the ARM core will henceforth be referred to as "APB side access" and the access by an external reader as "RF side access". The exchange of data over the RF from an external reader and the MIFARE Ultralight EV1 block is in units of pages which is of 4 bytes in size. The memory organization of the MIFARE Ultralight EV1 block is also in the same manner. The first 4 pages is an EEPROM block and that can only be accessed from the RF side and not from the APB side. The next 128 pages is the shared memory and that can be accessed from both the RF side as well as the APB side.
The NFC driver only provides simple and basic functions to operate NFC registers, upper layer should handle the complex cases. For example, the shared memory could be accessed by both RF side and APB side, upper layer should make sure the content consistency.
|
enum | _nfc_interrupts {
kNFC_RFPowerInterrupt = RFIDNFC_MIS_RFPOWER_MASK,
kNFC_RFSelectInterrupt = RFIDNFC_MIS_RFSELECT_MASK,
kNFC_MemReadInterrupt = RFIDNFC_MIS_MEMREAD_MASK,
kNFC_MemWriteInterrupt = RFIDNFC_MIS_MEMWRITE_MASK,
kNFC_CmdWriteInterrupt = RFIDNFC_MIS_CMDWRITE_MASK,
kNFC_CmdReadInterrupt = RFIDNFC_MIS_CMDREAD_MASK,
kNFC_TargetWriteInterrupt = RFIDNFC_MIS_TARGETWRITE_MASK,
kNFC_TargetReadInterrupt,
kNFC_NFCOffInterrupt = RFIDNFC_MIS_NFCOFF_MASK,
kNFC_AllInterrupt
} |
| NFC interrupts. More...
|
|
enum | _nfc_flags {
kNFC_PORFlag = RFIDNFC_SR_POR_MASK,
kNFC_1V2Flag = RFIDNFC_SR_R1V2_MASK,
kNFC_1V5Flag = RFIDNFC_SR_R1V5_MASK,
kNFC_PllFlag = RFIDNFC_SR_PLL_MASK,
kNFC_SelFlag = RFIDNFC_SR_SEL_MASK,
kNFC_AuthFlag = RFIDNFC_SR_AUTH_MASK,
kNFC_BypassFlag = RFIDNFC_SR_BYPASS_MASK,
kNFC_AllFlag
} |
| NFC status flags. More...
|
|
enum | nfc_access_t {
kNFC_Read,
kNFC_Write
} |
| NFC shared memory access type by the reader. More...
|
|
|
void | NFC_WritePage (RFIDNFC_Type *base, uint32_t pageIndex, const uint32_t *data, uint32_t numPage) |
| Writes to the shared memory. More...
|
|
void | NFC_ReadPage (RFIDNFC_Type *base, uint32_t pageIndex, uint32_t *data, uint32_t numPage) |
| Read from the shared memory. More...
|
|
#define NFC_SHARED_MEM_PAGE_COUNT ((sizeof(((RFIDNFC_Type *)0)->SHARED_MEM)) / NFC_PAGE_SIZE_BYTE) |
Enumerator |
---|
kNFC_RFPowerInterrupt |
RFID power is detected.
|
kNFC_RFSelectInterrupt |
Tag is selected by reader.
|
kNFC_MemReadInterrupt |
Reader reads from shared memory.
|
kNFC_MemWriteInterrupt |
Reader writes to shared memory.
|
kNFC_CmdWriteInterrupt |
Reader writes to CMDIN register.
|
kNFC_CmdReadInterrupt |
Reader reads the DATAOUT register.
|
kNFC_TargetWriteInterrupt |
Reader writes to address specified by NFC_SetTargetAddress>
|
kNFC_TargetReadInterrupt |
Reader reads from address specified by NFC_SetTargetAddress.
|
kNFC_NFCOffInterrupt |
NFC front-end is powered down by external reader.
|
kNFC_AllInterrupt |
All NFC interrupts.
|
Enumerator |
---|
kNFC_PORFlag |
Indicates that the NFC analog core has been powered ON.
|
kNFC_1V2Flag |
Indicates a warning that VDD_RFID is < 1.2 V.
|
kNFC_1V5Flag |
Indicates a warning that VDD_RFID is < 1.5 V.
|
kNFC_PllFlag |
Indicates that NFC PLL has been locked.
|
kNFC_SelFlag |
Indicates that the NFC block has been activated via ISO/IEC 14443 Type A commands.
Or in other words the MIFARE Ultralight EV1 block has reached the ACTIVE state in it's state machine. All memory operations falling under MIFARE Ultralight EV1 command set can now be carried out over the RF.
|
kNFC_AuthFlag |
Indicates that password authentication is successful.
All memory operations to password protected regions can now be carried out over the RF.
|
kNFC_BypassFlag |
Indicates that the NFC interface is in bypass mode.
|
kNFC_AllFlag |
All flags.
|
Enumerator |
---|
kNFC_Read |
Share memory read by reader.
|
kNFC_Write |
Share memory written by reader.
|
void NFC_Init |
( |
RFIDNFC_Type * |
base | ) |
|
This function initializes the peripheral, and resets the NFC registers status. Any previously written NDEF message will be lost due to initialization of shared memory.
- Parameters
-
base | NFC peripheral base address. |
void NFC_DeInit |
( |
RFIDNFC_Type * |
base | ) |
|
- Parameters
-
base | NFC peripheral base address. |
static void NFC_EnableInterrupts |
( |
RFIDNFC_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | NFC peripheral base address. |
mask | Interrupts to enable. OR'ed value of the _nfc_interrupts. |
static void NFC_DisableInterrupts |
( |
RFIDNFC_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | NFC peripheral base address. |
mask | Interrupts to disable. OR'ed value of the _nfc_interrupts. |
static uint32_t NFC_GetEnabledInterrupts |
( |
RFIDNFC_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | NFC peripheral base address. |
- Returns
- Interrupts enabled. OR'ed value of the _nfc_interrupts.
static uint32_t NFC_GetInterruptStatus |
( |
RFIDNFC_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | NFC peripheral base address. |
- Returns
- Interrupts pending status. OR'ed value of the _nfc_interrupts.
static void NFC_ClearInterruptStatus |
( |
RFIDNFC_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | NFC peripheral base address. |
mask | Interrupts status to clear. OR'ed value of the _nfc_interrupts. |
void NFC_WritePage |
( |
RFIDNFC_Type * |
base, |
|
|
uint32_t |
pageIndex, |
|
|
const uint32_t * |
data, |
|
|
uint32_t |
numPage |
|
) |
| |
- Parameters
-
base | NFC peripheral base address. |
pageIndex | : Start page to write. |
data | : Address of the data to write. |
numPage | : Number of pages to write. |
- Warning
- Because the shared memory could be access by the RF too, upper layer sould make sure no write conflict.
void NFC_ReadPage |
( |
RFIDNFC_Type * |
base, |
|
|
uint32_t |
pageIndex, |
|
|
uint32_t * |
data, |
|
|
uint32_t |
numPage |
|
) |
| |
- Parameters
-
base | NFC peripheral base address. |
pageIndex | : Start page to read. |
data | : Address of the data to read. |
numPage | : Number of pages to read. |
- Warning
- Because the shared memory could be access by the RF too, upper layer sould make sure RF is not writing the same pages during core reading.
static uint32_t NFC_GetStatusFlag |
( |
RFIDNFC_Type * |
base | ) |
|
|
inlinestatic |
Returns the status information from the NFC block
- Parameters
-
base | : The base address of the NFC peripheral on the chip |
- Returns
- Status of the NFC HW block.
static void NFC_SetTargetAddress |
( |
RFIDNFC_Type * |
base, |
|
|
uint32_t |
pageIndex |
|
) |
| |
|
inlinestatic |
nfc_access_t NFC_GetLastAccessInfo |
( |
RFIDNFC_Type * |
base, |
|
|
int32_t * |
pStartPageIndex, |
|
|
int32_t * |
pEndPageIndex |
|
) |
| |
- Parameters
-
| base | NFC peripheral base address. |
[out] | pStartPageIndex | : Start page index for last RF access |
[out] | pEndPageIndex | : Last accessed page index for last RF access |
- Returns
- Access type.