tdc2 2.1.0.0
TDC 2 Click Driver

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

Topics

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

Functions

void tdc2_cfg_setup (tdc2_cfg_t *cfg)
 TDC 2 configuration object setup function.
 
err_t tdc2_init (tdc2_t *ctx, tdc2_cfg_t *cfg)
 TDC 2 initialization function.
 
err_t tdc2_default_cfg (tdc2_t *ctx)
 TDC 2 default configuration function.
 
err_t tdc2_generic_write (tdc2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 TDC 2 data writing function.
 
err_t tdc2_generic_read (tdc2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 TDC 2 data reading function.
 
err_t tdc2_write_config (tdc2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 TDC 2 config data writing function.
 
err_t tdc2_read_config (tdc2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 TDC 2 config data reading function.
 
err_t tdc2_read_results (tdc2_t *ctx, uint8_t reg, uint32_t *reference_index, uint32_t *stop_result)
 TDC 2 results data reading function.
 
err_t tdc2_send_command (tdc2_t *ctx, uint8_t command)
 TDC 2 send command function.
 
err_t tdc2_sw_reset (tdc2_t *ctx)
 TDC 2 software reset function.
 
err_t tdc2_start_measuring (tdc2_t *ctx)
 TDC 2 start measuring function.
 
err_t tdc2_set_resolution (tdc2_t *ctx, uint32_t resolution)
 TDC 2 set resolution function.
 
err_t tdc2_get_resolution (tdc2_t *ctx, uint32_t *resolution)
 TDC 2 set resolution function.
 
void tdc2_reset_index (tdc2_t *ctx)
 TDC 2 reset reference index function.
 
void tdc2_disable_stop_channels (tdc2_t *ctx)
 TDC 2 disable stop channels function.
 
void tdc2_enable_stop_channels (tdc2_t *ctx)
 TDC 2 enable stop channels function.
 
uint8_t tdc2_get_int_state (tdc2_t *ctx)
 TDC 2 get int state function.
 
err_t tdc2_get_time_between_stops (tdc2_t *ctx, uint32_t stop_result1, uint32_t reference_index1, uint32_t stop_result2, uint32_t reference_index2, uint32_t *time_in_us)
 TDC 2 get time between stops function.
 

Detailed Description

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

◆ tdc2_cfg_setup()

void tdc2_cfg_setup ( tdc2_cfg_t * cfg)

TDC 2 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ tdc2_default_cfg()

err_t tdc2_default_cfg ( tdc2_t * ctx)

TDC 2 default configuration function.

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

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

◆ tdc2_disable_stop_channels()

void tdc2_disable_stop_channels ( tdc2_t * ctx)

TDC 2 disable stop channels function.

This function is used to disable STOP channels of the device.

Parameters
[in]ctx: Click context object. See tdc2_t object definition for detailed explanation.
Returns
Nothing.
Note
To use this function DIS pin must be activated by configuring it.

◆ tdc2_enable_stop_channels()

void tdc2_enable_stop_channels ( tdc2_t * ctx)

TDC 2 enable stop channels function.

This function is used to enable STOP channels of the device.

Parameters
[in]ctx: Click context object. See tdc2_t object definition for detailed explanation.
Returns
Nothing.
Note
To use this function DIS pin must be activated by configuring it.

◆ tdc2_generic_read()

err_t tdc2_generic_read ( tdc2_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint8_t len )

TDC 2 data reading 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 tdc2_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.

◆ tdc2_generic_write()

err_t tdc2_generic_write ( tdc2_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint8_t len )

TDC 2 data writing 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 tdc2_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.

◆ tdc2_get_int_state()

uint8_t tdc2_get_int_state ( tdc2_t * ctx)

TDC 2 get int state function.

This function is used to read SPI interrupt state of the device.

Parameters
[in]ctx: Click context object. See tdc2_t object definition for detailed explanation.
Returns
  • 0 - Int pin is low,
  • 1 - Int pin is high.
Note
None.

◆ tdc2_get_resolution()

err_t tdc2_get_resolution ( tdc2_t * ctx,
uint32_t * resolution )

TDC 2 set resolution function.

This function is used to read resolution of the device.

Parameters
[in]ctx: Click context object. See tdc2_t object definition for detailed explanation.
[out]resolution: Resolution of the device.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ tdc2_get_time_between_stops()

err_t tdc2_get_time_between_stops ( tdc2_t * ctx,
uint32_t stop_result1,
uint32_t reference_index1,
uint32_t stop_result2,
uint32_t reference_index2,
uint32_t * time_in_us )

TDC 2 get time between stops function.

This function is used to get time between two stops in uS.

Parameters
[in]ctx: Click context object. See tdc2_t object definition for detailed explanation.
[in]stop_result1: Stop result of first event.
[in]reference_index1: Reference index of first event.
[in]stop_result2: Stop result of second event.
[in]reference_index2: Reference index of second event.
[out]time_in_us: Calculated time in uS.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ tdc2_init()

err_t tdc2_init ( tdc2_t * ctx,
tdc2_cfg_t * cfg )

TDC 2 initialization function.

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

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

◆ tdc2_read_config()

err_t tdc2_read_config ( tdc2_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint8_t len )

TDC 2 config data reading function.

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

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

◆ tdc2_read_results()

err_t tdc2_read_results ( tdc2_t * ctx,
uint8_t reg,
uint32_t * reference_index,
uint32_t * stop_result )

TDC 2 results data reading function.

This function reads a reference index and stop result data from FIFO by using SPI serial interface.

Parameters
[in]ctx: Click context object. See tdc2_t object definition for detailed explanation.
[in]reg: Start register address.
[out]reference_index: Reference index output data.
[out]stop_result: Stop result read data.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ tdc2_reset_index()

void tdc2_reset_index ( tdc2_t * ctx)

TDC 2 reset reference index function.

This function is used to reset reference index of the device.

Parameters
[in]ctx: Click context object. See tdc2_t object definition for detailed explanation.
Returns
Nothing.
Note
To use this function RIR pin must be activated by configuring it.

◆ tdc2_send_command()

err_t tdc2_send_command ( tdc2_t * ctx,
uint8_t command )

TDC 2 send command function.

This function is used to send byte of command data by using SPI serial interface.

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

◆ tdc2_set_resolution()

err_t tdc2_set_resolution ( tdc2_t * ctx,
uint32_t resolution )

TDC 2 set resolution function.

This function is used to write resolution of the device.

Parameters
[in]ctx: Click context object. See tdc2_t object definition for detailed explanation.
[in]resolution: Resolution of the device.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ tdc2_start_measuring()

err_t tdc2_start_measuring ( tdc2_t * ctx)

TDC 2 start measuring function.

This function is used to configure the device into reading mode.

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

◆ tdc2_sw_reset()

err_t tdc2_sw_reset ( tdc2_t * ctx)

TDC 2 software reset function.

This function is used to perform a software reset of the device.

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

◆ tdc2_write_config()

err_t tdc2_write_config ( tdc2_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint8_t len )

TDC 2 config data writing function.

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

Parameters
[in]ctx: Click context object. See tdc2_t object definition for detailed explanation.
[in]reg: Start register address.
[in]data_in: Configuration 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.