vibrasense2 2.0.0.0
Vibra Sense 2 Click Driver

API for configuring and manipulating Vibra Sense 2 Click driver. More...

Topics

 Vibra Sense 2 Registers Settings
 Settings for registers of Vibra Sense 2 Click driver.
 
 Vibra Sense 2 MikroBUS Map
 MikroBUS pin mapping of Vibra Sense 2 Click driver.
 

Functions

void vibrasense2_cfg_setup (vibrasense2_cfg_t *cfg)
 Vibra Sense 2 configuration object setup function.
 
err_t vibrasense2_init (vibrasense2_t *ctx, vibrasense2_cfg_t *cfg)
 Vibra Sense 2 initialization function.
 
err_t vibrasense2_generic_write (vibrasense2_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
 Vibra Sense 2 I2C writing function.
 
err_t vibrasense2_generic_read (vibrasense2_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
 Vibra Sense 2 I2C reading function.
 
uint16_t vibrasense2_read_data (vibrasense2_t *ctx)
 Read data function.
 
uint16_t vibrasense2_read_voltage (vibrasense2_t *ctx, uint16_t v_ref)
 Read voltage function.
 
int8_t vibrasense2_vibration_level (vibrasense2_t *ctx)
 Get Vibration Level function.
 

Detailed Description

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

◆ vibrasense2_cfg_setup()

void vibrasense2_cfg_setup ( vibrasense2_cfg_t * cfg)

Vibra Sense 2 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ vibrasense2_generic_read()

err_t vibrasense2_generic_read ( vibrasense2_t * ctx,
uint8_t reg,
uint8_t * rx_buf,
uint8_t rx_len )

Vibra Sense 2 I2C reading function.

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

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

◆ vibrasense2_generic_write()

err_t vibrasense2_generic_write ( vibrasense2_t * ctx,
uint8_t reg,
uint8_t * tx_buf,
uint8_t tx_len )

Vibra Sense 2 I2C writing function.

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

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

◆ vibrasense2_init()

err_t vibrasense2_init ( vibrasense2_t * ctx,
vibrasense2_cfg_t * cfg )

Vibra Sense 2 initialization function.

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

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

◆ vibrasense2_read_data()

uint16_t vibrasense2_read_data ( vibrasense2_t * ctx)

Read data function.

Function is used to read raw data from MCP3221.

Parameters
[in]ctx: Click context object. See vibrasense2_t object definition for detailed explanation.
Returns
Result 16-bit value that represents ADC value from output register

◆ vibrasense2_read_voltage()

uint16_t vibrasense2_read_voltage ( vibrasense2_t * ctx,
uint16_t v_ref )

Read voltage function.

Function is used to calculate piezo voltage in millivolts.

Parameters
[in]ctx: Click context object. See vibrasense2_t object definition for detailed explanation.
[in]v_ref: 16-bit value representing power supply voltage.
Returns
Result 16-bit value that represents voltage in millivolts.

◆ vibrasense2_vibration_level()

int8_t vibrasense2_vibration_level ( vibrasense2_t * ctx)

Get Vibration Level function.

Function is used to get vibration level.

Parameters
[in]ctx: Click context object. See vibrasense2_t object definition for detailed explanation.
Returns
8-bit value representing vibration level or error occurence.
Note
Vibration levels available: "No vibrations", "Marginal", "Slight", "Enhanced", "Moderate", "High", and "Severe" vibrations detected.