mirror of
https://github.com/Polprzewodnikowy/SummerCart64.git
synced 2024-11-25 15:16:53 +01:00
[SC64][SW] Disable save writeback on SD card removal or write error
This commit is contained in:
parent
ed25ef16e9
commit
d5ae5b14aa
@ -2,7 +2,6 @@
|
|||||||
#include "sd.h"
|
#include "sd.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "writeback.h"
|
#include "writeback.h"
|
||||||
#include "led.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define SAVE_MAX_SECTOR_COUNT (256)
|
#define SAVE_MAX_SECTOR_COUNT (256)
|
||||||
@ -33,6 +32,7 @@ static void writeback_save_to_sd (void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (sd_write_sectors(save_address, sector, 1)) {
|
if (sd_write_sectors(save_address, sector, 1)) {
|
||||||
|
p.enabled = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
save_address += SD_SECTOR_SIZE;
|
save_address += SD_SECTOR_SIZE;
|
||||||
@ -66,12 +66,16 @@ void writeback_init (void) {
|
|||||||
|
|
||||||
void writeback_process (void) {
|
void writeback_process (void) {
|
||||||
if (p.enabled) {
|
if (p.enabled) {
|
||||||
|
if (fpga_reg_get(REG_SD_SCR) & SD_SCR_CARD_INSERTED) {
|
||||||
uint16_t save_count = fpga_reg_get(REG_SAVE_COUNT);
|
uint16_t save_count = fpga_reg_get(REG_SAVE_COUNT);
|
||||||
if (save_count != p.last_save_count) {
|
if (save_count != p.last_save_count) {
|
||||||
p.pending = true;
|
p.pending = true;
|
||||||
timer_set(TIMER_ID_WRITEBACK, WRITEBACK_DELAY_TICKS);
|
timer_set(TIMER_ID_WRITEBACK, WRITEBACK_DELAY_TICKS);
|
||||||
p.last_save_count = save_count;
|
p.last_save_count = save_count;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
writeback_init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (p.pending) {
|
if (p.pending) {
|
||||||
if (timer_get(TIMER_ID_WRITEBACK) == 0) {
|
if (timer_get(TIMER_ID_WRITEBACK) == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user