nfc5  2.1.0.0
Modules | Functions
NFC 5 Click Driver

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

Modules

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

Functions

void nfc5_cfg_setup (nfc5_cfg_t *cfg)
 NFC 5 configuration object setup function. More...
 
void nfc5_drv_interface_sel (nfc5_cfg_t *cfg, nfc5_drv_t drv_sel)
 NFC 5 driver interface setup function. More...
 
err_t nfc5_init (nfc5_t *ctx, nfc5_cfg_t *cfg)
 NFC 5 initialization function. More...
 
err_t nfc5_default_cfg (nfc5_t *ctx)
 NFC 5 default configuration function. More...
 
err_t nfc5_generic_write (nfc5_t *ctx, uint8_t reg, uint8_t *data_in, uint16_t len)
 NFC 5 data writing function. More...
 
err_t nfc5_generic_read (nfc5_t *ctx, uint8_t reg, uint8_t *data_out, uint16_t len)
 NFC 5 data reading function. More...
 
err_t nfc5_send_cmd (nfc5_t *ctx, uint8_t cmd)
 NFC 5 send direct command function. More...
 
err_t nfc5_send_cmd_with_res (nfc5_t *ctx, uint8_t cmd, uint8_t result_reg, uint32_t timeout, uint8_t *result)
 NFC 5 send direct command with result function. More...
 
err_t nfc5_write_reg (nfc5_t *ctx, uint8_t reg, uint8_t data_in)
 NFC 5 write register function. More...
 
err_t nfc5_read_reg (nfc5_t *ctx, uint8_t reg, uint8_t *data_out)
 NFC 5 read register function. More...
 
err_t nfc5_write_regs (nfc5_t *ctx, uint8_t reg, uint8_t *data_in, uint16_t len)
 NFC 5 write multiple registers function. More...
 
err_t nfc5_read_regs (nfc5_t *ctx, uint8_t reg, uint8_t *data_out, uint16_t len)
 NFC 5 read multiple registers function. More...
 
err_t nfc5_clear_reg_bits (nfc5_t *ctx, uint8_t reg, uint8_t clr_mask)
 NFC 5 clear register bits function. More...
 
err_t nfc5_set_reg_bits (nfc5_t *ctx, uint8_t reg, uint8_t set_mask)
 NFC 5 set register bits function. More...
 
err_t nfc5_modify_reg_bits (nfc5_t *ctx, uint8_t reg, uint8_t clr_mask, uint8_t set_mask)
 NFC 5 modify register bits function. More...
 
err_t nfc5_write_fifo (nfc5_t *ctx, uint8_t *data_in, uint16_t len)
 NFC 5 write fifo function. More...
 
err_t nfc5_read_fifo (nfc5_t *ctx, uint8_t *data_out, uint16_t len)
 NFC 5 read fifo function. More...
 
err_t nfc5_write_test_register (nfc5_t *ctx, uint8_t reg, uint8_t data_in)
 NFC 5 write test register function. More...
 
err_t nfc5_read_test_register (nfc5_t *ctx, uint8_t reg, uint8_t *data_out)
 NFC 5 read test register function. More...
 
err_t nfc5_modify_test_reg_bits (nfc5_t *ctx, uint8_t reg, uint8_t clr_mask, uint8_t set_mask)
 NFC 5 modify test register bits function. More...
 
err_t nfc5_enable_interrupt (nfc5_t *ctx, uint32_t mask)
 NFC 5 enable interrupt function. More...
 
err_t nfc5_disable_interrupt (nfc5_t *ctx, uint32_t mask)
 NFC 5 disable interrupt function. More...
 
err_t nfc5_clear_interrupts (nfc5_t *ctx)
 NFC 5 clear interrupts function. More...
 
err_t nfc5_check_interrupts (nfc5_t *ctx)
 NFC 5 check for received interrupts function. More...
 
uint32_t nfc5_wait_interrupt (nfc5_t *ctx, uint32_t mask, uint32_t timeout)
 NFC 5 wait for interrupt function. More...
 
uint32_t nfc5_get_interrupt (nfc5_t *ctx, uint32_t mask)
 NFC 5 get interrupt function. More...
 
err_t nfc5_check_chip_id (nfc5_t *ctx, uint8_t *revision)
 NFC 5 check chip ID function. More...
 
err_t nfc5_enable_osc (nfc5_t *ctx)
 NFC 5 enable oscillator and regulator function. More...
 
