1 /* 2 * Copyright (c) 2023 SILA Embedded Solutions GmbH 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_INCLUDE_DRIVERS_PWM_MAX31790_H_ 8 #define ZEPHYR_INCLUDE_DRIVERS_PWM_MAX31790_H_ 9 10 /** 11 * @name custom PWM flags for MAX31790 12 * These flags can be used with the PWM API in the upper 8 bits of pwm_flags_t 13 * They allow the usage of the RPM mode, which will cause the MAX31790 to 14 * measure the actual speed of the fan and automatically control it to the 15 * desired speed. 16 * @{ 17 */ 18 /** @cond INTERNAL_HIDDEN */ 19 #define PWM_MAX31790_FLAG_RPM_MODE_POS 8 20 #define PWM_MAX31790_FLAG_SPEED_RANGE_POS 9 21 #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS 12 22 #define PWM_MAX31790_FLAG_SPIN_UP_POS 15 23 /** @endcond */ 24 25 /*! 26 * @brief RPM mode 27 * 28 * Activating the RPM mode will cause the parameter pulse of @ref pwm_set_cycles 29 * to be interpreted as TACH target count. This basically is the number of internal 30 * pulses which occur during each TACH period. Hence, a bigger value means a slower 31 * rotation of the fan. The details about the TACH target count has to be calculated 32 * can be taken from the datasheet of the MAX31790. 33 */ 34 #define PWM_MAX31790_FLAG_RPM_MODE (1 << PWM_MAX31790_FLAG_RPM_MODE_POS) 35 /*! 36 * @brief speed range of fan 37 * 38 * This represents a multiplicator for the TACH count and should be chosen depending 39 * on the nominal RPM of the fan. A detailed table on how to choose a proper value 40 * can be found in the datasheet of the MAX31790. 41 */ 42 #define PWM_MAX31790_FLAG_SPEED_RANGE_1 (0 << PWM_MAX31790_FLAG_SPEED_RANGE_POS) 43 #define PWM_MAX31790_FLAG_SPEED_RANGE_2 (1 << PWM_MAX31790_FLAG_SPEED_RANGE_POS) 44 #define PWM_MAX31790_FLAG_SPEED_RANGE_4 (2 << PWM_MAX31790_FLAG_SPEED_RANGE_POS) 45 #define PWM_MAX31790_FLAG_SPEED_RANGE_8 (3 << PWM_MAX31790_FLAG_SPEED_RANGE_POS) 46 #define PWM_MAX31790_FLAG_SPEED_RANGE_16 (4 << PWM_MAX31790_FLAG_SPEED_RANGE_POS) 47 #define PWM_MAX31790_FLAG_SPEED_RANGE_32 (5 << PWM_MAX31790_FLAG_SPEED_RANGE_POS) 48 /*! 49 * @brief PWM rate of change 50 * 51 * Configures the internal control loop of the fan. Details about these values can be found 52 * in the datasheet of the MAX31790. 53 */ 54 #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_0 (0 << PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS) 55 #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_1 (1 << PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS) 56 #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_2 (2 << PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS) 57 #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_3 (3 << PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS) 58 #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_4 (4 << PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS) 59 #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_5 (5 << PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS) 60 #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_6 (6 << PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS) 61 #define PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_7 (7 << PWM_MAX31790_FLAG_PWM_RATE_OF_CHANGE_POS) 62 /*! 63 * @brief activate spin up for fan 64 * 65 * This activates the spin up of the fan, which means that the controller will force the fan 66 * to maximum speed for a startup from a completely stopped state. 67 */ 68 #define PWM_MAX31790_FLAG_SPIN_UP (1 << PWM_MAX31790_FLAG_SPIN_UP_POS) 69 /** @} */ 70 71 #endif /* ZEPHYR_INCLUDE_DRIVERS_PWM_MAX31790_H_ */ 72