nfc4 2.0.0.0
NFC 4 Click Driver

API for configuring and manipulating NFC 4 Click driver. More...

Topics

 NFC 4 Registers List
 List of registers of NFC 4 Click driver.
 
 NFC 4 Registers Settings
 Settings for registers of NFC 4 Click driver.
 
 NFC 4 MikroBUS Map
 MikroBUS pin mapping of NFC 4 Click driver.
 

Functions

void nfc4_cfg_setup (nfc4_cfg_t *cfg)
 NFC 4 configuration object setup function.
 
void nfc4_drv_interface_selection (nfc4_cfg_t *cfg, nfc4_drv_t drv_sel)
 NFC 4 driver interface setup function.
 
err_t nfc4_init (nfc4_t *ctx, nfc4_cfg_t *cfg)
 NFC 4 initialization function.
 
err_t nfc4_default_cfg (nfc4_t *ctx)
 NFC 4 default configuration function.
 
err_t nfc4_generic_write (nfc4_t *ctx, uint8_t reg, uint8_t *data_in, uint16_t len)
 NFC 4 data writing function.
 
err_t nfc4_generic_read (nfc4_t *ctx, uint8_t reg, uint8_t *data_out, uint16_t len)
 NFC 4 data reading function.
 
err_t nfc4_send_direct_command (nfc4_t *ctx, uint8_t cmd)
 NFC 4 send direct command function.
 
err_t nfc4_send_direct_command_with_result (nfc4_t *ctx, uint8_t cmd, uint8_t result_reg, uint32_t timeout, uint8_t *result)
 NFC 4 send direct command with result function.
 
err_t nfc4_write_register (nfc4_t *ctx, uint8_t reg, uint8_t data_in)
 NFC 4 write register function.
 
err_t nfc4_read_register (nfc4_t *ctx, uint8_t reg, uint8_t *data_out)
 NFC 4 read register function.
 
err_t nfc4_write_multiple_registers (nfc4_t *ctx, uint8_t reg, uint8_t *data_in, uint16_t len)
 NFC 4 write multiple registers function.
 
err_t nfc4_read_multiple_registers (nfc4_t *ctx, uint8_t reg, uint8_t *data_out, uint16_t len)
 NFC 4 read multiple registers function.
 
err_t nfc4_clear_register_bits (nfc4_t *ctx, uint8_t reg, uint8_t clr_mask)
 NFC 4 clear register bits function.
 
err_t nfc4_set_register_bits (nfc4_t *ctx, uint8_t reg, uint8_t set_mask)
 NFC 4 set register bits function.
 
err_t nfc4_modify_register_bits (nfc4_t *ctx, uint8_t reg, uint8_t clr_mask, uint8_t set_mask)
 NFC 4 modify register bits function.
 
err_t nfc4_write_fifo (nfc4_t *ctx, uint8_t *data_in, uint16_t len)
 NFC 4 write fifo function.
 
err_t nfc4_read_fifo (nfc4_t *ctx, uint8_t *data_out, uint16_t len)
 NFC 4 read fifo function.
 
err_t nfc4_write_test_register (nfc4_t *ctx, uint8_t reg, uint8_t data_in)
 NFC 4 write test register function.
 
err_t nfc4_read_test_register (nfc4_t *ctx, uint8_t reg, uint8_t *data_out)
 NFC 4 read test register function.
 
err_t nfc4_modify_test_register_bits (nfc4_t *ctx, uint8_t reg, uint8_t clr_mask, uint8_t set_mask)
 NFC 4 modify test register bits function.
 
err_t nfc4_enable_interrupt (nfc4_t *ctx, uint32_t mask)
 NFC 4 enable interrupt function.
 
err_t nfc4_disable_interrupt (nfc4_t *ctx, uint32_t mask)
 NFC 4 disable interrupt function.
 
err_t nfc4_clear_interrupts (nfc4_t *ctx)
 NFC 4 clear interrupts function.
 
err_t nfc4_check_for_received_interrupts (nfc4_t *ctx)
 NFC 4 check for received interrupts function.
 
uint32_t nfc4_wait_for_interrupt (nfc4_t *ctx, uint32_t mask, uint32_t timeout)
 NFC 4 wait for interrupt function.
 
uint32_t nfc4_get_interrupt (nfc4_t *ctx, uint32_t mask)
 NFC 4 get interrupt function.
 
err_t nfc4_check_chip_id (nfc4_t *ctx, uint8_t *revision)
 NFC 4 check chip ID function.
 
err_t nfc4_enable_osc (nfc4_t *ctx)
 NFC 4 enable oscillator and regulator function.
 
err_t nfc4_measure_voltage (nfc4_t *ctx, uint8_t mpsv_src, uint16_t *res_mv)
 NFC 4 measure voltage function.
 
uint8_t nfc4_get_irq_pin (nfc4_t *ctx)
 NFC 4 get irq pin function.
 
err_t nfc4_get_mifare_tag_uid (nfc4_t *ctx, uint8_t *uid, uint8_t *uid_len)
 NFC 4 get mifare tag UID function.
 

Detailed Description