err_t nfc5_measure_voltage (nfc5_t *ctx, uint8_t mpsv_src, uint16_t *res_mv)
 NFC 5 measure voltage function. More...
 
uint8_t nfc5_get_irq_pin (nfc5_t *ctx)
 NFC 5 get irq pin function. More...
 
err_t nfc5_get_mifare_tag_uid (nfc5_t *ctx, uint8_t *uid, uint8_t *uid_len)
 NFC 5 get mifare tag UID function. More...
 

Detailed Description

API for configuring and manipulating NFC 5 Click driver.

Function Documentation

◆ nfc5_cfg_setup()

void nfc5_cfg_setup ( nfc5_cfg_t cfg)

NFC 5 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ nfc5_check_chip_id()

err_t nfc5_check_chip_id ( nfc5_t ctx,
uint8_t *  revision 
)

NFC 5 check chip ID function.

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

Parameters
[in]ctx: Click context object. See nfc5_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.

◆ nfc5_check_interrupts()

err_t nfc5_check_interrupts ( nfc5_t ctx)

NFC 5 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 nfc5_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc5_clear_interrupts()

err_t nfc5_clear_interrupts ( nfc5_t ctx)

NFC 5 clear interrupts function.

This function clears all interrupt flags.

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

◆ nfc5_clear_reg_bits()

err_t nfc5_clear_reg_bits ( nfc5_t ctx,
uint8_t  reg,
uint8_t  clr_mask 
)

NFC 5 clear register bits function.

This function clears the given bitmask on the selected register.

Parameters
[in]ctx: Click context object. See nfc5_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.

◆ nfc5_default_cfg()

err_t nfc5_default_cfg ( nfc5_t ctx)

NFC 5 default configuration function.

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

Parameters
[in]ctx: Click context object. See nfc5_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.

◆ nfc5_disable_interrupt()

err_t nfc5_disable_interrupt ( nfc5_t ctx,
uint32_t  mask 
)

NFC 5 disable interrupt function.

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

Parameters
[in]ctx: Click context object. See nfc5_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.

◆ nfc5_drv_interface_sel()

void nfc5_drv_interface_sel ( nfc5_cfg_t cfg,
nfc5_drv_t  drv_sel 
)

NFC 5 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 nfc5_cfg_t object definition for detailed explanation.
[in]drv_sel: Driver interface selection. See nfc5_drv_t object definition for detailed explanation.
Returns
Nothing.
Note
This driver selection should be called 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.

◆ nfc5_enable_interrupt()

err_t nfc5_enable_interrupt ( nfc5_t ctx,
uint32_t  mask 
)

NFC 5 enable interrupt function.

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

Parameters
[in]ctx: Click context object. See nfc5_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.

◆ nfc5_enable_osc()

err_t nfc5_enable_osc ( nfc5_t ctx)

NFC 5 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 nfc5_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ nfc5_generic_read()

err_t nfc5_generic_read ( nfc5_t ctx,
uint8_t  reg,
uint8_t *  data_out,
uint16_t  len 
)

NFC 5 data reading function.

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

Parameters
[in]ctx: Click context object. See nfc5_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.

◆ nfc5_generic_write()

err_t nfc5_generic_write ( nfc5_t ctx,
uint8_t  reg,
uint8_t *  data_in,
uint16_t  len 
)

NFC 5 data writing function.

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

Parameters
[in]ctx: Click context object. See nfc5_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.

◆ nfc5_get_interrupt()

uint32_t nfc5_get_interrupt ( nfc5_t ctx,
uint32_t  mask 
)

NFC 5 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 nfc5_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.

◆ nfc5_get_irq_pin()

uint8_t nfc5_get_irq_pin ( nfc5_t ctx)

NFC 5 get irq pin function.

This function returns the IRQ pin logic state.

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

◆ nfc5_get_mifare_tag_uid()

err_t nfc5_get_mifare_tag_uid ( nfc5_t ctx,
uint8_t *  uid,
uint8_t *  uid_len 
)

NFC 5 get mifare tag UID function.

This function reads the UID of a mifare tag.

Parameters
[in]ctx: Click context object. See nfc5_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.

◆ nfc5_init()

err_t nfc5_init ( nfc5_t ctx,
nfc5_cfg_t cfg 
)

NFC 5 initialization function.

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

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

