uwb2 2.1.0.0
UWB 2 Click Driver

API for configuring and manipulating UWB 2 Click driver. More...

Topics

 UWB 2 Registers List
 List of registers of UWB 2 Click driver.
 
 UWB 2 Registers Settings
 Settings for registers of UWB 2 Click driver.
 
 UWB 2 MikroBUS Map
 MikroBUS pin mapping of UWB 2 Click driver.
 

Functions

void uwb2_cfg_setup (uwb2_cfg_t *cfg)
 UWB 2 configuration object setup function.
 
err_t uwb2_init (uwb2_t *ctx, uwb2_cfg_t *cfg)
 UWB 2 initialization function.
 
err_t uwb2_default_cfg (uwb2_t *ctx)
 UWB 2 default configuration function.
 
err_t uwb2_send_cmd (uwb2_t *ctx, uint8_t cmd)
 UWB 2 send cmd function.
 
err_t uwb2_read_reg (uwb2_t *ctx, uint16_t reg, uint8_t *data_out, uint16_t len)
 UWB 2 read register function.
 
err_t uwb2_write_reg (uwb2_t *ctx, uint16_t reg, uint8_t *data_in, uint16_t len)
 UWB 2 write register function.
 
err_t uwb2_read_reg_8bit (uwb2_t *ctx, uint16_t reg, uint8_t *data_out)
 UWB 2 read register 8bit function.
 
err_t uwb2_read_reg_16bit (uwb2_t *ctx, uint16_t reg, uint16_t *data_out)
 UWB 2 read register 16bit function.
 
err_t uwb2_read_reg_32bit (uwb2_t *ctx, uint16_t reg, uint32_t *data_out)
 UWB 2 read register 32bit function.
 
err_t uwb2_write_reg_8bit (uwb2_t *ctx, uint16_t reg, uint8_t data_in)
 UWB 2 write register 8bit function.
 
err_t uwb2_write_reg_16bit (uwb2_t *ctx, uint16_t reg, uint16_t data_in)
 UWB 2 write register 16bit function.
 
err_t uwb2_write_reg_32bit (uwb2_t *ctx, uint16_t reg, uint32_t data_in)
 UWB 2 write register 32bit function.
 
err_t uwb2_modify_reg_8bit (uwb2_t *ctx, uint16_t reg, uint8_t and_mask, uint8_t or_mask)
 UWB 2 modify register 8bit function.
 
err_t uwb2_modify_reg_16bit (uwb2_t *ctx, uint16_t reg, uint16_t and_mask, uint16_t or_mask)
 UWB 2 modify register 16bit function.
 
err_t uwb2_modify_reg_32bit (uwb2_t *ctx, uint16_t reg, uint32_t and_mask, uint32_t or_mask)
 UWB 2 modify register 32bit function.
 
err_t uwb2_read_otp (uwb2_t *ctx, uint16_t address, uint32_t *data_out, uint16_t len)
 UWB 2 read otp function.
 
void uwb2_set_rst_pin (uwb2_t *ctx, uint8_t state)
 UWB 2 set rst pin function.
 
void uwb2_set_wup_pin (uwb2_t *ctx, uint8_t state)
 UWB 2 set wup pin function.
 
uint8_t uwb2_get_ext_pin (uwb2_t *ctx)
 UWB 2 get ext pin function.
 
uint8_t uwb2_get_irq_pin (uwb2_t *ctx)
 UWB 2 get irq pin function.
 
void uwb2_reset_device (uwb2_t *ctx)
 UWB 2 reset device function.
 
err_t uwb2_check_communication (uwb2_t *ctx)
 UWB 2 check communication function.
 
err_t uwb2_power_up_ic (uwb2_t *ctx)
 UWB 2 power up IC function.
 
err_t uwb2_initialize_ic (uwb2_t *ctx)
 UWB 2 initialize IC function.
 
err_t uwb2_configure_ic (uwb2_t *ctx, uwb2_chip_cfg_t *config)
 UWB 2 configure IC function.
 
err_t uwb2_set_ic_state (uwb2_t *ctx, uint8_t state)
 UWB 2 set IC state function.
 
