Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NUSense/Core/Inc/fan_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ void set_fan_manual_pwm(uint8_t pwm_value);
/// @return The speed in RPM.
uint16_t read_fan_speed(uint8_t tachometer);

/// @brief Sets the fan mode between manual and automatic which controls whether the fan speed is driven by the onboard temp or some arbitrary PWM value.
/// @param mode true for manual mode (Direct Fan Control enabled), false for automatic mode (Direct Fan Control disabled)
void set_fan_mode(bool mode);

/// @brief Enables or disables the tachometer for the specified fan.
/// @param tachometer 0 for Tachometer 1, 1 for Tachometer 2
/// @param enabled true to enable, false to disable
Expand Down
7 changes: 0 additions & 7 deletions NUSense/Core/Inc/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ void MX_I2C3_Init(void);
*/
void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c);

/**
* @brief GPIO Initialisation Function
* @param None
* @retval None
*/
void MX_GPIO_Init(void);

#ifdef __cplusplus
}
#endif
Expand Down
11 changes: 11 additions & 0 deletions NUSense/Core/Src/fan_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ uint16_t read_fan_speed(uint8_t tachometer) {
return 60 * 100000 / fan_count / PULSES_PER_REVOLUTION;
}

void set_fan_mode(bool mode)
{
uint8_t control2 = read_fan_register(REG_CONTROL2);
if (mode) {
control2 |= (1 << 0); // set bit 0 to enable Direct Fan Control
} else {
control2 &= ~(1 << 0); // clear bit 0 to disable Direct Fan Control
}
write_fan_register(REG_CONTROL2, control2);
}

void fan_controller_init() {
set_fan_mode(true);

Expand Down