ESP-Miner/main/thermal/thermal.c
Skot 7dcb69ebdc
GammaTurbo support and HW abstraction (#698)
* initial changes for the gammaturbo bringup
* added preliminary TPS546 changes
* added preliminary EMC2103 support
* ASIC temp seems to be maybe working.
* magically now fan seems to have the right polarity
* added in ideality and beta constants (currently unused). Fixed EMC2103_get_fan_speed()
* abstract fan and ASIC temp into thermal functions
* abstracted voltage regulator specifics out of tasks and into power.c and vcore.c functions
* add TPS546 support for multiple models
* move TPS40305/DS4432U vout setter to DS4432U.c
* move all ASIC specific functions to asic.c
* bad device_model nvs handling
* remove old code
* add workaround for TPS546 VIN_UV_WARN_LIMIT silicon bug.
2025-02-11 22:46:56 -05:00

83 lines
2.2 KiB
C

#include "thermal.h"
#define INTERNAL_OFFSET 5 //degrees C
esp_err_t Thermal_init(DeviceModel device_model, bool polarity) {
//init the EMC2101, if we have one
switch (device_model) {
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
EMC2101_init(polarity);
break;
case DEVICE_GAMMA:
EMC2101_init(polarity);
EMC2101_set_ideality_factor(EMC2101_IDEALITY_1_0319);
EMC2101_set_beta_compensation(EMC2101_BETA_11);
break;
case DEVICE_GAMMATURBO:
EMC2103_init(polarity);
break;
default:
}
return ESP_OK;
}
//percent is a float between 0.0 and 1.0
esp_err_t Thermal_set_fan_percent(DeviceModel device_model, float percent) {
switch (device_model) {
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
case DEVICE_GAMMA:
EMC2101_set_fan_speed(percent);
break;
case DEVICE_GAMMATURBO:
EMC2103_set_fan_speed(percent);
break;
default:
}
return ESP_OK;
}
uint16_t Thermal_get_fan_speed(DeviceModel device_model) {
switch (device_model) {
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
case DEVICE_GAMMA:
return EMC2101_get_fan_speed();
case DEVICE_GAMMATURBO:
return EMC2103_get_fan_speed();
default:
}
return 0;
}
float Thermal_get_chip_temp(GlobalState * GLOBAL_STATE) {
if (!GLOBAL_STATE->ASIC_initalized) {
return -1;
}
switch (GLOBAL_STATE->device_model) {
case DEVICE_MAX:
return EMC2101_get_external_temp();
case DEVICE_ULTRA:
case DEVICE_SUPRA:
if (GLOBAL_STATE->board_version >= 402 && GLOBAL_STATE->board_version <= 499) {
return EMC2101_get_external_temp();
} else {
return EMC2101_get_internal_temp() + INTERNAL_OFFSET;
}
case DEVICE_GAMMA:
return EMC2101_get_external_temp();
case DEVICE_GAMMATURBO:
return EMC2103_get_external_temp();
default:
}
return -1;
}