summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2003-02-14 09:44:34 +0000
committerBjörn Stenberg <bjorn@haxx.se>2003-02-14 09:44:34 +0000
commitc4d8d970f6602c80d7362a41da8851dbbf59ae1b (patch)
tree7e8f936eae5c1854c006c4fe134c4c2ce6f91291 /firmware/drivers
parent84706a4188cea193a5a095855c1068b1c31a3875 (diff)
The power-saving SLEEP patch by Simon Elén.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3259 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/ata.c6
-rw-r--r--firmware/drivers/button.c15
-rw-r--r--firmware/drivers/i2c.c7
3 files changed, 11 insertions, 17 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 79193d9800..e65200eea2 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -111,7 +111,8 @@ static int wait_for_bsy(void)
{
int timeout = current_tick + HZ*10;
while (TIME_BEFORE(current_tick, timeout) && (ATA_ALT_STATUS & STATUS_BSY))
- yield();
+ sleep_thread();
+ wake_up_thread();
if (TIME_BEFORE(current_tick, timeout))
return 1;
@@ -131,7 +132,8 @@ static int wait_for_rdy(void)
while (TIME_BEFORE(current_tick, timeout) &&
!(ATA_ALT_STATUS & STATUS_RDY))
- yield();
+ sleep_thread();
+ wake_up_thread();
if (TIME_BEFORE(current_tick, timeout))
return STATUS_RDY;
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 2c33440fef..69d041f65e 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -163,19 +163,8 @@ int button_get(bool block)
int button_get_w_tmo(int ticks)
{
struct event ev;
- unsigned int timeout = current_tick + ticks;
-
- while (TIME_BEFORE( current_tick, timeout ))
- {
- if(!queue_empty(&button_queue))
- {
- queue_wait(&button_queue, &ev);
- return ev.id;
- }
- yield();
- }
-
- return BUTTON_NONE;
+ queue_wait_w_tmo(&button_queue, &ev, ticks);
+ return (ev.id != SYS_TIMEOUT)? ev.id: BUTTON_NONE;
}
#ifdef HAVE_RECORDER_KEYPAD
diff --git a/firmware/drivers/i2c.c b/firmware/drivers/i2c.c
index 97d7a511e1..f0b5907be8 100644
--- a/firmware/drivers/i2c.c
+++ b/firmware/drivers/i2c.c
@@ -19,6 +19,7 @@
#include "lcd.h"
#include "sh7034.h"
#include "kernel.h"
+#include "thread.h"
#include "debug.h"
#define PB13 0x2000
@@ -108,7 +109,8 @@ void i2c_ack(int bit)
SCL_INPUT; /* Set the clock to input */
while(!SCL) /* and wait for the MAS to release it */
- yield();
+ sleep_thread();
+ wake_up_thread();
DELAY;
SCL_OUTPUT;
@@ -130,7 +132,8 @@ int i2c_getack(void)
SDA_INPUT; /* And set to input */
SCL_INPUT; /* Set the clock to input */
while(!SCL) /* and wait for the MAS to release it */
- yield();
+ sleep_thread();
+ wake_up_thread();
if (SDA)
/* ack failed */