haptic4 2.1.0.0
haptic4.h File Reference

This file contains API for Haptic 4 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_i2c_master.h"

Go to the source code of this file.

Data Structures

struct  haptic4_t
 Haptic 4 Click context object. More...
 
struct  haptic4_cfg_t
 Haptic 4 Click configuration object. More...
 

Macros

#define HAPTIC4_REG_CHIP_REV   0x00
 Haptic 4 description register.
 
#define HAPTIC4_REG_IRQ_EVENT1   0x03
 
#define HAPTIC4_REG_IRQ_EVENT_WARNING_DIAG   0x04
 
#define HAPTIC4_REG_IRQ_EVENT_SEQ_DIAG   0x05
 
#define HAPTIC4_REG_IRQ_STATUS1   0x06
 
#define HAPTIC4_REG_IRQ_MASK1   0x07
 
#define HAPTIC4_REG_CIF_I2C1   0x08
 
#define HAPTIC4_REG_FRQ_LRA_PER_H   0x0A
 
#define HAPTIC4_REG_FRQ_LRA_PER_L   0x0B
 
#define HAPTIC4_REG_ACTUATOR1   0x0C
 
#define HAPTIC4_REG_ACTUATOR2   0x0D
 
#define HAPTIC4_REG_ACTUATOR3   0x0E
 
#define HAPTIC4_REG_CALIB_V2I_H   0x0F
 
#define HAPTIC4_REG_CALIB_V2I_L   0x10
 
#define HAPTIC4_REG_CALIB_IMP_H   0x11
 
#define HAPTIC4_REG_CALIB_IMP_L   0x12
 
#define HAPTIC4_REG_TOP_CFG1   0x13
 
#define HAPTIC4_REG_TOP_CFG2   0x14
 
#define HAPTIC4_REG_TOP_CFG3   0x15
 
#define HAPTIC4_REG_TOP_CFG4   0x16
 
#define HAPTIC4_REG_TOP_INT_CFG1   0x17
 
#define HAPTIC4_REG_TOP_INT_CFG6_H   0x1C
 
#define HAPTIC4_REG_TOP_INT_CFG6_L   0x1D
 
#define HAPTIC4_REG_TOP_INT_CFG7_H   0x1E
 
#define HAPTIC4_REG_TOP_INT_CFG7_L   0x1F
 
#define HAPTIC4_REG_TOP_INT_CFG8   0x20
 
#define HAPTIC4_REG_TOP_CTL1   0x22
 
#define HAPTIC4_REG_TOP_CTL2   0x23
 
#define HAPTIC4_REG_SEQ_CTL1   0x24
 
#define HAPTIC4_REG_SWG_C1   0x25
 
#define HAPTIC4_REG_SWG_C2   0x26
 
#define HAPTIC4_REG_SWG_C3   0x27
 
#define HAPTIC4_REG_SEQ_CTL2   0x28
 
#define HAPTIC4_REG_GPI_0_CTL   0x29
 
#define HAPTIC4_REG_GPI_1_CTL   0x2A
 
#define HAPTIC4_REG_GPI_2_CTL   0x2B
 
#define HAPTIC4_REG_MEM_CTL1   0x2C
 
#define HAPTIC4_REG_MEM_CTL2   0x2D
 
#define HAPTIC4_REG_ADC_DATA_H1   0x2E
 
#define HAPTIC4_REG_ADC_DATA_L1   0x2F
 
#define HAPTIC4_REG_POLARITY   0x43
 
#define HAPTIC4_REG_LRA_AVR_H   0x44
 
#define HAPTIC4_REG_LRA_AVR_L   0x45
 
#define HAPTIC4_REG_FRQ_LRA_PER_ACT_H   0x46
 
#define HAPTIC4_REG_FRQ_LRA_PER_ACT_L   0x47
 
#define HAPTIC4_REG_FRQ_PHASE_H   0x48
 
#define HAPTIC4_REG_FRQ_PHASE_L   0x49
 
#define HAPTIC4_REG_FRQ_CTL   0x4C
 
#define HAPTIC4_REG_TRIM3   0x5F
 
#define HAPTIC4_REG_TRIM4   0x60
 
#define HAPTIC4_REG_TRIM6   0x62
 
#define HAPTIC4_REG_TOP_CFG5   0x6E
 
#define HAPTIC4_REG_IRQ_EVENT_ACTUATOR_FAULT   0x81
 
#define HAPTIC4_REG_IRQ_STATUS2   0x82
 
#define HAPTIC4_REG_IRQ_MASK2   0x83
 
#define HAPTIC4_REG_SNP_MEM_X   0x84
 
#define HAPTIC4_CHIP_REV   0xBA
 Haptic 4 CHIP REV value.
 
#define HAPTIC4_PIN_STATE_LOW   0x00
 Haptic 4 pin state.
 
#define HAPTIC4_PIN_STATE_HIGH   0x01
 
#define HAPTIC4_TOP_CFG1_EMB_MODE_MANUAL   0x00
 Haptic 4 top CFG 1 register settings.
 
#define HAPTIC4_TOP_CFG1_EMB_MODE_AUTO   0x80
 
#define HAPTIC4_TOP_CFG1_EMB_MODE_MASK   0x80
 
#define HAPTIC4_TOP_CFG1_ACT_TYPE_LRA   0x00
 
#define HAPTIC4_TOP_CFG1_ACT_TYPE_ERM   0x20
 
#define HAPTIC4_TOP_CFG1_ACT_TYPE_MASK   0x20
 
#define HAPTIC4_TOP_CFG1_BEMF_SENSE_CUSTOM_WF   0x00
 
