diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/ata.c | 6 | ||||
-rw-r--r-- | firmware/drivers/button.c | 15 | ||||
-rw-r--r-- | firmware/drivers/i2c.c | 7 |
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 */ |