summaryrefslogtreecommitdiff
path: root/firmware/drivers/ata_mmc.c
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2005-02-19 14:45:34 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2005-02-19 14:45:34 +0000
commit7e1d36f35b7757c7d3482d973370e71a9dfc9504 (patch)
treea5f1dc299f7e64f2478e38392e257a7cbc67d66f /firmware/drivers/ata_mmc.c
parent2e429ff76221e2d39a35d8875c6a3add76191519 (diff)
downloadrockbox-7e1d36f35b7757c7d3482d973370e71a9dfc9504.zip
rockbox-7e1d36f35b7757c7d3482d973370e71a9dfc9504.tar.gz
rockbox-7e1d36f35b7757c7d3482d973370e71a9dfc9504.tar.bz2
rockbox-7e1d36f35b7757c7d3482d973370e71a9dfc9504.tar.xz
Ondio: disk activity indication in USB mode, too
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6020 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/ata_mmc.c')
-rw-r--r--firmware/drivers/ata_mmc.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c
index 7139f03..2ba465f 100644
--- a/firmware/drivers/ata_mmc.c
+++ b/firmware/drivers/ata_mmc.c
@@ -121,6 +121,8 @@ static int current_card = 0;
#endif
static bool last_mmc_status = false;
static int countdown; /* for mmc switch debouncing */
+static bool usb_activity; /* monitoring the USB bridge */
+static long last_activity;
/* private function declarations */
@@ -708,7 +710,7 @@ int ata_write_sectors(IF_MV2(int drive,)
addr = start * SECTOR_SIZE;
mutex_lock(&mmc_mutex);
- led(true);
+ led(true);
#ifdef HAVE_MULTIVOLUME
card = &card_info[drive];
ret = select_card(drive);
@@ -753,7 +755,7 @@ int ata_write_sectors(IF_MV2(int drive,)
}
deselect_card();
- led(false);
+ led(false);
mutex_unlock(&mmc_mutex);
/* only flush if writing went ok */
@@ -842,12 +844,26 @@ bool mmc_detect(void)
return adc_read(ADC_MMC_SWITCH) < 0x200 ? true : false;
}
+bool mmc_usb_active(int delayticks)
+{
+ /* reading "inactive" is delayed by user-supplied monoflop value */
+ return (usb_activity ||
+ TIME_BEFORE(current_tick, last_activity+delayticks));
+}
+
static void mmc_tick(void)
{
bool current_status;
+ /* USB bridge activity is 0 on idle, ~527 on active */
+ current_status = adc_read(ADC_USB_ACTIVE) > 0x100;
+ if (!current_status && usb_activity)
+ {
+ last_activity = current_tick;
+ }
+ usb_activity = current_status;
+
current_status = mmc_detect();
-
/* Only report when the status has changed */
if (current_status != last_mmc_status)
{