haptic4 2.1.0.0
Haptic 4 Click Driver

API for configuring and manipulating Haptic 4 Click driver. More...

Topics

 Haptic 4 Registers List
 List of registers of Haptic 4 Click driver.
 
 Haptic 4 Registers Settings
 Settings for registers of Haptic 4 Click driver.
 
 Haptic 4 MikroBUS Map
 MikroBUS pin mapping of Haptic 4 Click driver.
 

Functions

void haptic4_cfg_setup (haptic4_cfg_t *cfg)
 Haptic 4 configuration object setup function.
 
err_t haptic4_init (haptic4_t *ctx, haptic4_cfg_t *cfg)
 Haptic 4 initialization function.
 
err_t haptic4_default_cfg (haptic4_t *ctx)
 Haptic 4 default configuration function.
 
err_t haptic4_generic_write (haptic4_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 Haptic 4 I2C writing function.
 
err_t haptic4_generic_read (haptic4_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 Haptic 4 I2C reading function.
 
err_t haptic4_write_register (haptic4_t *ctx, uint8_t reg, uint8_t data_in)
 Haptic 4 write register function.
 
err_t haptic4_read_register (haptic4_t *ctx, uint8_t reg, uint8_t *data_out)
 Haptic 4 read register function.
 
err_t haptic4_write_register_bits (haptic4_t *ctx, uint8_t reg, uint8_t mask, uint8_t data_in)
 Haptic 4 write register bits function.
 
err_t haptic4_check_communication (haptic4_t *ctx)
 Haptic 4 check communication function.
 
void haptic4_set_gp0 (haptic4_t *ctx, uint8_t pin_state)
 Haptic 4 set GP0 pin state function.
 
void haptic4_set_gp1 (haptic4_t *ctx, uint8_t pin_state)
 Haptic 4 set GP1 pin state function.
 
void haptic4_set_gp2 (haptic4_t *ctx, uint8_t pin_state)
 Haptic 4 set GP2 pin state function.
 
uint8_t haptic4_get_int_pin (haptic4_t *ctx)
 Haptic 4 get INT pin function.
 
err_t haptic4_set_actuator_type (haptic4_t *ctx, uint8_t type)
 Haptic 4 set actuator type function.
 
err_t haptic4_set_actuator_abs_volt (haptic4_t *ctx, float abs_volt)
 Haptic 4 set actuator abs volt function.
 
err_t haptic4_set_actuator_nom_volt (haptic4_t *ctx, float nom_volt)
 Haptic 4 set actuator nom volt function.
 
err_t haptic4_set_actuator_imax (haptic4_t *ctx, float max_curr)
 Haptic 4 set actuator imax function.
 
err_t haptic4_set_actuator_impedance (haptic4_t *ctx, float impedance)
 Haptic 4 set actuator impedance function.
 
err_t haptic4_set_actuator_lra_freq (haptic4_t *ctx, float frequency)
 Haptic 4 set actuator lra freq function.
 
err_t haptic4_set_operation_mode (haptic4_t *ctx, uint8_t op_mode)
 Haptic 4 set operation mode function.
 
err_t haptic4_set_freq_track (haptic4_t *ctx, uint8_t freq_track_en)
 Haptic 4 set freq track function.
 
err_t haptic4_set_acceleration_mode (haptic4_t *ctx, uint8_t accel_en)
 Haptic 4 set accel mode function.
 
err_t haptic4_set_vibration_level (haptic4_t *ctx, float level)
 Haptic 4 set vibration level function.
 
err_t haptic4_get_vibration_level (haptic4_t *ctx, float *level)
 Haptic 4 get vibration level function.
 

Detailed Description

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

◆ haptic4_cfg_setup()

void haptic4_cfg_setup ( haptic4_cfg_t * cfg)

Haptic 4 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ haptic4_check_communication()

err_t haptic4_check_communication ( haptic4_t * ctx)

Haptic 4 check communication function.

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

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

◆ haptic4_default_cfg()

err_t haptic4_default_cfg ( haptic4_t * ctx)

Haptic 4 default configuration function.

This function executes a default configuration of Haptic 4 click board.

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

◆ haptic4_generic_read()

err_t haptic4_generic_read ( haptic4_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint8_t len )

Haptic 4 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 haptic4_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.

◆ haptic4_generic_write()

err_t haptic4_generic_write ( haptic4_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint8_t len )

Haptic 4 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 haptic4_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.

◆ haptic4_get_int_pin()

uint8_t haptic4_get_int_pin ( haptic4_t * ctx)

Haptic 4 get INT pin function.

This function returns the INT pin logic state.

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

◆ haptic4_get_vibration_level()

err_t haptic4_get_vibration_level ( haptic4_t * ctx,
float * level )

Haptic 4 get vibration level function.

This function reads the motor vibration level.

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

◆ haptic4_init()

err_t haptic4_init ( haptic4_t * ctx,
haptic4_cfg_t * cfg )

Haptic 4 initialization function.

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

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

◆ haptic4_read_register()

err_t haptic4_read_register ( haptic4_t * ctx,
uint8_t reg,
uint8_t * data_out )

Haptic 4 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 haptic4_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.

◆ haptic4_set_acceleration_mode()

err_t haptic4_set_acceleration_mode ( haptic4_t * ctx,
uint8_t accel_en )

Haptic 4 set accel mode function.

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

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

◆ haptic4_set_actuator_abs_volt()

err_t haptic4_set_actuator_abs_volt ( haptic4_t * ctx,
float abs_volt )

Haptic 4 set actuator abs volt function.

This function sets the actuator absolute maximum voltage.

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

◆ haptic4_set_actuator_imax()

err_t haptic4_set_actuator_imax ( haptic4_t * ctx,
float max_curr )

Haptic 4 set actuator imax function.

This function sets the actuator max current rating.

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

◆ haptic4_set_actuator_impedance()

err_t haptic4_set_actuator_impedance ( haptic4_t * ctx,
float impedance )

Haptic 4 set actuator impedance function.

This function sets the actuator impedance.

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

◆ haptic4_set_actuator_lra_freq()

err_t haptic4_set_actuator_lra_freq ( haptic4_t * ctx,
float frequency )

Haptic 4 set actuator lra freq function.

This function sets the actuator LRA frequency.

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

◆ haptic4_set_actuator_nom_volt()

err_t haptic4_set_actuator_nom_volt ( haptic4_t * ctx,
float nom_volt )

Haptic 4 set actuator nom volt function.

This function sets the actuator nominal voltage.

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

◆ haptic4_set_actuator_type()

err_t haptic4_set_actuator_type ( haptic4_t * ctx,
uint8_t type )

Haptic 4 set actuator type function.

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

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

◆ haptic4_set_freq_track()

err_t haptic4_set_freq_track ( haptic4_t * ctx,
uint8_t freq_track_en )

Haptic 4 set freq track function.

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

Parameters
[in]ctx: Click context object. See haptic4_t object definition for detailed explanation.
[in]freq_track_en: Selected frequency tracking mode.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ haptic4_set_gp0()

void haptic4_set_gp0 ( haptic4_t * ctx,
uint8_t pin_state )

Haptic 4 set GP0 pin state function.

This function is used to set GP0 pin state.

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

◆ haptic4_set_gp1()

void haptic4_set_gp1 ( haptic4_t * ctx,
uint8_t pin_state )

Haptic 4 set GP1 pin state function.

This function is used to set GP1 pin state.

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

◆ haptic4_set_gp2()

void haptic4_set_gp2 ( haptic4_t * ctx,
uint8_t pin_state )

Haptic 4 set GP2 pin state function.

This function is used to set GP2 pin state.

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

◆ haptic4_set_operation_mode()

err_t haptic4_set_operation_mode ( haptic4_t * ctx,
uint8_t op_mode )

Haptic 4 set operation mode function.

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

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

◆ haptic4_set_vibration_level()

err_t haptic4_set_vibration_level ( haptic4_t * ctx,
float level )

Haptic 4 set vibration level function.

This function sets the motor vibration level.

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

◆ haptic4_write_register()

err_t haptic4_write_register ( haptic4_t * ctx,
uint8_t reg,
uint8_t data_in )

Haptic 4 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 haptic4_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.

◆ haptic4_write_register_bits()

err_t haptic4_write_register_bits ( haptic4_t * ctx,
uint8_t reg,
uint8_t mask,
uint8_t data_in )

Haptic 4 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 haptic4_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.