1
0
Fork 0
forked from len0rd/rockbox

Added USB insertion handling

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1259 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Linus Nielsen Feltzing 2002-06-29 23:01:10 +00:00
parent 43eda43c20
commit 392f3853b1
2 changed files with 37 additions and 7 deletions

View file

@ -24,6 +24,7 @@
#include "i2c.h" #include "i2c.h"
#include "debug.h" #include "debug.h"
#include "rtc.h" #include "rtc.h"
#include "usb.h"
#define BACKLIGHT_ON 1 #define BACKLIGHT_ON 1
#define BACKLIGHT_OFF 2 #define BACKLIGHT_OFF 2
@ -55,6 +56,7 @@ void backlight_thread(void)
#endif #endif
} }
break; break;
case BACKLIGHT_OFF: case BACKLIGHT_OFF:
#ifdef HAVE_RTC #ifdef HAVE_RTC
rtc_write(0x13, 0x00); rtc_write(0x13, 0x00);
@ -62,6 +64,16 @@ void backlight_thread(void)
PADR &= ~0x40; PADR &= ~0x40;
#endif #endif
break; break;
case SYS_USB_CONNECTED:
/* Tell the USB thread that we are safe */
DEBUGF("backlight_thread got SYS_USB_CONNECTED\n");
usb_acknowledge(SYS_USB_CONNECTED_ACK);
/* Wait until the system reboots */
while(1)
yield();
break;
} }
} }
} }

View file

@ -25,6 +25,7 @@
#include "debug.h" #include "debug.h"
#include "kernel.h" #include "kernel.h"
#include "thread.h" #include "thread.h"
#include "usb.h"
#include "panic.h" #include "panic.h"
#include "file.h" #include "file.h"
#include "mpeg.h" #include "mpeg.h"
@ -471,6 +472,17 @@ struct mp3entry* mpeg_current_track(void)
return &(id3tags[0].id3); return &(id3tags[0].id3);
} }
static void stop_playing(void)
{
/* Stop the current stream */
playing = false;
filling = false;
if(mpeg_file >= 0)
close(mpeg_file);
mpeg_file = -1;
stop_dma();
}
static void mpeg_thread(void) static void mpeg_thread(void)
{ {
struct event ev; struct event ev;
@ -526,13 +538,7 @@ static void mpeg_thread(void)
case MPEG_STOP: case MPEG_STOP:
DEBUGF("MPEG_STOP\n"); DEBUGF("MPEG_STOP\n");
/* Stop the current stream */ stop_playing();
playing = false;
filling = false;
if(mpeg_file >= 0)
close(mpeg_file);
mpeg_file = -1;
stop_dma();
break; break;
case MPEG_PAUSE: case MPEG_PAUSE:
@ -683,6 +689,18 @@ static void mpeg_thread(void)
yield(); /* To be safe */ yield(); /* To be safe */
} }
break; break;
case SYS_USB_CONNECTED:
stop_playing();
/* Tell the USB thread that we are safe */
DEBUGF("mpeg_thread got SYS_USB_CONNECTED\n");
usb_acknowledge(SYS_USB_CONNECTED_ACK);
/* Wait until the system reboots */
while(1)
yield();
break;
} }
} }
} }