Permalink
Browse files

Merge branch 'feature/eeprom-flags' into develop

  • Loading branch information...
kcuzner committed Aug 12, 2013
2 parents b579bd7 + 418d4f0 commit 8cb99e07dee7fbaf482ded0405dbf21efbd647a5
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/main.c
View
@@ -20,6 +20,7 @@
#include <stdint.h>
+#include <avr/eeprom.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
@@ -41,6 +42,11 @@
#define EMU_FLAG 0x01
+/**
+ * Flags variable, in EEPROM!
+ */
+uint8_t EEMEM flagsEEPROM = 0;
+
uint8_t flags;
void sync_status()
@@ -63,8 +69,7 @@ void sync_status()
int main(void)
{
- //by default, we are in emulator mode
- flags = EMU_FLAG;
+ flags = eeprom_read_byte(&flagsEEPROM) & (EMU_FLAG);
//set up psx
psx_setup();
@@ -165,6 +170,7 @@ ISR(TIMER1_OVF_vect)
{
//if we managed to overflow, we switch modes and switch off the clock
flags ^= EMU_FLAG;
+ eeprom_update_byte(&flagsEEPROM, flags);
sync_status();
TCCR1B &= ~((1 << CS12) | (1 << CS11) | (1 << CS10));
}

0 comments on commit 8cb99e0

Please sign in to comment.