LCOV - code coverage report
Current view: top level - zephyr/drivers/comparator - nrf_comp.h Coverage Total Hit
Test: new.info Lines: 95.0 % 20 19
Test Date: 2025-10-20 12:20:01

            Line data    Source code
       1            0 : /*
       2              :  * Copyright (c) 2024 Nordic Semiconductor ASA
       3              :  *
       4              :  * SPDX-License-Identifier: Apache-2.0
       5              :  */
       6              : 
       7              : #ifndef ZEPHYR_INCLUDE_DRIVERS_COMP_NRF_COMP_H_
       8              : #define ZEPHYR_INCLUDE_DRIVERS_COMP_NRF_COMP_H_
       9              : 
      10              : #include <zephyr/dt-bindings/comparator/nrf-comp.h>
      11              : #include <zephyr/drivers/comparator.h>
      12              : 
      13              : #ifdef __cplusplus
      14              : extern "C" {
      15              : #endif
      16              : 
      17              : /** Reference selection */
      18            1 : enum comp_nrf_comp_refsel {
      19              :         /** Internal 1.2V reference */
      20              :         COMP_NRF_COMP_REFSEL_INT_1V2,
      21              :         /** Internal 1.8V reference */
      22              :         COMP_NRF_COMP_REFSEL_INT_1V8,
      23              :         /** Internal 2.4V reference */
      24              :         COMP_NRF_COMP_REFSEL_INT_2V4,
      25              :         /** AVDD 1.8V reference */
      26              :         COMP_NRF_COMP_REFSEL_AVDDAO1V8,
      27              :         /** VDD reference */
      28              :         COMP_NRF_COMP_REFSEL_VDD,
      29              :         /** Use external analog reference */
      30              :         COMP_NRF_COMP_REFSEL_AREF,
      31              : };
      32              : 
      33              : /** Speed mode selection */
      34            1 : enum comp_nrf_comp_sp_mode {
      35              :         /** Low-power mode */
      36              :         COMP_NRF_COMP_SP_MODE_LOW,
      37              :         /** Normal mode */
      38              :         COMP_NRF_COMP_SP_MODE_NORMAL,
      39              :         /** High-speed mode */
      40              :         COMP_NRF_COMP_SP_MODE_HIGH,
      41              : };
      42              : 
      43              : /** Current source configuration */
      44            1 : enum comp_nrf_comp_isource {
      45              :         /** Current source disabled */
      46              :         COMP_NRF_COMP_ISOURCE_DISABLED,
      47              :         /** 2.5uA current source enabled */
      48              :         COMP_NRF_COMP_ISOURCE_2UA5,
      49              :         /** 5uA current source enabled */
      50              :         COMP_NRF_COMP_ISOURCE_5UA,
      51              :         /** 10uA current source enabled */
      52              :         COMP_NRF_COMP_ISOURCE_10UA,
      53              : };
      54              : 
      55              : /**
      56              :  * @brief Single-ended mode configuration structure
      57              :  *
      58              :  * @note extrefsel is only used if refsel == COMP_NRF_COMP_REFSEL_AREF
      59              :  * @note Hysteresis down in volts = ((th_down + 1) / 64) * ref
      60              :  * @note Hysteresis up in volts = ((th_up + 1) / 64) * ref
      61              :  */
      62            1 : struct comp_nrf_comp_se_config {
      63              :         /** Positive input selection defined by the NRF_COMP_AIN defines */
      64            1 :         uint8_t psel;
      65              :         /** Speed mode selection */
      66            1 :         enum comp_nrf_comp_sp_mode sp_mode;
      67              :         /** Current source configuration */
      68            1 :         enum comp_nrf_comp_isource isource;
      69              :         /** External reference input selection defined by the NRF_COMP_AIN defines */
      70            1 :         uint8_t extrefsel;
      71              :         /** Reference selection */
      72            1 :         enum comp_nrf_comp_refsel refsel;
      73              :         /** Hysteresis down threshold configuration */
      74            1 :         uint8_t th_down;
      75              :         /** Hysteresis up threshold configuration */
      76            1 :         uint8_t th_up;
      77              : };
      78              : 
      79              : /**
      80              :  * @brief Configure comparator in single-ended mode
      81              :  *
      82              :  * @param dev Comparator device instance
      83              :  * @param config Single-ended mode configuration
      84              :  *
      85              :  * @retval 0 if successful
      86              :  * @retval negative errno-code otherwise
      87              :  */
      88            1 : int comp_nrf_comp_configure_se(const struct device *dev,
      89              :                                const struct comp_nrf_comp_se_config *config);
      90              : 
      91              : /** Differential mode configuration structure */
      92            1 : struct comp_nrf_comp_diff_config {
      93              :         /** Positive input selection defined by the NRF_COMP_AIN defines */
      94            1 :         uint8_t psel;
      95              :         /** Speed mode selection */
      96            1 :         enum comp_nrf_comp_sp_mode sp_mode;
      97              :         /** Current source configuration */
      98            1 :         enum comp_nrf_comp_isource isource;
      99              :         /** Negative input selection defined by the NRF_COMP_AIN defines */
     100            1 :         uint8_t extrefsel;
     101              :         /** Hysteresis configuration */
     102            1 :         bool enable_hyst;
     103              : };
     104              : 
     105              : /**
     106              :  * @brief Configure comparator in differential mode
     107              :  *
     108              :  * @param dev Comparator device instance
     109              :  * @param config Differential mode configuration
     110              :  *
     111              :  * @retval 0 if successful
     112              :  * @retval negative errno-code otherwise
     113              :  */
     114            1 : int comp_nrf_comp_configure_diff(const struct device *dev,
     115              :                                  const struct comp_nrf_comp_diff_config *config);
     116              : 
     117              : #ifdef __cplusplus
     118              : }
     119              : #endif
     120              : 
     121              : #endif /* ZEPHYR_INCLUDE_DRIVERS_COMP_NRF_COMP_H_ */
        

Generated by: LCOV version 2.0-1