Store setup settings in eeprom
To have the values of `value_contrast` and `value_backlight` persist over turn offs they are loaded and stored from and in the eeprom. For preventing the flash target from earasing the eeprom the `EESAVE` high fuse byte is set to 0 (programmed). The values are now loaded when booted and stored when a new value is set in the setup menu.
This commit is contained in:
parent
acf4bc5754
commit
05c9888a75
2 changed files with 27 additions and 3 deletions
|
@ -5,9 +5,12 @@ PROGRAMMER := usbasp
|
|||
SPEED := 8000000UL
|
||||
|
||||
TARGET := main.hex
|
||||
EEP := main.eep
|
||||
BIN := main.elf
|
||||
OBJ := main.o
|
||||
|
||||
HIGH_FUSE := 0xD6
|
||||
|
||||
SHELL := sh
|
||||
CC := avr-gcc
|
||||
OBJCOPY := avr-objcopy
|
||||
|
@ -16,24 +19,33 @@ AVRDUDE := avrdude
|
|||
|
||||
CFLAGS := -mmcu=$(MCU) -D F_CPU=$(SPEED) -Os -Wall -Werror -Wextra
|
||||
|
||||
all: $(TARGET)
|
||||
all: $(TARGET) $(EEP)
|
||||
|
||||
$(TARGET): $(BIN)
|
||||
${OBJCOPY} -O ihex -j .text -j .data $< $@
|
||||
|
||||
$(EEP): $(BIN)
|
||||
${OBJCOPY} --change-section-lma .eeprom=0 -O ihex -j .eeprom $< $@
|
||||
|
||||
$(BIN): $(OBJ)
|
||||
$(CC) $(CFLAGS) $< -o $@
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
.PHONY: flash clean check size
|
||||
.PHONY: flash eeprom fuses clean check size
|
||||
|
||||
flash: $(TARGET) size
|
||||
$(AVRDUDE) -p $(MCU) -c $(PROGRAMMER) -U flash:w:$<:a
|
||||
|
||||
eeprom: $(EEP) size
|
||||
$(AVRDUDE) -p $(MCU) -c $(PROGRAMMER) -U eeprom:w:$<:a
|
||||
|
||||
fuses:
|
||||
$(AVRDUDE) -p $(MCU) -c $(PROGRAMMER) -U hfuse:w:$(HIGH_FUSE):m
|
||||
|
||||
clean:
|
||||
$(RM) $(TARGET) $(BIN) $(OBJ)
|
||||
$(RM) $(TARGET) $(EEP) $(BIN) $(OBJ)
|
||||
|
||||
check:
|
||||
cppcheck main.c
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue