summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorTomasz Malesinski <tomal@rockbox.org>2006-02-03 23:28:53 +0000
committerTomasz Malesinski <tomal@rockbox.org>2006-02-03 23:28:53 +0000
commitc4d24a07abe2e6adce3cb4ba28d6e60438db89a2 (patch)
tree351bf0dec49704f198fdb162fcc95cfabde79010 /firmware
parent507120c1b397320cb69eb028318c698b00397a3f (diff)
Added non-blocking get/put_byte routines.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8556 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/usb_serial.h2
-rw-r--r--firmware/usb_serial.c23
2 files changed, 25 insertions, 0 deletions
diff --git a/firmware/export/usb_serial.h b/firmware/export/usb_serial.h
index 5daefeeff2..32bb8525b4 100644
--- a/firmware/export/usb_serial.h
+++ b/firmware/export/usb_serial.h
@@ -22,5 +22,7 @@
void usb_serial_init(void);
void usb_serial_put_byte(int b);
int usb_serial_get_byte(void);
+int usb_serial_try_put_byte(int b);
+int usb_serial_try_get_byte(void);
#endif
diff --git a/firmware/usb_serial.c b/firmware/usb_serial.c
index acf19e3b1a..0c4fb9d896 100644
--- a/firmware/usb_serial.c
+++ b/firmware/usb_serial.c
@@ -1081,6 +1081,17 @@ int usb_serial_get_byte(void)
return fifo_get_byte(&serial_in_fifo);
}
+int usb_serial_try_get_byte(void)
+{
+ int r;
+ if (fifo_empty(&serial_in_fifo))
+ r = -1;
+ else
+ r = fifo_get_byte(&serial_in_fifo);
+ usb_serial_handle();
+ return r;
+}
+
/*
Not used:
static int usb_serial_out_full(void)
@@ -1097,6 +1108,18 @@ void usb_serial_put_byte(int b)
usb_serial_handle();
}
+int usb_serial_try_put_byte(int b)
+{
+ int r = -1;
+ if (!fifo_full(&serial_out_fifo))
+ {
+ fifo_put_byte(&serial_out_fifo, b);
+ r = 0;
+ }
+ usb_serial_handle();
+ return r;
+}
+
void usb_serial_init(void)
{
fifo_init(&serial_in_fifo);