LCOV - code coverage report
Current view: top level - zephyr/drivers/mfd - ad559x.h Hit Total Coverage
Test: new.info Lines: 8 24 33.3 %
Date: 2024-12-22 00:14:23

          Line data    Source code
       1           0 : /*
       2             :  * Copyright (c) 2023 Grinn
       3             :  * SPDX-License-Identifier: Apache-2.0
       4             :  */
       5             : 
       6             : #ifndef ZEPHYR_INCLUDE_DRIVERS_MFD_AD559X_H_
       7             : #define ZEPHYR_INCLUDE_DRIVERS_MFD_AD559X_H_
       8             : 
       9             : #ifdef __cplusplus
      10             : extern "C" {
      11             : #endif
      12             : 
      13             : #include <zephyr/device.h>
      14             : 
      15           0 : #define AD559X_REG_SEQ_ADC        0x02U
      16           0 : #define AD559X_REG_GEN_CTRL       0x03U
      17           0 : #define AD559X_REG_ADC_CONFIG     0x04U
      18           0 : #define AD559X_REG_LDAC_EN        0x05U
      19           0 : #define AD559X_REG_GPIO_PULLDOWN  0x06U
      20           0 : #define AD559X_REG_READ_AND_LDAC  0x07U
      21           0 : #define AD559X_REG_GPIO_OUTPUT_EN 0x08U
      22           0 : #define AD559X_REG_GPIO_SET       0x09U
      23           0 : #define AD559X_REG_GPIO_INPUT_EN  0x0AU
      24           0 : #define AD559X_REG_PD_REF_CTRL    0x0BU
      25           0 : #define AD559X_REG_IO_TS_CONFIG   0x0DU
      26             : 
      27           0 : #define AD559X_DAC_RANGE BIT(4)
      28           0 : #define AD559X_ADC_RANGE BIT(5)
      29           0 : #define AD559X_EN_REF    BIT(9)
      30             : 
      31           0 : #define AD559X_PIN_MAX 8U
      32             : 
      33             : /**
      34             :  * @defgroup mdf_interface_ad559x MFD AD559X interface
      35             :  * @ingroup mfd_interfaces
      36             :  * @{
      37             :  */
      38             : 
      39             : /**
      40             :  * @brief Check if the chip has a pointer byte map
      41             :  *
      42             :  * @param[in] dev Pointer to MFD device
      43             :  *
      44             :  * @retval true if chip has a pointer byte map, false if it has normal register map
      45             :  */
      46           1 : bool mfd_ad559x_has_pointer_byte_map(const struct device *dev);
      47             : 
      48             : /**
      49             :  * @brief Read raw data from the chip
      50             :  *
      51             :  * @param[in] dev Pointer to MFD device
      52             :  * @param[in] val Pointer to data buffer
      53             :  * @param[in] len Number of bytes to be read
      54             :  *
      55             :  * @retval 0 if success
      56             :  * @retval negative errno if failure
      57             :  */
      58           1 : int mfd_ad559x_read_raw(const struct device *dev, uint8_t *val, size_t len);
      59             : 
      60             : /**
      61             :  * @brief Write raw data to chip
      62             :  *
      63             :  * @param[in] dev Pointer to MFD device
      64             :  * @param[in] val Data to be written
      65             :  * @param[in] len Number of bytes to be written
      66             :  *
      67             :  * @retval 0 if success
      68             :  * @retval negative errno if failure
      69             :  */
      70           1 : int mfd_ad559x_write_raw(const struct device *dev, uint8_t *val, size_t len);
      71             : 
      72             : /**
      73             :  * @brief Read data from provided register
      74             :  *
      75             :  * @param[in] dev Pointer to MFD device
      76             :  * @param[in] reg Register to be read
      77             :  * @param[in] reg_data Additional data passed to selected register
      78             :  * @param[in] val Pointer to data buffer
      79             :  *
      80             :  * @retval 0 if success
      81             :  * @retval negative errno if failure
      82             :  */
      83           1 : int mfd_ad559x_read_reg(const struct device *dev, uint8_t reg, uint8_t reg_data, uint16_t *val);
      84             : 
      85             : /**
      86             :  * @brief Write data to provided register
      87             :  *
      88             :  * @param[in] dev Pointer to MFD device
      89             :  * @param[in] reg Register to be written
      90             :  * @param[in] val Data to be written
      91             :  *
      92             :  * @retval 0 if success
      93             :  * @retval negative errno if failure
      94             :  */
      95           1 : int mfd_ad559x_write_reg(const struct device *dev, uint8_t reg, uint16_t val);
      96             : 
      97             : /**
      98             :  * @brief Read ADC channel data from the chip
      99             :  *
     100             :  * @param[in] dev Pointer to MFD device
     101             :  * @param[in] channel Channel to read
     102             :  * @param[out] result ADC channel value read
     103             :  *
     104             :  * @retval 0 if success
     105             :  * @retval negative errno if failure
     106             :  */
     107           1 : int mfd_ad559x_read_adc_chan(const struct device *dev, uint8_t channel, uint16_t *result);
     108             : 
     109             : /**
     110             :  * @brief Write ADC channel data to the chip
     111             :  *
     112             :  * @param[in] dev Pointer to MFD device
     113             :  * @param[in] channel Channel to write to
     114             :  * @param[in] value DAC channel value
     115             :  *
     116             :  * @retval 0 if success
     117             :  * @retval negative errno if failure
     118             :  */
     119           1 : int mfd_ad559x_write_dac_chan(const struct device *dev, uint8_t channel, uint16_t value);
     120             : 
     121             : /**
     122             :  * @brief Read GPIO port from the chip
     123             :  *
     124             :  * @param[in] dev Pointer to MFD device
     125             :  * @param[in] gpio GPIO to read
     126             :  * @param[in] value DAC channel value
     127             :  *
     128             :  * @retval 0 if success
     129             :  * @retval negative errno if failure
     130             :  */
     131           1 : int mfd_ad559x_gpio_port_get_raw(const struct device *dev, uint8_t gpio, uint16_t *value);
     132             : /**
     133             :  * @}
     134             :  */
     135             : 
     136             : #ifdef __cplusplus
     137             : }
     138             : #endif
     139             : 
     140             : #endif /* ZEPHYR_INCLUDE_DRIVERS_MFD_AD559X_H_ */

Generated by: LCOV version 1.14