|
@@ -445,6 +445,8 @@ static void do_next_command(struct ctl_state *state)
|
|
|
UINT rlen = 0;
|
|
|
FRESULT rv;
|
|
|
|
|
|
+ set_led(LED_DISKIO, true);
|
|
|
+
|
|
|
rv = f_lseek(&drv->file, file_pos(state));
|
|
|
if (rv == FR_OK)
|
|
|
rv = f_read(&drv->file, buf, 256, &rlen);
|
|
@@ -480,6 +482,8 @@ static void do_next_command(struct ctl_state *state)
|
|
|
UINT wlen = 0;
|
|
|
FRESULT rv;
|
|
|
|
|
|
+ set_led(LED_DISKIO, true);
|
|
|
+
|
|
|
rv = f_lseek(&drv->file, file_pos(state));
|
|
|
if (rv == FR_OK)
|
|
|
rv = f_write(&drv->file, buf, 256, &wlen);
|
|
@@ -604,9 +608,12 @@ static int mount_disk(void)
|
|
|
uint32_t volid, freeclust;
|
|
|
FATFS *fs;
|
|
|
|
|
|
+ set_led(LED_DISKIO, true);
|
|
|
+
|
|
|
rv = f_mount(&sd_fs, "", 1);
|
|
|
if (rv != FR_OK) {
|
|
|
con_printf("sdcard: no volume found\n");
|
|
|
+ set_led(LED_DISKIO, false);
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
@@ -625,20 +632,20 @@ static int mount_disk(void)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-#define SYNC_TIME (2*TIMER_HZ) /* 2 s */
|
|
|
+#define SYNC_TIME (1*TIMER_HZ) /* 1 s */
|
|
|
|
|
|
/* Called from the main loop */
|
|
|
void abcdisk_io_poll(void)
|
|
|
{
|
|
|
static uint32_t last_sync;
|
|
|
- uint32_t now = timer_count();
|
|
|
- bool need_sync = (now - last_sync) >= SYNC_TIME;
|
|
|
- last_sync = now;
|
|
|
- uint32_t abc_status = ABC_STATUS;
|
|
|
+ static uint32_t last_timer = -1U;
|
|
|
static uint32_t prev_abc_status = -1U;
|
|
|
+
|
|
|
+ uint32_t now = timer_count();
|
|
|
+ bool need_sync = false;
|
|
|
+ uint32_t abc_status = ABC_STATUS & (ABC_STATUS_LIVE | ABC_STATUS_800);
|
|
|
bool unmount_all = false;
|
|
|
bool reset_all = false;
|
|
|
- static uint32_t last_timer = -1U;
|
|
|
|
|
|
if (now != last_timer) {
|
|
|
/*
|
|
@@ -652,16 +659,23 @@ void abcdisk_io_poll(void)
|
|
|
unmount_all = true;
|
|
|
} else if (sdcard_present_poll() & STA_NOINIT) {
|
|
|
unmount_all = true;
|
|
|
+ } else {
|
|
|
+ if ((now - last_sync) >= SYNC_TIME) {
|
|
|
+ need_sync = true;
|
|
|
+ last_sync = now;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
last_timer = now;
|
|
|
}
|
|
|
|
|
|
- if ((abc_status ^ prev_abc_status) & (ABC_STATUS_LIVE|ABC_STATUS_800)) {
|
|
|
+ if (abc_status != prev_abc_status) {
|
|
|
const char *host;
|
|
|
|
|
|
prev_abc_status = abc_status;
|
|
|
|
|
|
+ set_led(LED_ABCBUS, !!(abc_status & ABC_STATUS_LIVE));
|
|
|
+
|
|
|
con_puts("ABC-bus host: ");
|
|
|
con_puts(abc_status & ABC_STATUS_800 ? "ABC800" : "ABC80");
|
|
|
con_puts(abc_status & ABC_STATUS_LIVE ? " (online)\n" : " (offline)\n");
|
|
@@ -695,12 +709,18 @@ void abcdisk_io_poll(void)
|
|
|
if (pending & PEND_RESET)
|
|
|
disk_reset_state(state);
|
|
|
|
|
|
- if (pending & PEND_IO)
|
|
|
+ if (pending & PEND_IO) {
|
|
|
do_next_command(state);
|
|
|
+ }
|
|
|
|
|
|
if (need_sync)
|
|
|
sync_drives(state);
|
|
|
}
|
|
|
+
|
|
|
+ if (need_sync) {
|
|
|
+ /* Did we sync drives? */
|
|
|
+ set_led(LED_DISKIO, false);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/*
|