proximity16 2.1.0.0
Proximity 16 Click Driver

API for configuring and manipulating Proximity 16 Click driver. More...

Topics

 Proximity 16 Registers List
 List of registers of Proximity 16 Click driver.
 
 Proximity 16 Registers Settings
 Settings for registers of Proximity 16 Click driver.
 
 Proximity 16 MikroBUS Map
 MikroBUS pin mapping of Proximity 16 Click driver.
 

Functions

void proximity16_cfg_setup (proximity16_cfg_t *cfg)
 Proximity 16 configuration object setup function.
 
err_t proximity16_init (proximity16_t *ctx, proximity16_cfg_t *cfg)
 Proximity 16 initialization function.
 
err_t proximity16_default_cfg (proximity16_t *ctx)
 Proximity 16 default configuration function.
 
err_t proximity16_write_multi (proximity16_t *ctx, uint16_t reg, uint8_t *data_in, uint8_t len)
 Proximity 16 write multi function.
 
err_t proximity16_read_multi (proximity16_t *ctx, uint16_t reg, uint8_t *data_out, uint16_t len)
 Proximity 16 read multi function.
 
err_t proximity16_write_byte (proximity16_t *ctx, uint16_t reg, uint8_t data_in)
 Proximity 16 write byte function.
 
err_t proximity16_read_byte (proximity16_t *ctx, uint16_t reg, uint8_t *data_out)
 Proximity 16 read byte function.
 
err_t proximity16_write_data (proximity16_t *ctx, uint8_t *data_in, uint16_t len)
 Proximity 16 write data function.
 
err_t proximity16_check_communication (proximity16_t *ctx)
 Proximity 16 check communication function.
 
uint8_t proximity16_get_int_pin (proximity16_t *ctx)
 Proximity 16 get int pin function.
 
void proximity16_set_i2c_rst_pin (proximity16_t *ctx, uint8_t state)
 Proximity 16 set i2c rst function.
 
void proximity16_set_lpn_pin (proximity16_t *ctx, uint8_t state)
 Proximity 16 set lpn function.
 
void proximity16_reset_i2c (proximity16_t *ctx)
 Proximity 16 reset i2c function.
 
err_t proximity16_sensor_init (proximity16_t *ctx)
 Proximity 16 sensor init function.
 
err_t proximity16_dci_write_data (proximity16_t *ctx, uint16_t index, uint8_t *data_in, uint16_t data_size)
 Proximity 16 dci write data function.
 
err_t proximity16_dci_read_data (proximity16_t *ctx, uint16_t index, uint8_t *data_out, uint16_t data_size)
 Proximity 16 dci read data function.
 
err_t proximity16_dci_replace_data (proximity16_t *ctx, uint16_t index, uint8_t *data_in, uint16_t data_size, uint8_t *new_data, uint16_t new_data_size, uint16_t new_data_pos)
 Proximity 16 dci replace data function.
 
err_t proximity16_set_resolution (proximity16_t *ctx, uint8_t resolution)
 Proximity 16 set resolution function.
 
err_t proximity16_get_resolution (proximity16_t *ctx, uint8_t *resolution)
 Proximity 16 get resolution function.
 
err_t proximity16_set_ranging_frequency_hz (proximity16_t *ctx, uint8_t frequency_hz)
 Proximity 16 set ranging frequency hz function.
 
err_t proximity16_get_ranging_frequency_hz (proximity16_t *ctx, uint8_t *frequency_hz)
 Proximity 16 get ranging frequency hz function.
 
err_t proximity16_set_integration_time_ms (proximity16_t *ctx, uint32_t integration_time_ms)
 Proximity 16 set integration time ms function.
 
err_t proximity16_get_integration_time_ms (proximity16_t *ctx, uint32_t *integration_time_ms)
 Proximity 16 get integration time ms function.
 
err_t proximity16_set_ranging_mode (proximity16_t *ctx, uint8_t ranging_mode)
 Proximity 16 set ranging mode function.
 
err_t proximity16_get_ranging_mode (proximity16_t *ctx, uint8_t *ranging_mode)
 Proximity 16 get ranging mode function.
 
err_t proximity16_start_ranging (proximity16_t *ctx)
 Proximity 16 start ranging function.
 
err_t proximity16_stop_ranging (proximity16_t *ctx)
 Proximity 16 stop ranging function.
 
err_t proximity16_get_ranging_data (proximity16_t *ctx, proximity16_results_data_t *results)
 Proximity 16 get ranging data function.
 

Detailed Description

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

◆ proximity16_cfg_setup()

void proximity16_cfg_setup ( proximity16_cfg_t * cfg)

Proximity 16 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ proximity16_check_communication()

err_t proximity16_check_communication ( proximity16_t * ctx)

Proximity 16 check communication function.

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

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

