Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
haptics.h File Reference

Main header file for haptics driver API. More...

#include <zephyr/audio/codec.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/sys/__assert.h>
#include <syscalls/haptics.h>

Go to the source code of this file.

Data Structures

union  haptics_config
 Haptics source configuration. More...
struct  haptics_driver_api
  Driver Operations Haptics driver operations More...

Typedefs

typedef void(* haptics_error_callback_t) (const struct device *dev, const uint32_t errors, void *const user_data)
 Function type of callback invoked when an error occurs.
typedef int(* haptics_calibrate_t) (const struct device *dev, const uint32_t routine)
 Calibrate the haptic driver for an external actuator.
typedef int(* haptics_monitor_get_t) (const struct device *dev, const enum haptics_monitor monitor, const enum haptics_monitor_type type, struct sensor_value *const val)
 Retrieve an integrated sensor reading from the haptic driver.
typedef int(* haptics_monitor_set_t) (const struct device *dev, const enum haptics_monitor monitor, const bool enable)
 Enable or disable integrated sensing for the haptic driver.
typedef int(* haptics_register_error_callback_t) (const struct device *dev, haptics_error_callback_t cb, void *const user_data)
 Register a callback function for haptics errors.
typedef int(* haptics_select_source_t) (const struct device *dev, const enum haptics_source src, const union haptics_config *const cfg)
 Specify a playback source for haptics_start_output().
typedef int(* haptics_set_level_t) (const struct device *dev, const enum haptics_source src, const union haptics_config *const cfg, const uint32_t level)
 Set level controls for haptic effects.
typedef int(* haptics_start_output_t) (const struct device *dev)
 Start playback for a haptic effect.
typedef int(* haptics_stop_output_t) (const struct device *dev)
 Stop an ongoing haptic effect and cancel any queued effects, if applicable.
typedef int(* haptics_stream_samples_t) (const struct device *dev, const uint8_t *const samples, const size_t len)
 Stream 8-bit samples over the control port for haptic effects.

Enumerations

enum  haptics_error_type {
  HAPTICS_ERROR_OVERCURRENT = BIT(0) , HAPTICS_ERROR_OVERTEMPERATURE = BIT(1) , HAPTICS_ERROR_UNDERVOLTAGE = BIT(2) , HAPTICS_ERROR_OVERVOLTAGE = BIT(3) ,
  HAPTICS_ERROR_DC = BIT(4)
}
 Haptics error types. More...
enum  haptics_monitor {
  HAPTICS_MONITOR_BEMF , HAPTICS_MONITOR_CURRENT , HAPTICS_MONITOR_F0 , HAPTICS_MONITOR_RE ,
  HAPTICS_MONITOR_AMBIENT_TEMP , HAPTICS_MONITOR_DIE_TEMP , HAPTICS_MONITOR_VBAT , HAPTICS_MONITOR_VBST ,
  HAPTICS_MONITOR_VOUT , HAPTICS_MONITOR_ALL
}
 Integrated sensing features. More...
enum  haptics_monitor_type { HAPTICS_MONITOR_TYPE_MIN , HAPTICS_MONITOR_TYPE_MAX , HAPTICS_MONITOR_TYPE_MEAN , HAPTICS_MONITOR_TYPE_SINGLE }
 Qualifiers for integrated sensor readings. More...
enum  haptics_source {
  HAPTICS_SOURCE_ROM , HAPTICS_SOURCE_RAM , HAPTICS_SOURCE_DAI , HAPTICS_SOURCE_ANALOG ,
  HAPTICS_SOURCE_PWM , HAPTICS_SOURCE_CONTROL_PORT , HAPTICS_SOURCE_ALL
}
 Haptics playback sources. More...

Functions

int haptics_calibrate (const struct device *dev, const uint32_t routine)
 Calibrate the haptic driver for an external actuator.
int haptics_monitor_get (const struct device *dev, const enum haptics_monitor monitor, const enum haptics_monitor_type type, struct sensor_value *const val)
 Retrieve an integrated sensor reading from the haptic driver.
int haptics_monitor_set (const struct device *dev, const enum haptics_monitor monitor, const bool enable)
 Enable or disable integrated sensing for the haptic driver.
static int haptics_register_error_callback (const struct device *dev, haptics_error_callback_t cb, void *const user_data)
 Register a callback function for haptics errors.
int haptics_select_source (const struct device *dev, const enum haptics_source src, const union haptics_config *const cfg)
 Specify a playback source and related configuration details.
int haptics_set_level (const struct device *dev, const enum haptics_source src, const union haptics_config *const cfg, const uint32_t level)
 Set level controls for haptic effects.
int haptics_start_output (const struct device *dev)
 Start playback for a haptic effect.
int haptics_stop_output (const struct device *dev)
 Stop an ongoing haptic effect and cancel any queued effects, if applicable.
int haptics_stream_samples (const struct device *dev, const uint8_t *const samples, const size_t len)
 Stream 8-bit samples over the control port for haptic effects.

Detailed Description

Main header file for haptics driver API.