summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
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)
111{ 111{
112 int timeout = current_tick + HZ*10; 112 int timeout = current_tick + HZ*10;
113 while (TIME_BEFORE(current_tick, timeout) && (ATA_ALT_STATUS & STATUS_BSY)) 113 while (TIME_BEFORE(current_tick, timeout) && (ATA_ALT_STATUS & STATUS_BSY))
114 yield(); 114 sleep_thread();
115 wake_up_thread();
115 116
116 if (TIME_BEFORE(current_tick, timeout)) 117 if (TIME_BEFORE(current_tick, timeout))
117 return 1; 118 return 1;
@@ -131,7 +132,8 @@ static int wait_for_rdy(void)
131 132
132 while (TIME_BEFORE(current_tick, timeout) && 133 while (TIME_BEFORE(current_tick, timeout) &&
133 !(ATA_ALT_STATUS & STATUS_RDY)) 134 !(ATA_ALT_STATUS & STATUS_RDY))
134 yield(); 135 sleep_thread();
136 wake_up_thread();
135 137
136 if (TIME_BEFORE(current_tick, timeout)) 138 if (TIME_BEFORE(current_tick, timeout))
137 return STATUS_RDY; 139 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)
163int button_get_w_tmo(int ticks) 163int button_get_w_tmo(int ticks)
164{ 164{
165 struct event ev; 165 struct event ev;
166 unsigned int timeout = current_tick + ticks; 166 queue_wait_w_tmo(&button_queue, &ev, ticks);
167 167 return (ev.id != SYS_TIMEOUT)? ev.id: BUTTON_NONE;
168 while (TIME_BEFORE( current_tick, timeout ))
169 {
170 if(!queue_empty(&button_queue))
171 {
172 queue_wait(&button_queue, &ev);
173 return ev.id;
174 }
175 yield();
176 }
177
178 return BUTTON_NONE;
179} 168}
180 169
181#ifdef HAVE_RECORDER_KEYPAD 170#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 @@
19#include "lcd.h" 19#include "lcd.h"
20#include "sh7034.h" 20#include "sh7034.h"
21#include "kernel.h" 21#include "kernel.h"
22#include "thread.h"
22#include "debug.h" 23#include "debug.h"
23 24
24#define PB13 0x2000 25#define PB13 0x2000
@@ -108,7 +109,8 @@ void i2c_ack(int bit)
108 109
109 SCL_INPUT; /* Set the clock to input */ 110 SCL_INPUT; /* Set the clock to input */
110 while(!SCL) /* and wait for the MAS to release it */ 111 while(!SCL) /* and wait for the MAS to release it */
111 yield(); 112 sleep_thread();
113 wake_up_thread();
112 114
113 DELAY; 115 DELAY;
114 SCL_OUTPUT; 116 SCL_OUTPUT;
@@ -130,7 +132,8 @@ int i2c_getack(void)
130 SDA_INPUT; /* And set to input */ 132 SDA_INPUT; /* And set to input */
131 SCL_INPUT; /* Set the clock to input */ 133 SCL_INPUT; /* Set the clock to input */
132 while(!SCL) /* and wait for the MAS to release it */ 134 while(!SCL) /* and wait for the MAS to release it */
133 yield(); 135 sleep_thread();
136 wake_up_thread();
134 137
135 if (SDA) 138 if (SDA)
136 /* ack failed */ 139 /* ack failed */