◆ proximity16_dci_read_data()

err_t proximity16_dci_read_data ( proximity16_t * ctx,
uint16_t index,
uint8_t * data_out,
uint16_t data_size )

Proximity 16 dci read data function.

This function reads 'extra data' from DCI. Using a known index, the function fills the casted structure passed in argument.

Parameters
[in]ctx: Click context object. See proximity16_t object definition for detailed explanation.
[in]index: DCI register address.
[out]data_out: This field can be a casted structure, or a simple array. Please note that the FW only accept data of 32 bits. So field data can only have a size of 32, 64, 96, 128, bits..
[in]data_size: This field must be the structure or array size.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ proximity16_dci_replace_data()

err_t proximity16_dci_replace_data ( proximity16_t * ctx,
uint16_t index,
uint8_t * data_in,
uint16_t data_size,
uint8_t * new_data,
uint16_t new_data_size,
uint16_t new_data_pos )

Proximity 16 dci replace data function.

This function replaces 'extra data' in DCI. The data can be simple data, or casted structure.

Parameters
[in]ctx: Click context object. See proximity16_t object definition for detailed explanation.
[in]index: DCI register address.
[in]data_in: This field can be a casted structure, or a simple array. Please note that the FW only accept data of 32 bits. So field data can only have a size of 32, 64, 96, 128, bits..
[in]data_size: This field must be the structure or array size.
[in]new_data: Contains the new fields.
[in]new_data_size: New data size.
[in]new_data_pos: New data position into the buffer.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ proximity16_dci_write_data()

err_t proximity16_dci_write_data ( proximity16_t * ctx,
uint16_t index,
uint8_t * data_in,
uint16_t data_size )

Proximity 16 dci write data function.

This function writes 'extra data' to DCI. The data can be simple data, or casted structure.

Parameters
[in]ctx: Click context object. See proximity16_t object definition for detailed explanation.
[in]index: DCI register address.
[in]data_in: This field can be a casted structure, or a simple array. Please note that the FW only accept data of 32 bits. So field data can only have a size of 32, 64, 96, 128, bits..
[in]data_size: This field must be the structure or array size.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ proximity16_default_cfg()

err_t proximity16_default_cfg ( proximity16_t * ctx)

Proximity 16 default configuration function.

This function executes a default configuration of Proximity 16 click board.

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

◆ proximity16_get_int_pin()

uint8_t proximity16_get_int_pin ( proximity16_t * ctx)

Proximity 16 get int pin function.

This function returns the INT pin logic state.

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

◆ proximity16_get_integration_time_ms()

err_t proximity16_get_integration_time_ms ( proximity16_t * ctx,
uint32_t * integration_time_ms )

Proximity 16 get integration time ms function.

This function gets the current integration time in ms.

Parameters
[in]ctx: Click context object. See proximity16_t object definition for detailed explanation.
[out]integration_time_ms: Contains integration time in ms.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ proximity16_get_ranging_data()

err_t proximity16_get_ranging_data ( proximity16_t * ctx,
proximity16_results_data_t * results )

Proximity 16 get ranging data function.

This function gets the ranging data, using the selected output and the resolution.

Parameters
[in]ctx: Click context object. See proximity16_t object definition for detailed explanation.
[out]results: Proximity 16 results structure. See proximity16_results_data_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ proximity16_get_ranging_frequency_hz()

err_t proximity16_get_ranging_frequency_hz ( proximity16_t * ctx,
uint8_t * frequency_hz )

Proximity 16 get ranging frequency hz function.

This function gets the current ranging frequency in Hz. Ranging frequency corresponds to the time between each measurement.

Parameters
[in]ctx: Click context object. See proximity16_t object definition for detailed explanation.
[out]frequency_hz: Contains the ranging frequency in Hz.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ proximity16_get_ranging_mode()

err_t proximity16_get_ranging_mode ( proximity16_t * ctx,
uint8_t * ranging_mode )

Proximity 16 get ranging mode function.

This function gets the ranging mode. Two modes are available using ULD : Continuous and autonomous. The default mode is Autonomous.

Parameters
[in]ctx: Click context object. See proximity16_t object definition for detailed explanation.
[out]ranging_mode: Current ranging mode.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ proximity16_get_resolution()

err_t proximity16_get_resolution ( proximity16_t * ctx,
uint8_t * resolution )

Proximity 16 get resolution function.

This function gets the current resolution (4x4 or 8x8).

Parameters
[in]ctx: Click context object. See proximity16_t object definition for detailed explanation.
[out]resolution: Value of this pointer will be equal to 16 for 4x4 mode, and 64 for 8x8 mode.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ proximity16_init()

err_t proximity16_init ( proximity16_t * ctx,
proximity16_cfg_t * cfg )

Proximity 16 initialization function.

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

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

