Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
haptics.h
Go to the documentation of this file.
1/*
2 * Copyright 2024 Cirrus Logic, Inc.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef ZEPHYR_INCLUDE_DRIVERS_HAPTICS_H_
14#define ZEPHYR_INCLUDE_DRIVERS_HAPTICS_H_
15
27
28#include <zephyr/device.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
43
44 /* Device-specific error codes can follow, refer to the device’s header file */
46 HAPTICS_ERROR_PRIV_START = BIT(5),
48};
49
57typedef void (*haptics_error_callback_t)(const struct device *dev, const uint32_t errors,
58 void *const user_data);
59
64
69typedef int (*haptics_stop_output_t)(const struct device *dev);
70
75typedef int (*haptics_start_output_t)(const struct device *dev);
76
81typedef int (*haptics_register_error_callback_t)(const struct device *dev,
83 void *const user_data);
84
102
106
115__syscall int haptics_start_output(const struct device *dev);
116
117static inline int z_impl_haptics_start_output(const struct device *dev)
118{
119 const struct haptics_driver_api *api = (const struct haptics_driver_api *)dev->api;
120
121 return api->start_output(dev);
122}
123
132__syscall int haptics_stop_output(const struct device *dev);
133
134static inline int z_impl_haptics_stop_output(const struct device *dev)
135{
136 const struct haptics_driver_api *api = (const struct haptics_driver_api *)dev->api;
137
138 return api->stop_output(dev);
139}
140
151static inline int haptics_register_error_callback(const struct device *dev,
153 void *const user_data)
154{
155 const struct haptics_driver_api *api = (const struct haptics_driver_api *)dev->api;
156
157 if (api->register_error_callback == NULL) {
158 return -ENOSYS;
159 }
160
161 return api->register_error_callback(dev, cb, user_data);
162}
163
167
168#ifdef __cplusplus
169}
170#endif /* __cplusplus */
171
172#include <syscalls/haptics.h>
173
174#endif /* ZEPHYR_INCLUDE_DRIVERS_HAPTICS_H_ */
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:81
int(* haptics_start_output_t)(const struct device *dev)
Set the haptic device to start output for a playback event.
Definition haptics.h:75
int(* haptics_stop_output_t)(const struct device *dev)
Set the haptic device to stop output.
Definition haptics.h:69
int haptics_stop_output(const struct device *dev)
Set the haptic device to stop output for a playback event.
int haptics_start_output(const struct device *dev)
Set the haptic device to start output for a playback event.
haptics_error_type
Haptics error types.
Definition haptics.h:37
void(* haptics_error_callback_t)(const struct device *dev, const uint32_t errors, void *const user_data)
Function type of callback invoked when a haptic device error occurs.
Definition haptics.h:57
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:151
@ HAPTICS_ERROR_OVERVOLTAGE
Power source overvoltage error.
Definition haptics.h:41
@ HAPTICS_ERROR_DC
Output direct-current error.
Definition haptics.h:42
@ HAPTICS_ERROR_OVERCURRENT
Output overcurrent error.
Definition haptics.h:38
@ HAPTICS_ERROR_UNDERVOLTAGE
Power source undervoltage error.
Definition haptics.h:40
@ HAPTICS_ERROR_OVERTEMPERATURE
Device overtemperature error.
Definition haptics.h:39
#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
#define NULL
Definition iar_missing_defs.h:20
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:519
<span class="mlabel">Driver Operations</span> Haptics driver operations
Definition haptics.h:88
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:100
haptics_start_output_t start_output
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition haptics.h:92
haptics_stop_output_t stop_output
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition haptics.h:96