summaryrefslogtreecommitdiff
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
parent2e429ff76221e2d39a35d8875c6a3add76191519 (diff)
downloadrockbox-7e1d36f35b7757c7d3482d973370e71a9dfc9504.tar.gz
rockbox-7e1d36f35b7757c7d3482d973370e71a9dfc9504.zip
Ondio: disk activity indication in USB mode, too
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6020 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/screens.c3
-rw-r--r--firmware/drivers/ata_mmc.c22
-rw-r--r--firmware/export/adc.h1
-rw-r--r--firmware/export/ata_mmc.h1
4 files changed, 24 insertions, 3 deletions
diff --git a/apps/screens.c b/apps/screens.c
index 10f9dd234d..145d2bbaca 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -111,6 +111,9 @@ void usb_screen(void)
111 usb_display_info(); 111 usb_display_info();
112 while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) { 112 while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) {
113 if(usb_inserted()) { 113 if(usb_inserted()) {
114#ifdef HAVE_MMC /* USB-MMC bridge can report activity */
115 led(mmc_usb_active(HZ));
116#endif
114 status_draw(false); 117 status_draw(false);
115 } 118 }
116 } 119 }
diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c
index 7139f0394f..2ba465f63d 100644
--- a/firmware/drivers/ata_mmc.c
+++ b/firmware/drivers/ata_mmc.c
@@ -121,6 +121,8 @@ static int current_card = 0;
121#endif 121#endif
122static bool last_mmc_status = false; 122static bool last_mmc_status = false;
123static int countdown; /* for mmc switch debouncing */ 123static int countdown; /* for mmc switch debouncing */
124static bool usb_activity; /* monitoring the USB bridge */
125static long last_activity;
124 126
125/* private function declarations */ 127/* private function declarations */
126 128
@@ -708,7 +710,7 @@ int ata_write_sectors(IF_MV2(int drive,)
708 addr = start * SECTOR_SIZE; 710 addr = start * SECTOR_SIZE;
709 711
710 mutex_lock(&mmc_mutex); 712 mutex_lock(&mmc_mutex);
711 led(true); 713 led(true);
712#ifdef HAVE_MULTIVOLUME 714#ifdef HAVE_MULTIVOLUME
713 card = &card_info[drive]; 715 card = &card_info[drive];
714 ret = select_card(drive); 716 ret = select_card(drive);
@@ -753,7 +755,7 @@ int ata_write_sectors(IF_MV2(int drive,)
753 } 755 }
754 756
755 deselect_card(); 757 deselect_card();
756 led(false); 758 led(false);
757 mutex_unlock(&mmc_mutex); 759 mutex_unlock(&mmc_mutex);
758 760
759 /* only flush if writing went ok */ 761 /* only flush if writing went ok */
@@ -842,12 +844,26 @@ bool mmc_detect(void)
842 return adc_read(ADC_MMC_SWITCH) < 0x200 ? true : false; 844 return adc_read(ADC_MMC_SWITCH) < 0x200 ? true : false;
843} 845}
844 846
847bool mmc_usb_active(int delayticks)
848{
849 /* reading "inactive" is delayed by user-supplied monoflop value */
850 return (usb_activity ||
851 TIME_BEFORE(current_tick, last_activity+delayticks));
852}
853
845static void mmc_tick(void) 854static void mmc_tick(void)
846{ 855{
847 bool current_status; 856 bool current_status;
848 857
858 /* USB bridge activity is 0 on idle, ~527 on active */
859 current_status = adc_read(ADC_USB_ACTIVE) > 0x100;
860 if (!current_status && usb_activity)
861 {
862 last_activity = current_tick;
863 }
864 usb_activity = current_status;
865
849 current_status = mmc_detect(); 866 current_status = mmc_detect();
850
851 /* Only report when the status has changed */ 867 /* Only report when the status has changed */
852 if (current_status != last_mmc_status) 868 if (current_status != last_mmc_status)
853 { 869 {
diff --git a/firmware/export/adc.h b/firmware/export/adc.h
index b1d78eac8f..a18cb1995a 100644
--- a/firmware/export/adc.h
+++ b/firmware/export/adc.h
@@ -40,6 +40,7 @@
40#define ADC_BUTTON_ONOFF 3 /* the on/off button, high value if pressed */ 40#define ADC_BUTTON_ONOFF 3 /* the on/off button, high value if pressed */
41#define ADC_BUTTON_ROW1 4 /* Used for scanning the keys, different 41#define ADC_BUTTON_ROW1 4 /* Used for scanning the keys, different
42 voltages for different keys */ 42 voltages for different keys */
43#define ADC_USB_ACTIVE 5 /* USB bridge activity */
43#define ADC_UNREG_POWER 7 /* Battery voltage */ 44#define ADC_UNREG_POWER 7 /* Battery voltage */
44 45
45#else 46#else
diff --git a/firmware/export/ata_mmc.h b/firmware/export/ata_mmc.h
index 957849925b..6c5141dd05 100644
--- a/firmware/export/ata_mmc.h
+++ b/firmware/export/ata_mmc.h
@@ -41,5 +41,6 @@ bool mmc_detect(void);
41unsigned long mmc_extract_bits(const unsigned long *p, unsigned int start, 41unsigned long mmc_extract_bits(const unsigned long *p, unsigned int start,
42 unsigned int size); 42 unsigned int size);
43tCardInfo *mmc_card_info(int card_no); 43tCardInfo *mmc_card_info(int card_no);
44bool mmc_usb_active(int delayticks);
44 45
45#endif 46#endif