◆ nfc5_measure_voltage()

err_t nfc5_measure_voltage ( nfc5_t ctx,
uint8_t  mpsv_src,
uint16_t *  res_mv 
)

NFC 5 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 nfc5_t object definition for detailed explanation.
[in]mpsv_src: one of NFC5_REGULATOR_CTRL_MPSV_VDD, NFC5_REGULATOR_CTRL_MPSV_VDD_A, NFC5_REGULATOR_CTRL_MPSV_VDD_D, NFC5_REGULATOR_CTRL_MPSV_VDD_RF, NFC5_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.

◆ nfc5_modify_reg_bits()

err_t nfc5_modify_reg_bits ( nfc5_t ctx,
uint8_t  reg,
uint8_t  clr_mask,
uint8_t  set_mask 
)

NFC 5 modify register bits function.

This function modifies desired bits of the selected register.

Parameters
[in]ctx: Click context object. See nfc5_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.

◆ nfc5_modify_test_reg_bits()

err_t nfc5_modify_test_reg_bits ( nfc5_t ctx,
uint8_t  reg,
uint8_t  clr_mask,
uint8_t  set_mask 
)

NFC 5 modify test register bits function.

This function modifies desired bits of the selected test register.

Parameters
[in]ctx: Click context object. See nfc5_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.

◆ nfc5_read_fifo()

err_t nfc5_read_fifo ( nfc5_t ctx,
uint8_t *  data_out,
uint16_t  len 
)

NFC 5 read fifo function.

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

Parameters
[in]ctx: Click context object. See nfc5_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.

◆ nfc5_read_reg()

err_t nfc5_read_reg ( nfc5_t ctx,
uint8_t  reg,
uint8_t *  data_out 
)

NFC 5 read register function.

This function reads a desired data from the selected register.

Parameters
[in]ctx: Click context object. See nfc5_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.

◆ nfc5_read_regs()

err_t nfc5_read_regs ( nfc5_t ctx,
uint8_t  reg,
uint8_t *  data_out,
uint16_t  len 
)

NFC 5 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 nfc5_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.

◆ nfc5_read_test_register()

err_t nfc5_read_test_register ( nfc5_t ctx,
uint8_t  reg,
uint8_t *  data_out 
)

NFC 5 read test register function.

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

Parameters
[in]ctx: Click context object. See nfc5_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.

◆ nfc5_send_cmd()

err_t nfc5_send_cmd ( nfc5_t ctx,
uint8_t  cmd 
)

NFC 5 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 nfc5_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.

◆ nfc5_send_cmd_with_res()

err_t nfc5_send_cmd_with_res ( nfc5_t ctx,
uint8_t  cmd,
uint8_t  result_reg,
uint32_t  timeout,
uint8_t *  result 
)

NFC 5 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 nfc5_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.

◆ nfc5_set_reg_bits()

err_t nfc5_set_reg_bits ( nfc5_t ctx,
uint8_t  reg,
uint8_t  set_mask 
)

NFC 5 set register bits function.

This function sets the given bitmask on the selected register.

Parameters
[in]ctx: Click context object. See nfc5_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.

◆ nfc5_wait_interrupt()

uint32_t nfc5_wait_interrupt ( nfc5_t ctx,
uint32_t  mask,
uint32_t  timeout 
)

NFC 5 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 nfc5_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.

◆ nfc5_write_fifo()

err_t nfc5_write_fifo ( nfc5_t ctx,
uint8_t *  data_in,
uint16_t  len 
)

NFC 5 write fifo function.

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

Parameters
[in]ctx: Click context object. See nfc5_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.

◆ nfc5_write_reg()

err_t nfc5_write_reg ( nfc5_t ctx,
uint8_t  reg,
uint8_t  data_in 
)

NFC 5 write register function.

This function writes a desired data to the selected register.

Parameters
[in]ctx: Click context object. See nfc5_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.

◆ nfc5_write_regs()

err_t nfc5_write_regs ( nfc5_t ctx,
uint8_t  reg,
uint8_t *  data_in,
uint16_t  len 
)

NFC 5 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 nfc5_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.

◆ nfc5_write_test_register()

err_t nfc5_write_test_register ( nfc5_t ctx,
uint8_t  reg,
uint8_t  data_in 
)

NFC 5 write test register function.

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

Parameters
[in]ctx: Click context object. See nfc5_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.