summaryrefslogtreecommitdiffstats
path: root/bootloader
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2007-09-04 08:03:07 +0000
committerDave Chapman <dave@dchapman.com>2007-09-04 08:03:07 +0000
commit1672350378c1eb218db319e35e7bf8fa457b1142 (patch)
treeccffc78a046ce73aa8f49784d5b2a2d26a2bc4d6 /bootloader
parent946a815cd4166f8761fac0c9cba0092b871cf900 (diff)
downloadrockbox-1672350378c1eb218db319e35e7bf8fa457b1142.tar.gz
rockbox-1672350378c1eb218db319e35e7bf8fa457b1142.zip
FS #7691 - improved USB detection on PP devices. This patch modifies the target-tree function usb_detect() on all targets from bool to int, returning USB_INSERTED or USB_EXTRACTED instead of true or false. This was done to enable the PP usb_detect() to check for USB_POWER (either a connection to a USB wall charger, or the user holding "charge mode" button) and return that as a third value.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14600 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'bootloader')
-rw-r--r--bootloader/gigabeat.c4
-rw-r--r--bootloader/iriver_h300.c11
-rw-r--r--bootloader/main-pp.c2
-rw-r--r--bootloader/main.c10
4 files changed, 14 insertions, 13 deletions
diff --git a/bootloader/gigabeat.c b/bootloader/gigabeat.c
index e482c70d16..704548b65a 100644
--- a/bootloader/gigabeat.c
+++ b/bootloader/gigabeat.c
@@ -66,7 +66,7 @@ void main(void)
usb_init();
/* Enter USB mode without USB thread */
- if(usb_detect())
+ if(usb_detect() == USB_INSERTED)
{
const char msg[] = "Bootloader USB mode";
reset_screen();
@@ -78,7 +78,7 @@ void main(void)
sleep(HZ/20);
usb_enable(true);
- while (usb_detect())
+ while (usb_detect() == USB_INSERTED)
sleep(HZ);
usb_enable(false);
diff --git a/bootloader/iriver_h300.c b/bootloader/iriver_h300.c
index dce178fcec..a3a15bd4b5 100644
--- a/bootloader/iriver_h300.c
+++ b/bootloader/iriver_h300.c
@@ -169,7 +169,7 @@ void main(void)
/* Turn off if we believe the start was accidental */
if(!(rtc_alarm || on_button || rc_on_button ||
- usb_detect() || charger_inserted())) {
+ (usb_detect() == USB_INSERTED) || charger_inserted())) {
__reset_cookie();
power_off();
}
@@ -222,7 +222,8 @@ void main(void)
{
hold_status = true;
}
- if (hold_status && !rtc_alarm && !usb_detect() && !charger_inserted())
+ if (hold_status && !rtc_alarm && (usb_detect() != USB_INSERTED) &&
+ !charger_inserted())
{
if (detect_original_firmware())
{
@@ -282,7 +283,7 @@ void main(void)
break;
}
- if(usb_detect())
+ if(usb_detect() == USB_INSERTED)
request_start = true;
}
if(!request_start)
@@ -297,7 +298,7 @@ void main(void)
usb_init();
/* A hack to enter USB mode without using the USB thread */
- if(usb_detect())
+ if(usb_detect() == USB_INSERTED)
{
const char msg[] = "Bootloader USB mode";
int w, h;
@@ -314,7 +315,7 @@ void main(void)
sleep(HZ/20);
usb_enable(true);
cpu_idle_mode(true);
- while (usb_detect())
+ while (usb_detect() == USB_INSERTED)
{
/* Print the battery status. */
line = 0;
diff --git a/bootloader/main-pp.c b/bootloader/main-pp.c
index 0d377fd798..8b851394ac 100644
--- a/bootloader/main-pp.c
+++ b/bootloader/main-pp.c
@@ -464,7 +464,7 @@ void* main(void)
{
usb_retry++;
sleep(HZ/4);
- usb = usb_detect();
+ usb = (usb_detect() == USB_INSERTED);
}
if (usb)
btn |= BOOTLOADER_BOOT_OF;
diff --git a/bootloader/main.c b/bootloader/main.c
index 0306eea5dc..e60799fa65 100644
--- a/bootloader/main.c
+++ b/bootloader/main.c
@@ -388,7 +388,7 @@ void main(void)
power_init();
/* Turn off if neither ON button is pressed */
- if(!(on_button || rc_on_button || usb_detect()))
+ if(!(on_button || rc_on_button || (usb_detect() == USB_INSERTED)))
{
__reset_cookie();
power_off();
@@ -439,7 +439,7 @@ void main(void)
}
# ifdef EEPROM_SETTINGS
- if (!hold_status && !usb_detect() && !recovery_mode)
+ if (!hold_status && (usb_detect() != USB_INSERTED) && !recovery_mode)
try_flashboot();
# endif
@@ -467,7 +467,7 @@ void main(void)
/* Don't start if the Hold button is active on the device you
are starting with */
- if (!usb_detect() && (hold_status
+ if ((usb_detect() != USB_INSERTED) && (hold_status
#ifdef HAVE_EEPROM_SETTINGS
|| recovery_mode
#endif
@@ -494,7 +494,7 @@ void main(void)
usb_init();
/* A hack to enter USB mode without using the USB thread */
- if(usb_detect())
+ if(usb_detect() == USB_INSERTED)
{
const char msg[] = "Bootloader USB mode";
int w, h;
@@ -520,7 +520,7 @@ void main(void)
sleep(HZ/20);
usb_enable(true);
cpu_idle_mode(true);
- while (usb_detect())
+ while (usb_detect() == USB_INSERTED)
{
/* Print the battery status. */
line = 0;