err_t uwb2_load_ic_rx_lut (uwb2_t *ctx, uint8_t channel)
 UWB 2 load IC RX lut function.
 
err_t uwb2_calibrate_ic_pgf (uwb2_t *ctx)
 UWB 2 calibrate IC PGF function.
 
err_t uwb2_set_rx_tx_leds (uwb2_t *ctx, uint8_t mode)
 UWB 2 set RX TX LEDs function.
 
err_t uwb2_wait_for_status_lo (uwb2_t *ctx, uint32_t status)
 UWB 2 wait for status lo function.
 
err_t uwb2_clear_status (uwb2_t *ctx)
 UWB 2 clear status function.
 
err_t uwb2_send_message (uwb2_t *ctx, uint8_t *data_in, uint16_t len)
 UWB 2 send message function.
 
err_t uwb2_read_message (uwb2_t *ctx, uint8_t *data_out, uint16_t *len)
 UWB 2 read message function.
 

Detailed Description

API for configuring and manipulating UWB 2 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

◆ uwb2_calibrate_ic_pgf()

err_t uwb2_calibrate_ic_pgf ( uwb2_t * ctx)

UWB 2 calibrate IC PGF function.

This function runs the PGF calibration. This is needed prior to reception.

Parameters
[in]ctx: Click context object. See uwb2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
If the RX calibration routine fails the device receiver performance will be severely affected, the application should reset and try again.

◆ uwb2_cfg_setup()

void uwb2_cfg_setup ( uwb2_cfg_t * cfg)

UWB 2 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ uwb2_check_communication()

err_t uwb2_check_communication ( uwb2_t * ctx)

UWB 2 check communication function.

This function checks the communication by reading and verifying the device ID.

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

◆ uwb2_clear_status()

err_t uwb2_clear_status ( uwb2_t * ctx)

UWB 2 clear status function.

This function reads and clears all 48 bits of the system status register.

Parameters
[in]ctx: Click context object. See uwb2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error or Timeout (Desired status bits are not set in expected period). See #err_t definition for detailed explanation.
Note
None.

◆ uwb2_configure_ic()

err_t uwb2_configure_ic ( uwb2_t * ctx,
uwb2_chip_cfg_t * config )

UWB 2 configure IC function.

This function configures the device as per the provided IC config structure.

Parameters
[in]ctx: Click context object. See uwb2_t object definition for detailed explanation.
[in,out]config: The IC config structure. See uwb2_chip_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function must be called after initializing the device.

◆ uwb2_default_cfg()

err_t uwb2_default_cfg ( uwb2_t * ctx)

UWB 2 default configuration function.

This function executes a default configuration of UWB 2 click board.

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

◆ uwb2_get_ext_pin()

uint8_t uwb2_get_ext_pin ( uwb2_t * ctx)

UWB 2 get ext pin function.

This function returns the EXTON pin logic state.

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

◆ uwb2_get_irq_pin()

uint8_t uwb2_get_irq_pin ( uwb2_t * ctx)

UWB 2 get irq pin function.

This function returns the IRQ pin logic state.

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

◆ uwb2_init()

err_t uwb2_init ( uwb2_t * ctx,
uwb2_cfg_t * cfg )

UWB 2 initialization function.

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

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

◆ uwb2_initialize_ic()

err_t uwb2_initialize_ic ( uwb2_t * ctx)

UWB 2 initialize IC function.

This function initializes the device transceiver by performing the initially required device configurations which reads and applies LDO and BIAS tune and crystal trim values from OTP memory.

Parameters
[in]ctx: Click context object. See uwb2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function must be called after a reset or on power up of the device.

◆ uwb2_load_ic_rx_lut()

err_t uwb2_load_ic_rx_lut ( uwb2_t * ctx,
uint8_t channel )

UWB 2 load IC RX lut function.

This function load RX lookup tables from OTP or by manually programming hard-coded values into the DGC registers for the selected channel.

Parameters
[in]ctx: Click context object. See uwb2_t object definition for detailed explanation.
[in]channel:
  • 0x05 - Channel 5,
  • 0x09 - Channel 9.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ uwb2_modify_reg_16bit()