API for configuring and manipulating NFC 4 Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ nfc4_cfg_setup()

void nfc4_cfg_setup ( nfc4_cfg_t * cfg)

NFC 4 configuration object setup function.

This function initializes click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See nfc4_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ nfc4_check_chip_id()

err_t nfc4_check_chip_id ( nfc4_t * ctx,
uint8_t * revision )

NFC 4 check chip ID function.

This function checks if the chip ID is as expected. 5 bit IC type code for ST25R3916: 00101, the 3 lsb contain the IC revision code.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[out]revision: The IC revision code.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_check_for_received_interrupts()

err_t nfc4_check_for_received_interrupts ( nfc4_t * ctx)

NFC 4 check for received interrupts function.

This function checks the received interrupts and saves the result into the int_status variable of the click context object structure.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_clear_interrupts()

err_t nfc4_clear_interrupts ( nfc4_t * ctx)

NFC 4 clear interrupts function.

This function clears all interrupt flags.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_clear_register_bits()

err_t nfc4_clear_register_bits ( nfc4_t * ctx,
uint8_t reg,
uint8_t clr_mask )

NFC 4 clear register bits function.

This function clears the given bitmask on the selected register.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]reg: Register address.
[in]clr_mask: Bitmask of bits to be cleared.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_default_cfg()

err_t nfc4_default_cfg ( nfc4_t * ctx)

NFC 4 default configuration function.

This function executes a default configuration of NFC 4 click board.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ nfc4_disable_interrupt()

err_t nfc4_disable_interrupt ( nfc4_t * ctx,
uint32_t mask )

NFC 4 disable interrupt function.

This function disables all interrupts given by mask, NFC4_IRQ_MASK_ALL disables all interrupts.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]mask: Mask indicating the interrupts to be disabled.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_drv_interface_selection()

void nfc4_drv_interface_selection ( nfc4_cfg_t * cfg,
nfc4_drv_t drv_sel )

NFC 4 driver interface setup function.

This function sets a serial driver interface which will be used further in the click driver.

Parameters
[out]cfg: Click configuration structure. See nfc4_cfg_t object definition for detailed explanation.
[in]drv_sel: Driver interface selection. See nfc4_drv_t object definition for detailed explanation.
Returns
Nothing.
Note
This driver selection should be call before init function to configure the driver to work with the serial interface which is consistent with the real state of the hardware. If this function is not called, the default driver interface will be set.

◆ nfc4_enable_interrupt()

err_t nfc4_enable_interrupt ( nfc4_t * ctx,
uint32_t mask )

NFC 4 enable interrupt function.

This function enables all interrupts given by mask, NFC4_IRQ_MASK_ALL enables all interrupts.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]mask: Mask indicating the interrupts to be enabled.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_enable_osc()

err_t nfc4_enable_osc ( nfc4_t * ctx)

NFC 4 enable oscillator and regulator function.

This function turns on oscillator and regulator and waits for the oscillator to become stable.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_generic_read()

err_t nfc4_generic_read ( nfc4_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint16_t len )

NFC 4 data reading function.

This function reads a desired number of data bytes starting from the selected register.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]reg: Start register address.
[out]data_out: Output read data.
[in]len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_generic_write()

err_t nfc4_generic_write ( nfc4_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint16_t len )

NFC 4 data writing function.

This function writes a desired number of data bytes starting from the selected register.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]reg: Start register address.
[in]data_in: Data to be written.
[in]len: Number of bytes to be written.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_get_interrupt()

uint32_t nfc4_get_interrupt ( nfc4_t * ctx,
uint32_t mask )

NFC 4 get interrupt function.

This function is used to check whether the interrupt given by mask is set in the int_status variable of the click context object structure. If yes the interrupt gets cleared. This function returns only status bits which are inside mask.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]mask: Mask indicating the interrupts to check for.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_get_irq_pin()

uint8_t nfc4_get_irq_pin ( nfc4_t * ctx)

NFC 4 get irq pin function.

This function returns the IRQ pin logic state.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
Returns
Pin logic state.
Note
None.

◆ nfc4_get_mifare_tag_uid()

err_t nfc4_get_mifare_tag_uid ( nfc4_t * ctx,
uint8_t * uid,
uint8_t * uid_len )

NFC 4 get mifare tag UID function.

This function reads the UID of a mifare tag.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[out]uid: Mifare tag UID (up to 10 bytes).
[out]uid_len: Tag UID length in bytes.
Returns
  • 0 - Success - Tag UID read successfully,
  • -1 - Error - There's no tag detected.
See #err_t definition for detailed explanation.
Note
This function should be called in a loop.

◆ nfc4_init()

err_t nfc4_init ( nfc4_t * ctx,
nfc4_cfg_t * cfg )

NFC 4 initialization function.

This function initializes all necessary pins and peripherals used for this click board.

Parameters
[out]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See nfc4_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_measure_voltage()

err_t nfc4_measure_voltage ( nfc4_t * ctx,
uint8_t mpsv_src,
uint16_t * res_mv )

NFC 4 measure voltage function.

