Hardware abstraction layer for the NFC Type 2 Tag library. More...
Modules | |
Hardware Abstraction Layer for NFC library. configuration | |
Typedefs | |
typedef void(* | hal_nfc_callback_t )(void *p_context, hal_nfc_event_t event, const uint8_t *p_data, size_t data_length) |
Callback from HAL_NFC layer into the upper layer. More... | |
Enumerations | |
enum | hal_nfc_event_t { HAL_NFC_EVENT_FIELD_ON, HAL_NFC_EVENT_FIELD_OFF, HAL_NFC_EVENT_DATA_RECEIVED, HAL_NFC_EVENT_DATA_TRANSMITTED, HAL_NFC_EVENT_FIELD_ON, HAL_NFC_EVENT_FIELD_OFF, HAL_NFC_EVENT_DATA_RECEIVED, HAL_NFC_EVENT_DATA_TRANSMITTED } |
Events passed to the upper-layer callback function. More... | |
enum | hal_nfc_param_id_t { HAL_NFC_PARAM_ID_TESTING, HAL_NFC_PARAM_ID_NFCID1, HAL_NFC_PARAM_ID_UNKNOWN, HAL_NFC_PARAM_ID_TESTING, HAL_NFC_PARAM_FWI, HAL_NFC_PARAM_SELRES, HAL_NFC_PARAM_NFCID1, HAL_NFC_PARAM_DID, HAL_NFC_PARAM_ID_UNKNOWN } |
Parameter IDs for set/get function. More... | |
Functions | |
ret_code_t | hal_nfc_setup (hal_nfc_callback_t callback, void *p_context) |
Function for initializing the NFC layer. More... | |
ret_code_t | hal_nfc_parameter_set (hal_nfc_param_id_t id, void *p_data, size_t data_length) |
Function for setting a HAL_NFC parameter. More... | |
ret_code_t | hal_nfc_parameter_get (hal_nfc_param_id_t id, void *p_data, size_t *p_max_data_length) |
Function for querying a HAL_NFC parameter value. More... | |
ret_code_t | hal_nfc_start (void) |
Function for starting the NFC subsystem. More... | |
ret_code_t | hal_nfc_send (const uint8_t *p_data, size_t data_length) |
Function for sending a packet to the connected NFC reader. More... | |
ret_code_t | hal_nfc_stop (void) |
Function for stopping the NFC subsystem. More... | |
ret_code_t | hal_nfc_done (void) |
Function for releasing resources. More... | |
Hardware abstraction layer for the NFC Type 2 Tag library.
typedef void(* hal_nfc_callback_t)(void *p_context, hal_nfc_event_t event, const uint8_t *p_data, size_t data_length) |
Callback from HAL_NFC layer into the upper layer.
If event == HAL_NFC_EVENT_DATA_RECEIVED: p_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: p_data points to the transmitted packet. The memory belongs to the application.
If event == <Other event>: p_data definition is event-specific (to be defined).
[in] | p_context | Context for callback execution. |
[in] | event | The event that occurred. |
[in] | p_data | Received/transmitted data or NULL. |
[in] | data_length | Size of the received/transmitted packet. |
enum hal_nfc_event_t |
Events passed to the upper-layer callback function.
enum hal_nfc_param_id_t |
Parameter IDs for set/get function.
Enumerator | |
---|---|
HAL_NFC_PARAM_ID_TESTING |
Used for unit tests. |
HAL_NFC_PARAM_ID_NFCID1 |
NFCID1 value, data can be 4, 7, or 10 bytes long (single, double, or triple size). To use default NFCID1 of specific length pass one byte containing requested length. Default 7-byte NFCID1 will be used if this parameter was not set. This parameter can be set before nfc_t2t_setup() to set initial NFCID1 and it can be changed later. |
HAL_NFC_PARAM_ID_TESTING |
Used for unit tests. |
HAL_NFC_PARAM_FWI |
Frame Wait Time parameter. |
HAL_NFC_PARAM_SELRES |
Parameter for setting the 'Protocol' bits for SEL_RES packet. |
HAL_NFC_PARAM_NFCID1 |
NFCID1 value, data can be 4, 7, or 10 bytes long (simple, double, or triple size). To use default NFCID1 of specific length pass one byte containing requested length. Default 7-byte NFCID1 will be used if this parameter was not set before nfc_t4t_setup(). |
HAL_NFC_PARAM_DID |
Parameter for DID field management. |
ret_code_t 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.
NRF_SUCCESS | This function always succeeds. |
ret_code_t hal_nfc_parameter_get | ( | hal_nfc_param_id_t | id, |
void * | p_data, | ||
size_t * | p_max_data_length | ||
) |
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.
[in] | id | ID of the parameter to query. |
[in] | p_data | Pointer to a buffer receiving the queried data. |
[in,out] | p_max_data_length | Size of the buffer. It receives the required size if buffer is too small. |
NRF_SUCCESS | If the parameter was received successfully. If one of the arguments was invalid (for example, the buffer was too small), an error code is returned. |
ret_code_t hal_nfc_parameter_set | ( | hal_nfc_param_id_t | id, |
void * | p_data, | ||
size_t | data_length | ||
) |
Function for setting a HAL_NFC parameter.
This function allows to set any parameter defined as available by HAL_NFC.
[in] | id | ID of the parameter to set. |
[in] | p_data | Pointer to the buffer containing the data to set. |
[in] | data_length | Size of the buffer containing the data to set. |
NRF_SUCCESS | If the parameter was set successfully. If one of the arguments was invalid (for example, wrong data length), an error code is returned. |
ret_code_t hal_nfc_send | ( | const uint8_t * | p_data, |
size_t | data_length | ||
) |
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.
[in] | p_data | Pointer to the memory area in RAM containing data packet to send. |
[in] | data_length | Size of the packet in bytes. |
NRF_SUCCESS | If the packet was sent. Otherwise, an error code is returned. |
ret_code_t hal_nfc_setup | ( | hal_nfc_callback_t | callback, |
void * | p_context | ||
) |
Function for initializing the NFC layer.
This function provides a pointer to a callback function and the callback context to the NFC layer.
[in] | callback | Pointer to the callback function. |
[in] | p_context | Context of callback. |
NRF_SUCCESS | If the NFC layer was initialized successfully. If one of the arguments was invalid, an error code is returned. |
ret_code_t hal_nfc_start | ( | void | ) |
Function for starting the NFC subsystem.
After this function completes, NFC readers will be able to detect the chip.
NRF_SUCCESS | If the NFC subsystem was started successfully. If the NFC subsystem could not be started, an error code is returned. |
ret_code_t 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.
NRF_SUCCESS | If the NFC subsystem was stopped. Otherwise, an error code is returned. |