err_t uwb2_modify_reg_16bit ( uwb2_t * ctx,
uint16_t reg,
uint16_t and_mask,
uint16_t or_mask )

UWB 2 modify register 16bit function.

This function modifies 16-bit data with AND and OR masks of the selected register.

Parameters
[in]ctx: Click context object. See uwb2_t object definition for detailed explanation.
[in]reg: Register address.
[in]and_mask: 16-bit AND mask.
[in]or_mask: 16-bit OR mask.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ uwb2_modify_reg_32bit()

err_t uwb2_modify_reg_32bit ( uwb2_t * ctx,
uint16_t reg,
uint32_t and_mask,
uint32_t or_mask )

UWB 2 modify register 32bit function.

This function modifies 32-bit data with AND and OR masks of the selected register.

Parameters
[in]ctx: Click context object. See uwb2_t object definition for detailed explanation.
[in]reg: Register address.
[in]and_mask: 32-bit AND mask.
[in]or_mask: 32-bit OR mask.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ uwb2_modify_reg_8bit()

err_t uwb2_modify_reg_8bit ( uwb2_t * ctx,
uint16_t reg,
uint8_t and_mask,
uint8_t or_mask )

UWB 2 modify register 8bit function.

This function modifies 8-bit data with AND and OR masks of the selected register.

Parameters
[in]ctx: Click context object. See uwb2_t object definition for detailed explanation.
[in]reg: Register address.
[in]and_mask: 8-bit AND mask.
[in]or_mask: 8-bit OR mask.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ uwb2_power_up_ic()

err_t uwb2_power_up_ic ( uwb2_t * ctx)

UWB 2 power up IC function.

This function resets the device, checks the communication, and waits until the IC enters the IDLE_RC state.

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

◆ uwb2_read_message()

err_t uwb2_read_message ( uwb2_t * ctx,
uint8_t * data_out,
uint16_t * len )

UWB 2 read message function.

This function activates the reception and then waits for a frame with a good FCS/CRC then reads up to len number of data bytes from the RX buffer and adjust the len parameter with the number of data bytes actually read.

Parameters
[in]ctx: Click context object. See uwb2_t object definition for detailed explanation.
[out]data_out: Output data buffer read.
[in,out]len: Input - the maximal number of data bytes that can be read, Output - the number of data bytes actually read.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ uwb2_read_otp()

err_t uwb2_read_otp ( uwb2_t * ctx,
uint16_t address,
uint32_t * data_out,
uint16_t len )

UWB 2 read otp function.

This function reads a desired number of data bytes starting from the selected OTP memory address.

Parameters
[in]ctx: Click context object. See uwb2_t object definition for detailed explanation.
[in]address: Start OTP memory address.
[out]data_out: Output data read (32-bit array).
[in]len: Number of data DWORDs to be read.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ uwb2_read_reg()

err_t uwb2_read_reg ( uwb2_t * ctx,
uint16_t reg,
uint8_t * data_out,
uint16_t len )

UWB 2 read register function.

This function reads a desired number of data bytes starting from the selected register by using SPI serial interface.

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

◆ uwb2_read_reg_16bit()

err_t uwb2_read_reg_16bit ( uwb2_t * ctx,
uint16_t reg,
uint16_t * data_out )

UWB 2 read register 16bit function.

This function reads 16-bit data from the selected register by using SPI serial interface.

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

◆ uwb2_read_reg_32bit()

err_t uwb2_read_reg_32bit ( uwb2_t * ctx,
uint16_t reg,
uint32_t * data_out )

UWB 2 read register 32bit function.

This function reads 32-bit data from the selected register by using SPI serial interface.

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

◆ uwb2_read_reg_8bit()

err_t uwb2_read_reg_8bit ( uwb2_t * ctx,
uint16_t reg,
uint8_t * data_out )

UWB 2 read register 8bit function.

This function reads 8-bit data from the selected register by using SPI serial interface.

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

◆ uwb2_reset_device()

void uwb2_reset_device ( uwb2_t * ctx)

UWB 2 reset device function.

This function resets the device by toggling the RST pin state.

Parameters
[in]ctx: Click context object. See uwb2_t object definition for detailed explanation.
Returns
None.
Note
None.