#define HAPTIC4_TOP_CFG1_BEMF_SENSE_STANDARD   0x10
 
#define HAPTIC4_TOP_CFG1_BEMF_SENSE_MASK   0x10
 
#define HAPTIC4_TOP_CFG1_FREQ_TRACK_DISABLE   0x00
 
#define HAPTIC4_TOP_CFG1_FREQ_TRACK_ENABLE   0x08
 
#define HAPTIC4_TOP_CFG1_FREQ_TRACK_MASK   0x08
 
#define HAPTIC4_TOP_CFG1_ACCEL_DISABLE   0x00
 
#define HAPTIC4_TOP_CFG1_ACCEL_ENABLE   0x04
 
#define HAPTIC4_TOP_CFG1_ACCEL_MASK   0x04
 
#define HAPTIC4_TOP_CFG1_RAPID_STOP_DISABLE   0x00
 
#define HAPTIC4_TOP_CFG1_RAPID_STOP_ENABLE   0x02
 
#define HAPTIC4_TOP_CFG1_RAPID_STOP_MASK   0x02
 
#define HAPTIC4_TOP_CFG1_AMPLITUDE_PID_DISABLE   0x00
 
#define HAPTIC4_TOP_CFG1_AMPLITUDE_PID_ENABLE   0x01
 
#define HAPTIC4_TOP_CFG1_AMPLITUDE_PID_MASK   0x01
 
#define HAPTIC4_TOP_CTL1_SEQ_STOP   0x00
 Haptic 4 top CTL 1 register settings.
 
#define HAPTIC4_TOP_CTL1_SEQ_START   0x10
 
#define HAPTIC4_TOP_CTL1_SEQ_MASK   0x10
 
#define HAPTIC4_TOP_CTL1_STANDBY_DISABLE   0x00
 
#define HAPTIC4_TOP_CTL1_STANDBY_ENABLE   0x08
 
#define HAPTIC4_TOP_CTL1_STANDBY_MASK   0x08
 
#define HAPTIC4_TOP_CTL1_OP_MODE_INACTIVE   0x00
 
#define HAPTIC4_TOP_CTL1_OP_MODE_DRO   0x01
 
#define HAPTIC4_TOP_CTL1_OP_MODE_PWM   0x02
 
#define HAPTIC4_TOP_CTL1_OP_MODE_RTWM   0x03
 
#define HAPTIC4_TOP_CTL1_OP_MODE_ETWM   0x04
 
#define HAPTIC4_TOP_CTL1_OP_MODE_MASK   0x07
 
#define HAPTIC4_ACTUATOR_VOLTAGE_MIN   0.0f
 Haptic 4 calculation macros.
 
#define HAPTIC4_ACTUATOR_VOLTAGE_MAX   6.0f
 
#define HAPTIC4_ACTUATOR_VOLTAGE_RESOLUTION   0.0234f
 
#define HAPTIC4_ACTUATOR_IMAX_MIN   28.6f
 
#define HAPTIC4_ACTUATOR_IMAX_MAX   251.8f
 
#define HAPTIC4_ACTUATOR_IMAX_DIVIDER   7.2f
 
#define HAPTIC4_ACTUATOR_IMAX_RESOLUTION   0x1F
 
#define HAPTIC4_ACTUATOR_IMPEDANCE_MIN   4.0f
 
#define HAPTIC4_ACTUATOR_IMPEDANCE_MAX   50.0f
 
#define HAPTIC4_ACTUATOR_V2I_FACTOR_DIVIDER   1.6104f
 
#define HAPTIC4_ACTUATOR_LRA_FREQ_MIN   0.0f
 
#define HAPTIC4_ACTUATOR_LRA_FREQ_MAX   300.0f
 
#define HAPTIC4_ACTUATOR_LRA_FREQ_RESOLUTION   0.00000133332f
 
#define HAPTIC4_VIBRATION_LEVEL_MIN   -1.0f
 
#define HAPTIC4_VIBRATION_LEVEL_MAX   1.0f
 
#define HAPTIC4_VIBRATION_LEVEL_MIN_ACC_EN   0.0f
 
#define HAPTIC4_VIBRATION_LEVEL_RESOLUTION   0.008f
 
#define HAPTIC4_ROUND_TO_NEAREST_INT   0.5f
 
#define HAPTIC4_DEFAULT_ACTUATOR_TYPE   HAPTIC4_TOP_CFG1_ACT_TYPE_LRA
 Haptic 4 actuator settings default values.
 
#define HAPTIC4_DEFAULT_ACTUATOR_ABS_VOLT   2.808f
 
#define HAPTIC4_DEFAULT_ACTUATOR_NOM_VOLT   2.106f
 
#define HAPTIC4_DEFAULT_ACTUATOR_IMAX   194.0f
 
#define HAPTIC4_DEFAULT_ACTUATOR_IMPEDANCE   16.0f
 
#define HAPTIC4_DEFAULT_ACTUATOR_LRA_FREQ   174.0f
 
#define HAPTIC4_DEVICE_ADDRESS   0x4A
 Haptic 4 device address setting.
 
#define HAPTIC4_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  haptic4_return_value_t { HAPTIC4_OK = 0 , HAPTIC4_ERROR = -1 }
 Haptic 4 Click return value data. More...
 

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

This file contains API for Haptic 4 Click Driver.

Enumeration Type Documentation

◆ haptic4_return_value_t

Haptic 4 Click return value data.

Predefined enum values for driver return values.

Enumerator
HAPTIC4_OK 
HAPTIC4_ERROR