This function measures the voltage on one of VDD and VDD_* and returns the result in mV.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]mpsv_src: one of NFC4_REGULATOR_CTRL_MPSV_VDD, NFC4_REGULATOR_CTRL_MPSV_VDD_A, NFC4_REGULATOR_CTRL_MPSV_VDD_D, NFC4_REGULATOR_CTRL_MPSV_VDD_RF, NFC4_REGULATOR_CTRL_MPSV_VDD_AM.
[out]res_mv: The measured voltage in mV.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_modify_register_bits()

err_t nfc4_modify_register_bits ( nfc4_t * ctx,
uint8_t reg,
uint8_t clr_mask,
uint8_t set_mask )

NFC 4 modify register bits function.

This function modifies desired bits of the selected register.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]reg: Register address.
[in]clr_mask: Bitmask of bits to be cleared.
[in]set_mask: Bitmask of bits to be set.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_modify_test_register_bits()

err_t nfc4_modify_test_register_bits ( nfc4_t * ctx,
uint8_t reg,
uint8_t clr_mask,
uint8_t set_mask )

NFC 4 modify test register bits function.

This function modifies desired bits of the selected test register.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]reg: Test register address.
[in]clr_mask: Bitmask of bits to be cleared.
[in]set_mask: Bitmask of bits to be set.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_read_fifo()

err_t nfc4_read_fifo ( nfc4_t * ctx,
uint8_t * data_out,
uint16_t len )

NFC 4 read fifo function.

This function reads a desired number of data bytes from FIFO.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[out]data_out: Output read data.
[in]len: Number of data bytes (up to 512).
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_read_multiple_registers()

err_t nfc4_read_multiple_registers ( nfc4_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint16_t len )

NFC 4 read multiple registers function.

This function reads a desired number of data bytes starting from the selected register.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]reg: Start register address.
[out]data_out: Output read data.
[in]len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_read_register()

err_t nfc4_read_register ( nfc4_t * ctx,
uint8_t reg,
uint8_t * data_out )

NFC 4 read register function.

This function reads a desired data from the selected register.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]reg: Register address.
[out]data_out: Output data read.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_read_test_register()

err_t nfc4_read_test_register ( nfc4_t * ctx,
uint8_t reg,
uint8_t * data_out )

NFC 4 read test register function.

This function reads a desired data from the selected test register.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]reg: Test register address.
[out]data_out: Output data read.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_send_direct_command()

err_t nfc4_send_direct_command ( nfc4_t * ctx,
uint8_t cmd )

NFC 4 send direct command function.

This function is used to start so-called direct command. These commands are implemented inside the chip and each command has unique code (see datasheet).

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]cmd: Code of the direct command to be executed.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_send_direct_command_with_result()

err_t nfc4_send_direct_command_with_result ( nfc4_t * ctx,
uint8_t cmd,
uint8_t result_reg,
uint32_t timeout,
uint8_t * result )

NFC 4 send direct command with result function.

This function executes the direct command given by cmd waits for timeout for I_dct and returns the result read from register result_reg. The value of cmd is not checked.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]cmd: Code of the direct command to be executed.
[in]result_reg: Address of the register containing the result.
[in]timeout: Time in microseconds to wait before reading the result.
[out]resultResult.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_set_register_bits()

err_t nfc4_set_register_bits ( nfc4_t * ctx,
uint8_t reg,
uint8_t set_mask )

NFC 4 set register bits function.

This function sets the given bitmask on the selected register.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]reg: Register address.
[in]set_mask: Bitmask of bits to be set.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_wait_for_interrupt()

uint32_t nfc4_wait_for_interrupt ( nfc4_t * ctx,
uint32_t mask,
uint32_t timeout )

NFC 4 wait for interrupt function.

This function checks the received interrupts and waits for maximal timeout ( microseconds ) for the first interrupt indicated with mask to occur.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]mask: Mask indicating the interrupts to wait for.
[in]timeout: Time in microseconds until timeout occurs.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_write_fifo()

err_t nfc4_write_fifo ( nfc4_t * ctx,
uint8_t * data_in,
uint16_t len )

NFC 4 write fifo function.

This function writes a desired number of data bytes to FIFO.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]data_in: Data to be written.
[in]len: Number of data bytes (up to 512).
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_write_multiple_registers()

err_t nfc4_write_multiple_registers ( nfc4_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint16_t len )

NFC 4 write multiple registers function.

This function writes a desired number of data bytes starting from the selected register.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]reg: Start register address.
[in]data_in: Data to be written.
[in]len: Number of bytes to be written.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_write_register()

err_t nfc4_write_register ( nfc4_t * ctx,
uint8_t reg,
uint8_t data_in )

NFC 4 write register function.

This function writes a desired data to the selected register.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]reg: Register address.
[in]data_in: Data to be written.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc4_write_test_register()

err_t nfc4_write_test_register ( nfc4_t * ctx,
uint8_t reg,
uint8_t data_in )

NFC 4 write test register function.

This function writes a desired data to the selected test register.

Parameters
[in]ctx: Click context object. See nfc4_t object definition for detailed explanation.
[in]reg: Test register address.
[in]data_in: Data to be written.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.