◆ proximity16_read_byte()

err_t proximity16_read_byte ( proximity16_t * ctx,
uint16_t reg,
uint8_t * data_out )

Proximity 16 read byte function.

This function reads data byte from the selected register by using I2C serial interface.

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

◆ proximity16_read_multi()

err_t proximity16_read_multi ( proximity16_t * ctx,
uint16_t reg,
uint8_t * data_out,
uint16_t len )

Proximity 16 read multi function.

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

Parameters
[in]ctx: Click context object. See proximity16_t object definition for detailed explanation.
[in]reg: 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.

◆ proximity16_reset_i2c()

void proximity16_reset_i2c ( proximity16_t * ctx)

Proximity 16 reset i2c function.

This function resets the I2C communication by toggling the I2C RST pin.

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

◆ proximity16_sensor_init()

err_t proximity16_sensor_init ( proximity16_t * ctx)

Proximity 16 sensor init function.

This function initializes the sensor. It must be called after a power on, to load the firmware into the sensor.

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

◆ proximity16_set_i2c_rst_pin()

void proximity16_set_i2c_rst_pin ( proximity16_t * ctx,
uint8_t state )

Proximity 16 set i2c rst function.

This function sets the I2C RST pin logic state.

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

◆ proximity16_set_integration_time_ms()

err_t proximity16_set_integration_time_ms ( proximity16_t * ctx,
uint32_t integration_time_ms )

Proximity 16 set integration time ms function.

This function sets a new integration time in ms. Integration time must be computed to be lower than the ranging period, for a selected resolution.

Parameters
[in]ctx: Click context object. See proximity16_t object definition for detailed explanation.
[in]integration_time_ms: Contains the integration time in ms. For all resolutions and frequency, the minimum value is 2ms, and the maximum is 1000ms.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function has no impact on ranging mode continous.

◆ proximity16_set_lpn_pin()

void proximity16_set_lpn_pin ( proximity16_t * ctx,
uint8_t state )

Proximity 16 set lpn function.

This function sets the LPn pin logic state.

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

◆ proximity16_set_ranging_frequency_hz()

err_t proximity16_set_ranging_frequency_hz ( proximity16_t * ctx,
uint8_t frequency_hz )

Proximity 16 set ranging frequency hz function.

This function sets a new ranging frequency in Hz. Ranging frequency corresponds to the measurements frequency. This setting depends of the resolution, so please select your resolution before using this function.

Parameters
[in]ctx: Click context object. See proximity16_t object definition for detailed explanation.
[in]frequency_hz: Contains the ranging frequency in Hz.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
For 4x4, min and max allowed values are : [1;60] - For 8x8, min and max allowed values are : [1;15].

◆ proximity16_set_ranging_mode()

err_t proximity16_set_ranging_mode ( proximity16_t * ctx,
uint8_t ranging_mode )

Proximity 16 set ranging mode function.

This function sets the ranging mode. Two modes are available using ULD : Continuous and autonomous. The default mode is Autonomous.

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

◆ proximity16_set_resolution()

err_t proximity16_set_resolution ( proximity16_t * ctx,
uint8_t resolution )

Proximity 16 set resolution function.

This function sets a new data resolution (4x4 or 8x8).

Parameters
[in]ctx: Click context object. See proximity16_t object definition for detailed explanation.
[in]resolution: Use macro PROXIMITY16_RESOLUTION_4X4 or PROXIMITY16_RESOLUTION_8X8 to set the resolution.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ proximity16_start_ranging()

err_t proximity16_start_ranging ( proximity16_t * ctx)

Proximity 16 start ranging function.

This function starts a ranging session. When the sensor streams, host cannot change settings 'on-the-fly'.

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

◆ proximity16_stop_ranging()

err_t proximity16_stop_ranging ( proximity16_t * ctx)

Proximity 16 stop ranging function.

This function stops the ranging session. It must be used when the sensor streams, after calling proximity16_start_ranging( ).

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

◆ proximity16_write_byte()

err_t proximity16_write_byte ( proximity16_t * ctx,
uint16_t reg,
uint8_t data_in )

Proximity 16 write byte function.

This function writes a data byte to the selected register by using I2C serial interface.

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

◆ proximity16_write_data()

err_t proximity16_write_data ( proximity16_t * ctx,
uint8_t * data_in,
uint16_t len )

Proximity 16 write data function.

This function writes a desired number of data bytes by using I2C serial interface.

Parameters
[in]ctx: Click context object. See proximity16_t object definition for detailed explanation.
[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.

◆ proximity16_write_multi()

err_t proximity16_write_multi ( proximity16_t * ctx,
uint16_t reg,
uint8_t * data_in,
uint8_t len )

Proximity 16 write multi function.

This function writes a desired number of data bytes to the selected register by using I2C serial interface.

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