Add fan module and implement fan_max switch

This commit is contained in:
Jeremy Soller
2020-10-05 09:44:05 -06:00
committed by Jeremy Soller
parent e01e712745
commit a8f5fc5ec0
5 changed files with 41 additions and 16 deletions

View File

@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include <stdbool.h>
#include <board/fan.h>
#include <board/peci.h>
#include <board/power.h>
#include <common/debug.h>
@ -34,12 +33,6 @@ int16_t peci_temp = 0;
uint8_t peci_duty = 0;
#define PECI_TEMP(X) (((int16_t)(X)) << 6)
#define PWM_DUTY(X) ((uint8_t)(((((uint16_t)(X)) * 255) + 99) / 100))
struct FanPoint {
int16_t temp;
uint8_t duty;
};
#define FAN_POINT(T, D) { .temp = PECI_TEMP(T), .duty = PWM_DUTY(D) }
@ -237,6 +230,10 @@ void peci_event(void) {
uint8_t heatup_duty = fan_heatup(peci_duty);
uint8_t cooldown_duty = fan_cooldown(heatup_duty);
if (fan_max) {
// Override duty if fans are manually set to maximum
cooldown_duty = 0xFF;
}
if (cooldown_duty != DCR2) {
DCR2 = cooldown_duty;
DEBUG("PECI offset=%d, temp=%d = %d\n", peci_offset, peci_temp, cooldown_duty);