summaryrefslogtreecommitdiff
path: root/ps2.c
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2011-02-21 15:43:17 +0900
committertmk <nobody@nowhere>2011-02-22 03:09:14 +0900
commitfb8d23c60c757d5d9c2270cb0123a53be2049a28 (patch)
tree2f5d695f9d501468dc83f4861e7367cdf905ed3f /ps2.c
parent47f5d8b545eec12ca74d8e7048bb5daa290d937e (diff)
integrate V-USB support into ps2_usb
Diffstat (limited to 'ps2.c')
-rw-r--r--ps2.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ps2.c b/ps2.c
index 52ee1691fb..99749cf6ba 100644
--- a/ps2.c
+++ b/ps2.c
@@ -187,6 +187,9 @@ static inline void pbuf_enqueue(uint8_t data)
{
if (!data)
return;
+
+ uint8_t sreg = SREG;
+ cli();
uint8_t next = (pbuf_head + 1) % PBUF_SIZE;
if (next != pbuf_tail) {
pbuf[pbuf_head] = data;
@@ -194,10 +197,12 @@ static inline void pbuf_enqueue(uint8_t data)
} else {
debug("pbuf: full\n");
}
+ SREG = sreg;
}
static inline uint8_t pbuf_dequeue(void)
{
uint8_t val = 0;
+
uint8_t sreg = SREG;
cli();
if (pbuf_head != pbuf_tail) {
@@ -205,17 +210,20 @@ static inline uint8_t pbuf_dequeue(void)
pbuf_tail = (pbuf_tail + 1) % PBUF_SIZE;
}
SREG = sreg;
+
return val;
}
/* get data received by interrupt */
uint8_t ps2_host_recv(void)
{
- // TODO: release clock line after 100us when inhibited by error
if (ps2_error) {
+ print("x");
+ phex(ps2_error);
ps2_host_send(0xFE); // request to resend
ps2_error = PS2_ERR_NONE;
}
+ idle();
return pbuf_dequeue();
}
@@ -281,7 +289,7 @@ ISR(PS2_INT_VECT)
}
goto RETURN;
ERROR:
- DEBUGP(0xFF);
+ DEBUGP(0x0F);
inhibit();
ps2_error = state;
DONE: