nRF5 SDK v11.0.0
Typedefs | Enumerations | Functions
NFC Type 2 Tag HAL

nRF52 only: Hardware abstraction layer for the NFC Type 2 Tag library. More...

Typedefs

typedef void(* hal_nfc_callback )(void *context, hal_nfc_event event, const char *data, size_t dataLength)
 Callback from HAL_NFC layer into upper layer. More...
 

Enumerations

enum  hal_nfc_retval {
  HAL_NFC_RETVAL_OK,
  HAL_NFC_RETVAL_ERROR,
  HAL_NFC_RETVAL_INVALID_SIZE,
  HAL_NFC_RETVAL_TIMEOUT
}
 Return values generated by HAL_NFC functions.
 
enum  hal_nfc_event {
  HAL_NFC_EVENT_FIELD_ON,
  HAL_NFC_EVENT_FIELD_OFF,
  HAL_NFC_EVENT_DATA_RECEIVED,
  HAL_NFC_EVENT_DATA_TRANSMITTED
}
 Events passed to upper-layer callback function.
 
enum  hal_nfc_param_id {
  HAL_NFC_PARAM_ID_TESTING,
  HAL_NFC_PARAM_ID_UNKNOWN
}
 Parameter IDs for set/get function.
 

Functions

hal_nfc_retval hal_nfc_setup (hal_nfc_callback callback, void *cbContext)
 Function for initializing the NFC layer. More...
 
hal_nfc_retval hal_nfc_set_parameter (hal_nfc_param_id id, void *data, size_t dataLength)
 Function for setting a HAL_NFC parameter. More...
 
hal_nfc_retval hal_nfc_get_parameter (hal_nfc_param_id id, void *data, size_t *maxDataLength)
 Function for querying a HAL_NFC parameter value. More...
 
hal_nfc_retval hal_nfc_start (void)
 Function for starting the NFC subsystem. More...
 
hal_nfc_retval hal_nfc_send (const char *data, size_t dataLength)
 Function for sending a packet to the connected NFC reader. More...
 
hal_nfc_retval hal_nfc_stop (void)
 Function for stopping the NFC subsystem. More...
 
hal_nfc_retval hal_nfc_done (void)
 Function for releasing resources. More...
 

Detailed Description

nRF52 only: Hardware abstraction layer for the NFC Type 2 Tag library.

Typedef Documentation

typedef void(* hal_nfc_callback)(void *context, hal_nfc_event event, const char *data, size_t dataLength)

Callback from HAL_NFC layer into upper layer.

If event == HAL_NFC_EVENT_DATA_RECEIVED: data points to the received packet. The memory belongs to the HAL_NFC layer and is guaranteed to be valid only until the callback returns.

If event == HAL_NFC_EVENT_DATA_TRANSMITTED: data points to the transmitted packet. The memory belongs to the application.

If event == <Other event>: data definition is event-specific (to be defined).

Parameters
contextContext for callback execution.
eventThe event that occurred.
dataReceived/transmitted data or NULL.
dataLengthSize of the received/transmitted packet.

Function Documentation

hal_nfc_retval hal_nfc_done ( void  )

Function for releasing resources.

After this call returns, the callback is considered invalid and no more events will be posted to it.

Return values
OKThis function always succeeds.
hal_nfc_retval hal_nfc_get_parameter ( hal_nfc_param_id  id,
void *  data,
size_t *  maxDataLength 
)

Function for querying a HAL_NFC parameter value.

The queried value will be placed into the passed data buffer. If the buffer is too small, maxDataLength will contain the required buffer size.

Parameters
idID of the parameter to query.
dataPointer to a buffer receiving the queried data.
maxDataLengthSize of the buffer, receives needed size if buffer is too small.
Return values
OKIf the parameter was received successfully. If one of the arguments was invalid (for example, the buffer was too small), an error code is returned.
hal_nfc_retval hal_nfc_send ( const char *  data,
size_t  dataLength 
)

Function for sending a packet to the connected NFC reader.

The provided data buffer belongs to the caller and is guaranteed to be valid until the HAL_NFC_EVENT_DATA_TRANSMITTED event is received by the callback.

Parameters
dataThe data packet to send.
dataLengthSize of the packet in bytes.
Return values
OKIf the packet was sent. Otherwise, an error code is returned.
hal_nfc_retval hal_nfc_set_parameter ( hal_nfc_param_id  id,
void *  data,
size_t  dataLength 
)

Function for setting a HAL_NFC parameter.

This function allows to set any parameter defined as available by HAL_NFC.

Parameters
idID of the parameter to set.
dataPointer to a buffer containing the data to set.
dataLengthSize of the buffer containing the data to set.
Return values
OKIf the parameter was set successfully. If one of the arguments was invalid (for example, a wrong data length), an error code is returned.
hal_nfc_retval hal_nfc_setup ( hal_nfc_callback  callback,
void *  cbContext 
)

Function for initializing the NFC layer.

This function provides a pointer to a callback function and the callback context to the NFC layer.

Parameters
callbackPointer to the callback function.
cbContextContext of callback.
Return values
OKIf the NFC layer was initialized successfully. If one of the arguments was invalid, an error code is returned.
hal_nfc_retval hal_nfc_start ( void  )

Function for starting the NFC subsystem.

After this function completes, NFC readers will be able to detect the chip.

Return values
OKIf the NFC subsystem was started successfully. If the NFC subsystem could not be started, an error code is returned.
hal_nfc_retval hal_nfc_stop ( void  )

Function for stopping the NFC subsystem.

After this function returns, NFC readers will no longer be able to connect to the chip.

Return values
OKIf the NFC subsystem was stopped. Otherwise, an error code is returned.

Documentation feedback | Developer Zone | Updated