13#ifndef ZEPHYR_INCLUDE_DRIVERS_HAPTICS_H_
14#define ZEPHYR_INCLUDE_DRIVERS_HAPTICS_H_
55 HAPTICS_ERROR_PRIV_START =
BIT(5),
81 HAPTICS_MONITOR_PRIV_START,
100 HAPTICS_MONITOR_TYPE_PRIV_START,
123 HAPTICS_SOURCE_PRIV_START,
152 void *
const user_data);
186 void *
const user_data);
284static inline int z_impl_haptics_calibrate(
const struct device *dev,
const uint32_t routine)
317static inline int z_impl_haptics_monitor_get(
const struct device *dev,
329 __ASSERT_NO_MSG(val != NULL);
351static inline int z_impl_haptics_monitor_set(
const struct device *dev,
376 void *
const user_data)
384 __ASSERT_NO_MSG(cb != NULL);
409static inline int z_impl_haptics_select_source(
const struct device *dev,
441static inline int z_impl_haptics_set_level(
const struct device *dev,
const enum haptics_source src,
451 return api->
set_level(dev, src, cfg, level);
467static inline int z_impl_haptics_start_output(
const struct device *dev)
488static inline int z_impl_haptics_stop_output(
const struct device *dev)
517static inline int z_impl_haptics_stream_samples(
const struct device *dev,
518 const uint8_t *
const samples,
const size_t len)
526 __ASSERT_NO_MSG(samples != NULL);
539#include <syscalls/haptics.h>
Public API header file for Audio Codec.
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1425
Main header file for GPIO driver API.
audio_dai_type_t
Digital Audio Interface (DAI) type.
Definition codec.h:63
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.
Definition haptics.h:184
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.
Definition haptics.h:169
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.
Definition haptics.h:177
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().
Definition haptics.h:192
int(* haptics_calibrate_t)(const struct device *dev, const uint32_t routine)
Calibrate the haptic driver for an external actuator.
Definition haptics.h:163
int(* haptics_start_output_t)(const struct device *dev)
Start playback for a haptic effect.
Definition haptics.h:206
int(* haptics_stop_output_t)(const struct device *dev)
Stop an ongoing haptic effect and cancel any queued effects, if applicable.
Definition haptics.h:212
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.
Definition haptics.h:199
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.
Definition haptics.h:218
haptics_monitor
Integrated sensing features.
Definition haptics.h:67
int haptics_stop_output(const struct device *dev)
Stop an ongoing haptic effect and cancel any queued effects, if applicable.
haptics_source
Haptics playback sources.
Definition haptics.h:112
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_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.
int haptics_start_output(const struct device *dev)
Start playback for a haptic effect.
int haptics_calibrate(const struct device *dev, const uint32_t routine)
Calibrate the haptic driver for an external actuator.
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_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.
haptics_error_type
Haptics error types.
Definition haptics.h:46
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.
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.
Definition haptics.h:151
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.
Definition haptics.h:374
haptics_monitor_type
Qualifiers for integrated sensor readings.
Definition haptics.h:92
@ HAPTICS_MONITOR_CURRENT
Amperage.
Definition haptics.h:69
@ HAPTICS_MONITOR_BEMF
Back EMF.
Definition haptics.h:68
@ HAPTICS_MONITOR_VBAT
Supply voltage.
Definition haptics.h:74
@ HAPTICS_MONITOR_VOUT
Amplifier output voltage.
Definition haptics.h:76
@ HAPTICS_MONITOR_F0
Resonant frequency.
Definition haptics.h:70
@ HAPTICS_MONITOR_DIE_TEMP
Die temperature.
Definition haptics.h:73
@ HAPTICS_MONITOR_VBST
Boost supply voltage.
Definition haptics.h:75
@ HAPTICS_MONITOR_RE
Coil resistance.
Definition haptics.h:71
@ HAPTICS_MONITOR_ALL
All integrated sensors.
Definition haptics.h:77
@ HAPTICS_MONITOR_AMBIENT_TEMP
Ambient temperature.
Definition haptics.h:72
@ HAPTICS_SOURCE_PWM
Effect streamed from a PWM source.
Definition haptics.h:117
@ HAPTICS_SOURCE_RAM
Effect loaded at runtime into volatile memory.
Definition haptics.h:114
@ HAPTICS_SOURCE_CONTROL_PORT
Effect streamed via the control port (e.g., I2C or SPI).
Definition haptics.h:118
@ HAPTICS_SOURCE_ANALOG
Effect streamed from an analog source.
Definition haptics.h:116
@ HAPTICS_SOURCE_ALL
All playback sources.
Definition haptics.h:119
@ HAPTICS_SOURCE_ROM
Effect from a pre-programmed wavetable.
Definition haptics.h:113
@ HAPTICS_SOURCE_DAI
Effect streamed from a digital audio source (e.g., I2S).
Definition haptics.h:115
@ HAPTICS_ERROR_OVERVOLTAGE
Power source overvoltage error.
Definition haptics.h:50
@ HAPTICS_ERROR_DC
Output direct-current error.
Definition haptics.h:51
@ HAPTICS_ERROR_OVERCURRENT
Output overcurrent error.
Definition haptics.h:47
@ HAPTICS_ERROR_UNDERVOLTAGE
Power source undervoltage error.
Definition haptics.h:49
@ HAPTICS_ERROR_OVERTEMPERATURE
Device overtemperature error.
Definition haptics.h:48
@ HAPTICS_MONITOR_TYPE_MEAN
Mean sensor reading.
Definition haptics.h:95
@ HAPTICS_MONITOR_TYPE_MAX
Maximum sensor reading.
Definition haptics.h:94
@ HAPTICS_MONITOR_TYPE_SINGLE
Most recent or single-shot sensor reading.
Definition haptics.h:96
@ HAPTICS_MONITOR_TYPE_MIN
Minimum sensor reading.
Definition haptics.h:93
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44
#define ENOSYS
Function not implemented.
Definition errno.h:82
Main header file for sensor driver API.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
<span class="mlabel">Driver Operations</span> Haptics driver operations
Definition haptics.h:224
haptics_select_source_t select_source
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition haptics.h:244
haptics_stream_samples_t stream_samples
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition haptics.h:260
haptics_monitor_get_t monitor_get
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition haptics.h:232
haptics_register_error_callback_t register_error_callback
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition haptics.h:240
haptics_set_level_t set_level
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition haptics.h:248
haptics_start_output_t start_output
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition haptics.h:252
haptics_monitor_set_t monitor_set
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition haptics.h:236
haptics_calibrate_t calibrate
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition haptics.h:228
haptics_stop_output_t stop_output
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition haptics.h:256
Representation of a sensor readout value.
Definition sensor.h:55
Digital Audio Interface Configuration.
Definition codec.h:151
Haptics source configuration.
Definition haptics.h:136
uint32_t idx
Used to specify an effect from a list of waveforms stored in memory.
Definition haptics.h:137
audio_dai_type_t type
Digital audio interface type, e.g., I2S.
Definition haptics.h:139
struct haptics_config::@252171155116075075015152322253304273144057276332 dai
Digital audio interface configuration for "audio to haptics" features.
audio_dai_cfg_t cfg
Digital audio interface configuration details.
Definition haptics.h:140