haptic3 2.0.0.0
HAPTIC 3 Click Driver

API for configuring and manipulating HAPTIC 3 Click driver. More...

Topics

 HAPTIC 3 Registers List
 List of registers of HAPTIC 3 Click driver.
 
 HAPTIC 3 Registers Settings
 Settings for registers of HAPTIC 3 Click driver.
 
 HAPTIC 3 MikroBUS Map
 MikroBUS pin mapping of HAPTIC 3 Click driver.
 

Functions

void haptic3_cfg_setup (haptic3_cfg_t *cfg)
 HAPTIC 3 configuration object setup function.
 
err_t haptic3_init (haptic3_t *ctx, haptic3_cfg_t *cfg)
 HAPTIC 3 initialization function.
 
err_t haptic3_default_cfg (haptic3_t *ctx)
 HAPTIC 3 default configuration function.
 
err_t haptic3_generic_write (haptic3_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
 HAPTIC 3 I2C writing function.
 
err_t haptic3_generic_read (haptic3_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
 HAPTIC 3 I2C reading function.
 
err_t haptic3_write_register (haptic3_t *ctx, uint8_t reg, uint8_t data_in)
 HAPTIC 3 write register function.
 
err_t haptic3_read_register (haptic3_t *ctx, uint8_t reg, uint8_t *data_out)
 HAPTIC 3 read register function.
 
err_t haptic3_write_register_bits (haptic3_t *ctx, uint8_t reg, uint8_t mask, uint8_t data_in)
 HAPTIC 3 write register bits function.
 
err_t haptic3_check_communication (haptic3_t *ctx)
 HAPTIC 3 check communication function.
 
void haptic3_enable_device (haptic3_t *ctx)
 HAPTIC 3 enable device function.
 
void haptic3_disable_device (haptic3_t *ctx)
 HAPTIC 3 disable device function.
 
uint8_t haptic3_get_int_pin (haptic3_t *ctx)
 HAPTIC 3 get INT pin function.
 
err_t haptic3_set_actuator_type (haptic3_t *ctx, uint8_t type)
 HAPTIC 3 set actuator type function.
 
err_t haptic3_set_actuator_abs_volt (haptic3_t *ctx, float abs_volt)
 HAPTIC 3 set actuator abs volt function.
 
err_t haptic3_set_actuator_nom_volt (haptic3_t *ctx, float nom_volt)
 HAPTIC 3 set actuator nom volt function.
 
err_t haptic3_set_actuator_imax (haptic3_t *ctx, float max_curr)
 HAPTIC 3 set actuator imax function.
 
err_t haptic3_set_actuator_impedance (haptic3_t *ctx, float impedance)
 HAPTIC 3 set actuator impedance function.
 
err_t haptic3_set_actuator_lra_freq (haptic3_t *ctx, float frequency)
 HAPTIC 3 set actuator lra freq function.
 
err_t haptic3_set_operation_mode (haptic3_t *ctx, uint8_t op_mode)
 HAPTIC 3 set operation mode function.
 
err_t haptic3_set_freq_track (haptic3_t *ctx, uint8_t freq_track_en)
 HAPTIC 3 set freq track function.
 
err_t haptic3_set_acceleration_mode (haptic3_t *ctx, uint8_t accel_en)
 HAPTIC 3 set acceleration mode function.
 
err_t haptic3_set_vibration_level (haptic3_t *ctx, float level)
 HAPTIC 3 set vibration level function.
 
err_t haptic3_get_vibration_level (haptic3_t *ctx, float *level)
 HAPTIC 3 get vibration level function.
 

Detailed Description

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

◆ haptic3_cfg_setup()

void haptic3_cfg_setup ( haptic3_cfg_t * cfg)

HAPTIC 3 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ haptic3_check_communication()

err_t haptic3_check_communication ( haptic3_t * ctx)

HAPTIC 3 check communication function.

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

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

◆ haptic3_default_cfg()

err_t haptic3_default_cfg ( haptic3_t * ctx)

HAPTIC 3 default configuration function.

This function executes a default configuration of HAPTIC 3 click board.

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

◆ haptic3_disable_device()

void haptic3_disable_device ( haptic3_t * ctx)

HAPTIC 3 disable device function.

This function disables the device by setting the EN pin to low logic state.

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

◆ haptic3_enable_device()

void haptic3_enable_device ( haptic3_t * ctx)

HAPTIC 3 enable device function.

This function enables the device by setting the EN pin to high logic state.

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

◆ haptic3_generic_read()

err_t haptic3_generic_read ( haptic3_t * ctx,
uint8_t reg,
uint8_t * rx_buf,
uint8_t rx_len )

HAPTIC 3 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 haptic3_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.
Note
None.

◆ haptic3_generic_write()

err_t haptic3_generic_write ( haptic3_t * ctx,
uint8_t reg,
uint8_t * tx_buf,
uint8_t tx_len )

HAPTIC 3 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 haptic3_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.
Note
None.

◆ haptic3_get_int_pin()

uint8_t haptic3_get_int_pin ( haptic3_t * ctx)

HAPTIC 3 get INT pin function.

This function returns the INT pin logic state.

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

◆ haptic3_get_vibration_level()

err_t haptic3_get_vibration_level ( haptic3_t * ctx,
float * level )

HAPTIC 3 get vibration level function.

This function reads the motor vibration level.

Parameters
[in]ctx: Click context object. See haptic3_t object definition for detailed explanation.
[out]level: Vibration level in percentage from 0.0 (or -1.0 if acceleration mode is disabled) to 1.0.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ haptic3_init()

err_t haptic3_init ( haptic3_t * ctx,
haptic3_cfg_t * cfg )

HAPTIC 3 initialization function.

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

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

◆ haptic3_read_register()

err_t haptic3_read_register ( haptic3_t * ctx,
uint8_t reg,
uint8_t * data_out )

HAPTIC 3 read register function.

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

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

◆ haptic3_set_acceleration_mode()

err_t haptic3_set_acceleration_mode ( haptic3_t * ctx,
uint8_t accel_en )

HAPTIC 3 set acceleration mode function.

This function sets the acceleration mode bits in TOP CFG1 register.

Parameters
[in]ctx: Click context object. See haptic3_t object definition for detailed explanation.
[in]accel_en:
  • 0x00 - Disable,
  • 0x04 - Enable.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ haptic3_set_actuator_abs_volt()

err_t haptic3_set_actuator_abs_volt ( haptic3_t * ctx,
float abs_volt )

HAPTIC 3 set actuator abs volt function.

This function sets the actuator absolute maximum voltage.

Parameters
[in]ctx: Click context object. See haptic3_t object definition for detailed explanation.
[in]abs_volt: Voltage in range of 0.0 to 6.0 V.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ haptic3_set_actuator_imax()

err_t haptic3_set_actuator_imax ( haptic3_t * ctx,
float max_curr )

HAPTIC 3 set actuator imax function.

This function sets the actuator max current rating.

Parameters
[in]ctx: Click context object. See haptic3_t object definition for detailed explanation.
[in]max_curr: Current in range of 28.6 to 251.8 mA.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ haptic3_set_actuator_impedance()

err_t haptic3_set_actuator_impedance ( haptic3_t * ctx,
float impedance )

HAPTIC 3 set actuator impedance function.

This function sets the actuator impedance.

Parameters
[in]ctx: Click context object. See haptic3_t object definition for detailed explanation.
[in]impedance: Impedance in range of 4.0 to 50.0 Ohm.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
The value is dependent on the max current value that can be set using haptic3_set_actuator_imax function.

◆ haptic3_set_actuator_lra_freq()

err_t haptic3_set_actuator_lra_freq ( haptic3_t * ctx,
float frequency )

HAPTIC 3 set actuator lra freq function.

This function sets the actuator LRA frequency.

Parameters
[in]ctx: Click context object. See haptic3_t object definition for detailed explanation.
[in]frequency: Frequency in range of 0.0 to 300.0 Hz.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ haptic3_set_actuator_nom_volt()

err_t haptic3_set_actuator_nom_volt ( haptic3_t * ctx,
float nom_volt )

HAPTIC 3 set actuator nom volt function.

This function sets the actuator nominal voltage.

Parameters
[in]ctx: Click context object. See haptic3_t object definition for detailed explanation.
[in]nom_volt: Voltage in range of 0.0 to 6.0 V.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ haptic3_set_actuator_type()

err_t haptic3_set_actuator_type ( haptic3_t * ctx,
uint8_t type )

HAPTIC 3 set actuator type function.

This function sets the actuator type bits in TOP CFG1 register.

Parameters
[in]ctx: Click context object. See haptic3_t object definition for detailed explanation.
[in]type:
  • 0x00 - LRA,
  • 0x20 - ERM.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ haptic3_set_freq_track()

err_t haptic3_set_freq_track ( haptic3_t * ctx,
uint8_t freq_track_en )

HAPTIC 3 set freq track function.

This function sets the frequency tracking bits in TOP CFG1 register.

Parameters
[in]ctx: Click context object. See haptic3_t object definition for detailed explanation.
[in]freq_track_en:
  • 0x00 - Disable,
  • 0x08 - Enable.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ haptic3_set_operation_mode()

err_t haptic3_set_operation_mode ( haptic3_t * ctx,
uint8_t op_mode )

HAPTIC 3 set operation mode function.

This function sets the operation mode bits in TOP CTL1 register.

Parameters
[in]ctx: Click context object. See haptic3_t object definition for detailed explanation.
[in]op_mode:
  • 0x00 - Inactive,
  • 0x01 - DRO (I2C Control),
  • 0x02 - PWM,
  • 0x03 - RTWM (Register-Triggered-Waveform-Memory),
  • 0x04 - ETWM (Edge-Triggered-Waveform-Memory Mode).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ haptic3_set_vibration_level()

err_t haptic3_set_vibration_level ( haptic3_t * ctx,
float level )

HAPTIC 3 set vibration level function.

This function sets the motor vibration level.

Parameters
[in]ctx: Click context object. See haptic3_t object definition for detailed explanation.
[in]level: Vibration level in percentage from 0.0 (or -1.0 if acceleration mode is disabled) to 1.0.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ haptic3_write_register()

err_t haptic3_write_register ( haptic3_t * ctx,
uint8_t reg,
uint8_t data_in )

HAPTIC 3 write register function.

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

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

◆ haptic3_write_register_bits()

err_t haptic3_write_register_bits ( haptic3_t * ctx,
uint8_t reg,
uint8_t mask,
uint8_t data_in )

HAPTIC 3 write register bits function.

This function writes a desired data bits to the bits specified with mask of the selected register.

Parameters
[in]ctx: Click context object. See haptic3_t object definition for detailed explanation.
[in]reg: Register address.
[in]mask: Mask of bits to be changed.
[in]data_in: Data to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.