Нет, неправильно.
#include <avr/eeprom.h>
typedef enum {Speed_0, Speed_1, Speed_2, Speed_3} Speeds;
uint8_t CoolLevelsNV[3] EEMEM = { 70, 130, 255 };
uint8_t GetCoolerSpeedValue(Speeds CoolerSpeed)
{
uint8_t Value;
switch (CoolerSpeed)
{
case Speed_0:
Value = 0x00;
break;
case Speed_1:
Value = eeprom_read_byte(&CoolLevelsNV[0]); // PWM 25%
break;
case Speed_2:
Value = eeprom_read_byte(&CoolLevelsNV[1]); // PWM 50%
break;
case Speed_3:
default:
Value = eeprom_read_byte(&CoolLevelsNV[2]); // PWM 100%
break;
}
return Value;
}
void SetCoolerSpeedValue(Speeds CoolerSpeed, uint8_t Value)
{
switch (CoolerSpeed)
{
case Speed_0:
break;
case Speed_1:
eeprom_write_byte (&CoolLevelsNV[0], Value); // PWM 25%
break;
case Speed_2:
eeprom_write_byte (&CoolLevelsNV[1], Value); // PWM 50%
break;
case Speed_3:
default:
eeprom_write_byte (&CoolLevelsNV[2], Value); // PWM 100%
break;
}
}
memento mori