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

            Line data    Source code
       1            1 : /*
       2              :  * Copyright (c) 2023 SILA Embedded Solutions GmbH
       3              :  *
       4              :  * SPDX-License-Identifier: Apache-2.0
       5              :  */
       6              : 
       7              : /**
       8              :  * @file
       9              :  * @brief Header file for MAX31790 PWM driver
      10              :  * @ingroup pwm_max31790_interface
      11              :  */
      12              : 
      13              : #ifndef ZEPHYR_INCLUDE_DRIVERS_PWM_MAX31790_H_
      14              : #define ZEPHYR_INCLUDE_DRIVERS_PWM_MAX31790_H_
      15              : 
      16              : /**
      17              :  * @defgroup pwm_max31790_interface MAX31790
      18              :  * @ingroup pwm_interface_ext
      19              :  * @brief Maxim MAX31790 6-channel I2C-bus PWM controller
      20              :  * @{
      21              :  */
      22              : 
      23              : /**
      24              :  * @name Custom PWM flags for MAX31790
      25              :  *
      26              :  * These flags can be used with the PWM API in the upper 8 bits of pwm_flags_t
      27              :  * They allow the usage of the RPM mode, which will cause the MAX31790 to
      28              :  * measure the actual speed of the fan and automatically control it to the
      29              :  * desired speed.
      30              :  * @{
      31              :  */
      32              : /** @cond INTERNAL_HIDDEN */
      33              : #define PWM_MAX31790_FLAG_RPM_MODE_POS           8
      34              : #define PWM_MAX31790_FLAG_SPEED_RANGE_POS        9
      35              : #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS 12
      36              : #define PWM_MAX31790_FLAG_SPIN_UP_POS            15
      37              : /** @endcond */
      38              : 
      39              : /**
      40              :  * @brief RPM mode
      41              :  *
      42              :  * Activating the RPM mode will cause the parameter pulse of @ref pwm_set_cycles
      43              :  * to be interpreted as TACH target count. This basically is the number of internal
      44              :  * pulses which occur during each TACH period. Hence, a bigger value means a slower
      45              :  * rotation of the fan. The details about the TACH target count has to be calculated
      46              :  * can be taken from the datasheet of the MAX31790.
      47              :  */
      48            1 : #define PWM_MAX31790_FLAG_RPM_MODE             (1 << PWM_MAX31790_FLAG_RPM_MODE_POS)
      49              : 
      50              : /**
      51              :  * @name Speed range of fan
      52              :  *
      53              :  * This represents a multiplier for the TACH count and should be chosen depending
      54              :  * on the nominal RPM of the fan. A detailed table on how to choose a proper value
      55              :  * can be found in the datasheet of the MAX31790.
      56              :  *
      57              :  * @{
      58              :  */
      59              : /** 1 TACH period (best for low-speed fans). */
      60            1 : #define PWM_MAX31790_FLAG_SPEED_RANGE_1        (0 << PWM_MAX31790_FLAG_SPEED_RANGE_POS)
      61              : /** 2 TACH periods */
      62            1 : #define PWM_MAX31790_FLAG_SPEED_RANGE_2        (1 << PWM_MAX31790_FLAG_SPEED_RANGE_POS)
      63              : /** 4 TACH periods */
      64            1 : #define PWM_MAX31790_FLAG_SPEED_RANGE_4        (2 << PWM_MAX31790_FLAG_SPEED_RANGE_POS)
      65              : /** 8 TACH periods */
      66            1 : #define PWM_MAX31790_FLAG_SPEED_RANGE_8        (3 << PWM_MAX31790_FLAG_SPEED_RANGE_POS)
      67              : /** 16 TACH periods */
      68            1 : #define PWM_MAX31790_FLAG_SPEED_RANGE_16       (4 << PWM_MAX31790_FLAG_SPEED_RANGE_POS)
      69              : /** 32 TACH periods (best for high-speed fans). */
      70            1 : #define PWM_MAX31790_FLAG_SPEED_RANGE_32       (5 << PWM_MAX31790_FLAG_SPEED_RANGE_POS)
      71              : /** @} */
      72              : 
      73              : /**
      74              :  * @name PWM rate of change
      75              :  *
      76              :  * Configures the internal control loop of the fan. Details about these values can be found
      77              :  * in the datasheet of the MAX31790.
      78              :  *
      79              :  * @{
      80              :  */
      81              : /** Fastest rate of change (0ms per step in PWM mode). */
      82            1 : #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_0 (0 << PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS)
      83              : /** Fast rate of change (1.953125 ms per step). */
      84            1 : #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_1 (1 << PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS)
      85              : /** Medium-fast rate of change (3.90625 ms per step). */
      86            1 : #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_2 (2 << PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS)
      87              : /** Medium rate of change (7.8125 ms per step). */
      88            1 : #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_3 (3 << PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS)
      89              : /** Medium-slow rate of change (15.625 ms per step). */
      90            1 : #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_4 (4 << PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS)
      91              : /** Slow rate of change (31.25 ms per step). */
      92            1 : #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_5 (5 << PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS)
      93              : /** Very slow rate of change (62.5 ms per step). */
      94            1 : #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_6 (6 << PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS)
      95              : /** Ultra-slow rate of change (125 ms per step). */
      96            1 : #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_7 (7 << PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS)
      97              : /** @} */
      98              : 
      99              : /**
     100              :  * @brief Activate spin up for fan
     101              :  *
     102              :  * This activates the spin up of the fan, which means that the controller will force the fan
     103              :  * to maximum speed for a startup from a completely stopped state.
     104              :  */
     105            1 : #define PWM_MAX31790_FLAG_SPIN_UP              (1 << PWM_MAX31790_FLAG_SPIN_UP_POS)
     106              : /** @} */
     107              : 
     108              : /**
     109              :  * @}
     110              :  */
     111              : 
     112              : #endif /* ZEPHYR_INCLUDE_DRIVERS_PWM_MAX31790_H_ */
        

Generated by: LCOV version 2.0-1