int8_t internal_temp_error_shutdown = 0; /* Flag and error code */
uint8_t external_disable = 0; /* Flag only */
uint8_t mosfet_temp_shutdown = 0; /* Flag only */
-uint8_t overvoltage = 0; /* Flag and counter. Used to create a delay when overvoltage is detected,
+volatile uint8_t overvoltage = 0; /* Flag and counter. Used to create a delay when overvoltage is detected,
set to OVERVOLTAGE_PROTECTION_CYCLES and decreases to 0 */
/* Current running mode */
overvoltage = OVERVOLTAGE_PROTECTION_CYCLES;
gpio_set(fan_ctrl); /* Turn on FAN immediatly */
/* Change current working mode */
- old_mode = mode;
- mode = mode_overvoltage;
+ if (mode != mode_overvoltage) {
+ old_mode = mode;
+ mode = mode_overvoltage;
+ }
}