![]() |
NHS31xx SW API
|
Near Field Communication (NFC) driver provides the API to control the functionalities handled by the NFC HW block. The NFC driver provides the following functionalities:
Data Structures | |
struct | NSS_NFC_T |
Macros | |
#define | NFC_SHARED_MEM_BYTE_SIZE (int)(sizeof(NSS_NFC->BUF)) |
#define | NFC_SHARED_MEM_WORD_SIZE (NFC_SHARED_MEM_BYTE_SIZE / 4) |
#define | NFC_SHARED_MEM_START (int)(NSS_NFC->BUF) |
#define | NFC_SHARED_MEM_END (NFC_SHARED_MEM_START + NFC_SHARED_MEM_BYTE_SIZE -1) |
Enumerations | |
enum | NFC_INT_T { NFC_INT_RFPOWER = (1 << 0), NFC_INT_RFSELECT = (1 << 1), NFC_INT_MEMREAD = (1 << 2), NFC_INT_MEMWRITE = (1 << 3), NFC_INT_CMDWRITE = (1 << 4), NFC_INT_CMDREAD = (1 << 5), NFC_INT_TARGETWRITE = (1 << 6), NFC_INT_TARGETREAD = (1 << 7), NFC_INT_NFCOFF = (1 << 8), NFC_INT_NONE = 0, NFC_INT_ALL = 0x1FF } |
enum | NFC_STATUS_T { NFC_STATUS_POR = (1 << 0), NFC_STATUS_1V2 = (1 << 1), NFC_STATUS_1V5 = (1 << 2), NFC_STATUS_PLL = (1 << 3), NFC_STATUS_SEL = (1 << 4), NFC_STATUS_AUTH = (1 << 5), NFC_STATUS_BYPASS = (1 << 6) } |
Functions | |
void | Chip_NFC_Init (NSS_NFC_T *pNFC) |
void | Chip_NFC_DeInit (NSS_NFC_T *pNFC) |
NFC_STATUS_T | Chip_NFC_GetStatus (NSS_NFC_T *pNFC) |
void | Chip_NFC_Int_SetEnabledMask (NSS_NFC_T *pNFC, NFC_INT_T mask) |
NFC_INT_T | Chip_NFC_Int_GetEnabledMask (NSS_NFC_T *pNFC) |
NFC_INT_T | Chip_NFC_Int_GetRawStatus (NSS_NFC_T *pNFC) |
void | Chip_NFC_Int_ClearRawStatus (NSS_NFC_T *pNFC, NFC_INT_T flags) |
void | Chip_NFC_SetTargetAddress (NSS_NFC_T *pNFC, uint32_t offset) |
uint32_t | Chip_NFC_GetTargetAddress (NSS_NFC_T *pNFC) |
bool | Chip_NFC_GetLastAccessInfo (NSS_NFC_T *pNFC, uint32_t *pStartOffset, uint32_t *pEndOffset) |
bool | Chip_NFC_WordWrite (NSS_NFC_T *pNFC, uint32_t *pDest, const uint32_t *pSrc, int n) |
bool | Chip_NFC_ByteRead (NSS_NFC_T *pNFC, uint8_t *pDest, const uint8_t *pSrc, int n) |
struct NSS_NFC_T |
Near Field Communication (NFC) register block structure (APB side)
Data Fields | ||
---|---|---|
__IO uint32_t | CFG |
Configuration register. |
__I uint32_t | SR |
NFC status register. |
__I uint32_t | CMDIN |
NFC incoming command. The driver does not provide functions to access this register |
__O uint32_t | DATAOUT |
NFC outgoing command. The driver does not provide functions to access this register |
__IO uint32_t | TARGET |
NFC target page address register. |
__I uint32_t | LAST_ACCESS |
NFC last accessed page register. |
__IO uint32_t | IMSC |
Interrupt mask register. |
__I uint32_t | RIS |
Raw Interrupt status register. |
__I uint32_t | MIS |
Masked Interrupt status register. |
__O uint32_t | IC |
Interrupt Clear register. |
__IO uint32_t | RESERVED0[54] | |
__IO uint32_t | BUF[128] |
Shared memory buffer memory space, located at offset 0x100-0x2FC (128 words of 4 bytes each). |
#define NFC_SHARED_MEM_BYTE_SIZE (int)(sizeof(NSS_NFC->BUF)) |
NFC shared RAM size in bytes.
#define NFC_SHARED_MEM_WORD_SIZE (NFC_SHARED_MEM_BYTE_SIZE / 4) |
NFC shared RAM size in 32bit words.
#define NFC_SHARED_MEM_START (int)(NSS_NFC->BUF) |
NFC shared RAM start address.
#define NFC_SHARED_MEM_END (NFC_SHARED_MEM_START + NFC_SHARED_MEM_BYTE_SIZE -1) |
NFC shared RAM end address.
enum NFC_INT_T |
NFC interrupt flags provides the information as listed below. The flag can be set using Chip_NFC_Int_SetEnabledMask. The status of the interrupt can be retrieved using Chip_NFC_Int_GetRawStatus. Clearing of the flag can be done using Chip_NFC_Int_ClearRawStatus.
Enumerator | |
---|---|
NFC_INT_RFPOWER | RFID power is detected. |
NFC_INT_RFSELECT | Tag is selected by reader. |
NFC_INT_MEMREAD | Reader reads from shared memory. |
NFC_INT_MEMWRITE | Reader writes to shared memory. |
NFC_INT_CMDWRITE | Reader writes to NSS_NFC_T.CMDIN register. |
NFC_INT_CMDREAD | Reader reads the NSS_NFC_T.DATAOUT register. |
NFC_INT_TARGETWRITE | Reader writes to address specified in the NSS_NFC_T.TARGET register. |
NFC_INT_TARGETREAD | Reader reads from address specified in the NSS_NFC_T.TARGET register. |
NFC_INT_NFCOFF | NFC front-end is powered down by external reader. |
NFC_INT_NONE | De-selects all Interrupts |
NFC_INT_ALL | Selects all Interrupts |
enum NFC_STATUS_T |
NFC HW block status flags provides information on the NFC HW block as listed below. This can be retrieved using Chip_NFC_GetStatus.
void Chip_NFC_Init | ( | NSS_NFC_T * | pNFC | ) |
Initializes the NFC HW block. The function disables the NFC interrupt internally and also clears any pending interrupts. Any previously written NDEF message will be lost due to initialization of shared memory.
pNFC | : The base address of the NFC peripheral on the chip |
void Chip_NFC_DeInit | ( | NSS_NFC_T * | pNFC | ) |
De-initializes NFC HW block. The function disables the NFC interrupt internally and also clears any pending interrupts. This will overwrite any NDEF message that was previously present with default values.
pNFC | : The base address of the NFC peripheral on the chip |
NFC_STATUS_T Chip_NFC_GetStatus | ( | NSS_NFC_T * | pNFC | ) |
Returns the status information from the NFC block
pNFC | : The base address of the NFC peripheral on the chip |
Enables/Disables the NFC interrupts.
pNFC | : The base address of the NFC peripheral on the chip |
mask | : Interrupt enabled mask to set |
Retrieves the NFC interrupt enabled mask
pNFC | : The base address of the NFC peripheral on the chip |
Retrieves a bitVector with the RAW NFC interrupt flags
pNFC | : The base address of the NFC peripheral on the chip |
Clears the required NFC interrupt flags
pNFC | : The base address of the NFC peripheral on the chip |
flags | : Bitvector indicating which interrupt flags to clear |
void Chip_NFC_SetTargetAddress | ( | NSS_NFC_T * | pNFC, |
uint32_t | offset | ||
) |
Sets the target address used for interrupt generation
pNFC | : The base address of the NFC peripheral on the chip |
offset | : 32-bit word offset from start of BUF |
uint32_t Chip_NFC_GetTargetAddress | ( | NSS_NFC_T * | pNFC | ) |
Returns the target address used for interrupt generation
pNFC | : The base address of the NFC peripheral on the chip |
bool Chip_NFC_GetLastAccessInfo | ( | NSS_NFC_T * | pNFC, |
uint32_t * | pStartOffset, | ||
uint32_t * | pEndOffset | ||
) |
Returns the start and end 32-bit word offset from start of BUF and the direction of last RF access
pNFC | : The base address of the NFC peripheral on the chip | |
[out] | pStartOffset | : Start word offset for last RF access |
[out] | pEndOffset | : Last accessed word offset for last RF access |
true
for write access.false
for read access.bool Chip_NFC_WordWrite | ( | NSS_NFC_T * | pNFC, |
uint32_t * | pDest, | ||
const uint32_t * | pSrc, | ||
int | n | ||
) |
Writes a block of words to the BUF, and returns success/failure of write operation. Failure indicates corruption of written data due to RF access.
pNFC | : The base address of the NFC peripheral on the chip |
pDest | : Destination address in BUF |
pSrc | : Source buffer address (32 bit word aligned) |
n | : Number of words |
true
for successful write.false
for write failure.bool Chip_NFC_ByteRead | ( | NSS_NFC_T * | pNFC, |
uint8_t * | pDest, | ||
const uint8_t * | pSrc, | ||
int | n | ||
) |
Reads a block of bytes from the BUF, and returns success/failure of read operation. Failure indicates corruption of read data due to RF access.
pNFC | : The base address of the NFC peripheral on the chip |
pDest | : Destination buffer address |
pSrc | : Source address in BUF |
n | : Number of bytes |
true
for successful read.false
for read corruption.