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};
47
52typedef int (*haptics_stop_output_t)(const struct device *dev);
53
58typedef int (*haptics_start_output_t)(const struct device *dev);
59
68typedef void (*haptics_error_callback_t)(const struct device *dev, const uint32_t errors,
69 void *const user_data);
70
75typedef int (*haptics_register_error_callback_t)(const struct device *dev,
77 void *const user_data);
78
87
96__syscall int haptics_start_output(const struct device *dev);
97
98static inline int z_impl_haptics_start_output(const struct device *dev)
99{
100 const struct haptics_driver_api *api = (const struct haptics_driver_api *)dev->api;
101
102 return api->start_output(dev);
103}
104
113__syscall int haptics_stop_output(const struct device *dev);
114
115static inline int z_impl_haptics_stop_output(const struct device *dev)
116{
117 const struct haptics_driver_api *api = (const struct haptics_driver_api *)dev->api;
118
119 return api->stop_output(dev);
120}
121
132static inline int haptics_register_error_callback(const struct device *dev,
134 void *const user_data)
135{
136 const struct haptics_driver_api *api = (const struct haptics_driver_api *)dev->api;
137
138 if (api->register_error_callback == NULL) {
139 return -ENOSYS;
140 }
141
142 return api->register_error_callback(dev, cb, user_data);
143}
144
148
149#ifdef __cplusplus
150}
151#endif /* __cplusplus */
152
153#include <syscalls/haptics.h>
154
155#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:75
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.
int(* haptics_start_output_t)(const struct device *dev)
Set the haptic device to start output for a playback event.
Definition haptics.h:58
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)
Callback function for error interrupt.
Definition haptics.h:68
int(* haptics_stop_output_t)(const struct device *dev)
Set the haptic device to stop output.
Definition haptics.h:52
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:132
@ HAPTICS_ERROR_OVERVOLTAGE
Power source overvoltage error.
Definition haptics.h:41
@ HAPTICS_ERROR_PRIV_START
Definition haptics.h:45
@ 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
Haptic device API.
Definition haptics.h:82
haptics_register_error_callback_t register_error_callback
Definition haptics.h:85
haptics_start_output_t start_output
Definition haptics.h:83
haptics_stop_output_t stop_output
Definition haptics.h:84