◆ uwb2_send_cmd()

err_t uwb2_send_cmd ( uwb2_t * ctx,
uint8_t cmd )

UWB 2 send cmd function.

This function send fast command by using SPI serial interface.

Parameters
[in]ctx: Click context object. See uwb2_t object definition for detailed explanation.
[in]cmd: Fast command to be sent.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ uwb2_send_message()

err_t uwb2_send_message ( uwb2_t * ctx,
uint8_t * data_in,
uint16_t len )

UWB 2 send message function.

This function write a desired number of data bytes to the TX buffer, sets the TX message size, starts transmission and waits for a TX frame sent event.

Parameters
[in]ctx: Click context object. See uwb2_t object definition for detailed explanation.
[in]data_in: Data buffer to be sent.
[in]len: Number of data bytes to send.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ uwb2_set_ic_state()

err_t uwb2_set_ic_state ( uwb2_t * ctx,
uint8_t state )

UWB 2 set IC state function.

This function can place the IC into IDLE/IDLE_PLL or IDLE_RC mode when it is not actively in TX or RX.

Parameters
[in]ctx: Click context object. See uwb2_t object definition for detailed explanation.
[in]state:
  • 0 - INIT,
  • 1 - IDLE/IDLE_PLL,
  • 2 - IDLE_RC.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ uwb2_set_rst_pin()

void uwb2_set_rst_pin ( uwb2_t * ctx,
uint8_t state )

UWB 2 set rst pin function.

This function sets the RST pin logic state.

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

◆ uwb2_set_rx_tx_leds()

err_t uwb2_set_rx_tx_leds ( uwb2_t * ctx,
uint8_t mode )

UWB 2 set RX TX LEDs function.

This function sets the GPIO0 as RX LED - the output is asserted briefly when the receiver completes the reception of a frame with a good FCS/CRC, and the GPIO3 as TX LED - the output is asserted briefly when the transmitter completes sending a packet.

Parameters
[in]ctx: Click context object. See uwb2_t object definition for detailed explanation.
[in]mode:
  • 0 - Disable RX/TX LEDs,
  • 1 - Enable RX/TX LEDs.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ uwb2_set_wup_pin()

void uwb2_set_wup_pin ( uwb2_t * ctx,
uint8_t state )

UWB 2 set wup pin function.

This function sets the WAKEUP pin logic state.

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

◆ uwb2_wait_for_status_lo()

err_t uwb2_wait_for_status_lo ( uwb2_t * ctx,
uint32_t status )

UWB 2 wait for status lo function.

This function will continuously read lower 32 bits of the system status register for a UWB2_WAIT_TIMEOUT_MS period or until it matches the bits set in the status input parameter.

Parameters
[in]ctx: Click context object. See uwb2_t object definition for detailed explanation.
[in]status: Status bits mask to wait for (lower 32 bits of system status register).
Returns
  • 0 - Success,
  • -1 - Error or Timeout (Desired status bits are not set in expected period). See #err_t definition for detailed explanation.
Note
None.

◆ uwb2_write_reg()

err_t uwb2_write_reg ( uwb2_t * ctx,
uint16_t reg,
uint8_t * data_in,
uint16_t len )

UWB 2 write register function.

This function writes a desired number of data bytes starting from the selected register by using SPI serial interface.

Parameters
[in]ctx: Click context object. See uwb2_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 read.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ uwb2_write_reg_16bit()

err_t uwb2_write_reg_16bit ( uwb2_t * ctx,
uint16_t reg,
uint16_t data_in )

UWB 2 write register 16bit function.

This function writes 16-bit data to the selected register by using SPI serial interface.

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

◆ uwb2_write_reg_32bit()

err_t uwb2_write_reg_32bit ( uwb2_t * ctx,
uint16_t reg,
uint32_t data_in )

UWB 2 write register 32bit function.

This function writes 32-bit data to the selected register by using SPI serial interface.

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

◆ uwb2_write_reg_8bit()

err_t uwb2_write_reg_8bit ( uwb2_t * ctx,
uint16_t reg,
uint8_t data_in )

UWB 2 write register 8bit function.

This function writes 8-bit data to the selected register by using SPI serial interface.

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