From 53cbb2cc3d1e1fd91f60c74ab4177fa0c50209be Mon Sep 17 00:00:00 2001 From: Stephen Crane Date: Fri, 31 Oct 2014 08:44:28 +0000 Subject: [PATCH] break hardware_reset() out of hardware_init() --- hardware.cpp | 19 ++++++++++++------- hardware.h | 3 ++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/hardware.cpp b/hardware.cpp index 604c963..10c35b3 100644 --- a/hardware.cpp +++ b/hardware.cpp @@ -14,15 +14,10 @@ spiram sram(SPIRAM_SIZE); UTFT utft(TFT_MODEL, TFT_RS, TFT_WR, TFT_CS, TFT_RST); static CPU *_cpu; -bool hardware_init(CPU &cpu) { - _cpu = &cpu; - ps2.begin(KBD_DATA, KBD_IRQ); - - pinMode(SD_CS, OUTPUT); +bool hardware_reset() { bool sd = SD.begin(SD_CS, 3, SD_SPI); #if defined(TFT_BACKLIGHT) - pinMode(TFT_BACKLIGHT, OUTPUT); digitalWrite(TFT_BACKLIGHT, HIGH); #endif utft.InitLCD(); @@ -31,10 +26,20 @@ bool hardware_init(CPU &cpu) { sram.begin(SPIRAM_CS, SPIRAM_SPI); - cpu.reset(); + _cpu->reset(); return sd; } +void hardware_init(CPU &cpu) { + _cpu = &cpu; + memory.begin(); + ps2.begin(KBD_DATA, KBD_IRQ); + pinMode(SD_CS, OUTPUT); +#if defined(TFT_BACKLIGHT) + pinMode(TFT_BACKLIGHT, OUTPUT); +#endif +} + void hardware_checkpoint(Stream &s) { unsigned ds = 0; for (unsigned i = 0; i < 0x10000; i += ds) { diff --git a/hardware.h b/hardware.h index 15c316c..633f984 100644 --- a/hardware.h +++ b/hardware.h @@ -32,7 +32,8 @@ #define SD_CS PF_3 #define SD_SPI 1 -bool hardware_init(class CPU &); +bool hardware_reset(); +void hardware_init(class CPU &); void hardware_checkpoint(Stream &); // FIXME: make a path? void hardware_restore(Stream &);