LCOV - code coverage report
Current view: top level - zephyr/input - input_analog_axis.h Coverage Total Hit
Test: new.info Lines: 100.0 % 10 10
Test Date: 2025-09-05 16:43:28

            Line data    Source code
       1            1 : /*
       2              :  * Copyright 2023 Google LLC
       3              :  *
       4              :  * SPDX-License-Identifier: Apache-2.0
       5              :  */
       6              : 
       7              : /**
       8              :  * @file
       9              :  * @ingroup input_analog_axis
      10              :  * @brief Main header file for interacting with analog axis input devices.
      11              :  */
      12              : 
      13              : #ifndef ZEPHYR_INCLUDE_INPUT_ANALOG_AXIS_H_
      14              : #define ZEPHYR_INCLUDE_INPUT_ANALOG_AXIS_H_
      15              : 
      16              : #include <stdint.h>
      17              : #include <zephyr/device.h>
      18              : 
      19              : /**
      20              :  * @defgroup input_analog_axis Analog axis
      21              :  * @ingroup input_interface
      22              :  * @{
      23              :  */
      24              : 
      25              : /**
      26              :  * @brief Analog axis calibration data structure.
      27              :  *
      28              :  * Holds the calibration data for a single analog axis. Initial values are set
      29              :  * from the devicetree and can be changed by the application in runtime using
      30              :  * @ref analog_axis_calibration_set and @ref analog_axis_calibration_get.
      31              :  */
      32            1 : struct analog_axis_calibration {
      33              :         /** Input value that corresponds to the minimum output value. */
      34            1 :         int16_t in_min;
      35              :         /** Input value that corresponds to the maximum output value. */
      36            1 :         int16_t in_max;
      37              :         /** Input value center deadzone. */
      38            1 :         uint16_t in_deadzone;
      39              : };
      40              : 
      41              : /**
      42              :  * @brief Analog axis raw data callback.
      43              :  *
      44              :  * @param dev Analog axis device.
      45              :  * @param channel Channel number.
      46              :  * @param raw_val Raw value for the channel.
      47              :  */
      48            1 : typedef void (*analog_axis_raw_data_t)(const struct device *dev,
      49              :                                        int channel, int16_t raw_val);
      50              : 
      51              : /**
      52              :  * @brief Set a raw data callback.
      53              :  *
      54              :  * Set a callback to receive raw data for the specified analog axis device.
      55              :  * This is meant to be use in the application to acquire the data to use for
      56              :  * calibration. Set cb to NULL to disable the callback.
      57              :  *
      58              :  * @param dev Analog axis device.
      59              :  * @param cb An analog_axis_raw_data_t callback to use, NULL to disable.
      60              :  */
      61            1 : void analog_axis_set_raw_data_cb(const struct device *dev, analog_axis_raw_data_t cb);
      62              : 
      63              : /**
      64              :  * @brief Get the number of defined axes.
      65              :  *
      66              :  * @param dev Analog axis device.
      67              :  * @retval n The number of defined axes for dev.
      68              :  */
      69            1 : int analog_axis_num_axes(const struct device *dev);
      70              : 
      71              : /**
      72              :  * @brief Get the axis calibration data.
      73              :  *
      74              :  * @param dev Analog axis device.
      75              :  * @param channel Channel number.
      76              :  * @param cal Pointer to an analog_axis_calibration structure that is going to
      77              :  * get set with the current calibration data.
      78              :  *
      79              :  * @retval 0 If successful.
      80              :  * @retval -EINVAL If the specified channel is not valid.
      81              :  */
      82            1 : int analog_axis_calibration_get(const struct device *dev,
      83              :                                 int channel,
      84              :                                 struct analog_axis_calibration *cal);
      85              : 
      86              : /**
      87              :  * @brief Set the axis calibration data.
      88              :  *
      89              :  * @param dev Analog axis device.
      90              :  * @param channel Channel number.
      91              :  * @param cal Pointer to an analog_axis_calibration structure with the new
      92              :  * calibration data
      93              :  *
      94              :  * @retval 0 If successful.
      95              :  * @retval -EINVAL If the specified channel is not valid.
      96              :  */
      97            1 : int analog_axis_calibration_set(const struct device *dev,
      98              :                                 int channel,
      99              :                                 struct analog_axis_calibration *cal);
     100              : 
     101              : /** @} */
     102              : 
     103              : #endif /* ZEPHYR_INCLUDE_INPUT_ANALOG_AXIS_H_ */
        

Generated by: LCOV version 2.0-1