LCOV - code coverage report
Current view: top level - zephyr/drivers - haptics.h Coverage Total Hit
Test: new.info Lines: 75.0 % 8 6
Test Date: 2025-09-25 19:22:35

            Line data    Source code
       1            1 : /*
       2              :  * Copyright 2024 Cirrus Logic, Inc.
       3              :  *
       4              :  * SPDX-License-Identifier: Apache-2.0
       5              :  */
       6              : 
       7              : /**
       8              :  * @file
       9              :  * @ingroup haptics_interface
      10              :  * @brief Main header file for haptics driver API.
      11              :  */
      12              : 
      13              : #ifndef ZEPHYR_INCLUDE_DRIVERS_HAPTICS_H_
      14              : #define ZEPHYR_INCLUDE_DRIVERS_HAPTICS_H_
      15              : 
      16              : /**
      17              :  * @brief Interfaces for haptic devices.
      18              :  * @defgroup haptics_interface Haptics
      19              :  * @ingroup io_interfaces
      20              :  * @{
      21              :  *
      22              :  * @defgroup haptics_interface_ext Device-specific Haptics API extensions
      23              :  *
      24              :  * @{
      25              :  * @}
      26              :  */
      27              : 
      28              : #include <zephyr/device.h>
      29              : 
      30              : #ifdef __cplusplus
      31              : extern "C" {
      32              : #endif
      33              : 
      34              : /**
      35              :  * @typedef haptics_stop_output_t
      36              :  * @brief Set the haptic device to stop output
      37              :  * @param dev Pointer to the device structure for haptic device instance
      38              :  */
      39            1 : typedef int (*haptics_stop_output_t)(const struct device *dev);
      40              : 
      41              : /**
      42              :  * @typedef haptics_start_output_t
      43              :  * @brief Set the haptic device to start output for a playback event
      44              :  */
      45            1 : typedef int (*haptics_start_output_t)(const struct device *dev);
      46              : 
      47              : /**
      48              :  * @brief Haptic device API
      49              :  */
      50            1 : __subsystem struct haptics_driver_api {
      51            0 :         haptics_start_output_t start_output;
      52            0 :         haptics_stop_output_t stop_output;
      53              : };
      54              : 
      55              : /**
      56              :  * @brief Set the haptic device to start output for a playback event
      57              :  *
      58              :  * @param dev Pointer to the device structure for haptic device instance
      59              :  *
      60              :  * @retval 0 if successful
      61              :  * @retval <0 if failed
      62              :  */
      63            1 : __syscall int haptics_start_output(const struct device *dev);
      64              : 
      65              : static inline int z_impl_haptics_start_output(const struct device *dev)
      66              : {
      67              :         const struct haptics_driver_api *api = (const struct haptics_driver_api *)dev->api;
      68              : 
      69              :         return api->start_output(dev);
      70              : }
      71              : 
      72              : /**
      73              :  * @brief Set the haptic device to stop output for a playback event
      74              :  *
      75              :  * @param dev Pointer to the device structure for haptic device instance
      76              :  *
      77              :  * @retval 0 if successful
      78              :  * @retval <0 if failed
      79              :  */
      80            1 : __syscall int haptics_stop_output(const struct device *dev);
      81              : 
      82              : static inline int z_impl_haptics_stop_output(const struct device *dev)
      83              : {
      84              :         const struct haptics_driver_api *api = (const struct haptics_driver_api *)dev->api;
      85              : 
      86              :         return api->stop_output(dev);
      87              : }
      88              : 
      89              : /**
      90              :  * @}
      91              :  */
      92              : 
      93              : #ifdef __cplusplus
      94              : }
      95              : #endif /* __cplusplus */
      96              : 
      97              : #include <syscalls/haptics.h>
      98              : 
      99              : #endif /* ZEPHYR_INCLUDE_DRIVERS_HAPTICS_H_ */
        

Generated by: LCOV version 2.0-1