forked from len0rd/rockbox
Ondio: disk activity indication in USB mode, too
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6020 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
2e429ff762
commit
7e1d36f35b
4 changed files with 24 additions and 3 deletions
|
@ -111,6 +111,9 @@ void usb_screen(void)
|
||||||
usb_display_info();
|
usb_display_info();
|
||||||
while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) {
|
while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) {
|
||||||
if(usb_inserted()) {
|
if(usb_inserted()) {
|
||||||
|
#ifdef HAVE_MMC /* USB-MMC bridge can report activity */
|
||||||
|
led(mmc_usb_active(HZ));
|
||||||
|
#endif
|
||||||
status_draw(false);
|
status_draw(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,6 +121,8 @@ static int current_card = 0;
|
||||||
#endif
|
#endif
|
||||||
static bool last_mmc_status = false;
|
static bool last_mmc_status = false;
|
||||||
static int countdown; /* for mmc switch debouncing */
|
static int countdown; /* for mmc switch debouncing */
|
||||||
|
static bool usb_activity; /* monitoring the USB bridge */
|
||||||
|
static long last_activity;
|
||||||
|
|
||||||
/* private function declarations */
|
/* private function declarations */
|
||||||
|
|
||||||
|
@ -708,7 +710,7 @@ int ata_write_sectors(IF_MV2(int drive,)
|
||||||
addr = start * SECTOR_SIZE;
|
addr = start * SECTOR_SIZE;
|
||||||
|
|
||||||
mutex_lock(&mmc_mutex);
|
mutex_lock(&mmc_mutex);
|
||||||
led(true);
|
led(true);
|
||||||
#ifdef HAVE_MULTIVOLUME
|
#ifdef HAVE_MULTIVOLUME
|
||||||
card = &card_info[drive];
|
card = &card_info[drive];
|
||||||
ret = select_card(drive);
|
ret = select_card(drive);
|
||||||
|
@ -753,7 +755,7 @@ int ata_write_sectors(IF_MV2(int drive,)
|
||||||
}
|
}
|
||||||
|
|
||||||
deselect_card();
|
deselect_card();
|
||||||
led(false);
|
led(false);
|
||||||
mutex_unlock(&mmc_mutex);
|
mutex_unlock(&mmc_mutex);
|
||||||
|
|
||||||
/* only flush if writing went ok */
|
/* only flush if writing went ok */
|
||||||
|
@ -842,12 +844,26 @@ bool mmc_detect(void)
|
||||||
return adc_read(ADC_MMC_SWITCH) < 0x200 ? true : false;
|
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)
|
static void mmc_tick(void)
|
||||||
{
|
{
|
||||||
bool current_status;
|
bool current_status;
|
||||||
|
|
||||||
current_status = mmc_detect();
|
/* 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 */
|
/* Only report when the status has changed */
|
||||||
if (current_status != last_mmc_status)
|
if (current_status != last_mmc_status)
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#define ADC_BUTTON_ONOFF 3 /* the on/off button, high value if pressed */
|
#define ADC_BUTTON_ONOFF 3 /* the on/off button, high value if pressed */
|
||||||
#define ADC_BUTTON_ROW1 4 /* Used for scanning the keys, different
|
#define ADC_BUTTON_ROW1 4 /* Used for scanning the keys, different
|
||||||
voltages for different keys */
|
voltages for different keys */
|
||||||
|
#define ADC_USB_ACTIVE 5 /* USB bridge activity */
|
||||||
#define ADC_UNREG_POWER 7 /* Battery voltage */
|
#define ADC_UNREG_POWER 7 /* Battery voltage */
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -41,5 +41,6 @@ bool mmc_detect(void);
|
||||||
unsigned long mmc_extract_bits(const unsigned long *p, unsigned int start,
|
unsigned long mmc_extract_bits(const unsigned long *p, unsigned int start,
|
||||||
unsigned int size);
|
unsigned int size);
|
||||||
tCardInfo *mmc_card_info(int card_no);
|
tCardInfo *mmc_card_info(int card_no);
|
||||||
|
bool mmc_usb_active(int delayticks);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue