summaryrefslogtreecommitdiffstats
path: root/firmware/usbstack/usb_serial.c
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2008-02-20 22:54:26 +0000
committerFrank Gevaerts <frank@gevaerts.be>2008-02-20 22:54:26 +0000
commit07427592a928ab3d164fbcca842399af6d5ca7ef (patch)
treeeb7b1b748f8ac9ea28ce357290bc5992f5e2403f /firmware/usbstack/usb_serial.c
parent6af732d17aa1eb882e3c52242b2bf7f2fcccc752 (diff)
downloadrockbox-07427592a928ab3d164fbcca842399af6d5ca7ef.tar.gz
rockbox-07427592a928ab3d164fbcca842399af6d5ca7ef.tar.bz2
rockbox-07427592a928ab3d164fbcca842399af6d5ca7ef.zip
Major USB stack improvements. It now works at nearly the maximum speed for a full speed connection, and does seem stable.
Still not enabled by default, #define USE_ROCKBOX_USB is still required to enable it. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16360 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/usbstack/usb_serial.c')
-rw-r--r--firmware/usbstack/usb_serial.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/firmware/usbstack/usb_serial.c b/firmware/usbstack/usb_serial.c
index 5513c56910..77878092d7 100644
--- a/firmware/usbstack/usb_serial.c
+++ b/firmware/usbstack/usb_serial.c
@@ -23,6 +23,8 @@
//#define LOGF_ENABLE
#include "logf.h"
+#ifdef USB_SERIAL
+
static unsigned char _transfer_buffer[16];
static unsigned char* transfer_buffer;
@@ -34,20 +36,26 @@ void usb_serial_init(void)
}
/* called by usb_core_transfer_complete() */
-void usb_serial_transfer_complete(int endpoint)
+void usb_serial_transfer_complete(bool in, int status, int length)
{
- switch (endpoint) {
- case EP_RX:
+ int i;
+ switch (in) {
+ case false:
logf("serial: %s", transfer_buffer);
-
- /* re-prime endpoint */
- usb_drv_recv(EP_RX, transfer_buffer, sizeof _transfer_buffer);
-
- /* echo back :) */
- usb_drv_send(EP_TX, transfer_buffer, sizeof transfer_buffer);
+ /* Data received. Send it back */
+ for(i=0;i<length;i++) {
+ if(transfer_buffer[i]>0x40 && transfer_buffer[i]<0x5b)
+ transfer_buffer[i]+=0x20;
+ else if(transfer_buffer[i]>0x60 && transfer_buffer[i]<0x7b)
+ transfer_buffer[i]-=0x20;
+ }
+ usb_drv_send_nonblocking(EP_SERIAL, transfer_buffer, length);
break;
- case EP_TX:
+ case true:
+ /* Data sent out (maybe correctly, but we don't actually care.
+ * Re-prime read endpoint */
+ usb_drv_recv(EP_SERIAL, transfer_buffer, sizeof _transfer_buffer);
break;
}
}
@@ -55,14 +63,12 @@ void usb_serial_transfer_complete(int endpoint)
/* called by usb_core_control_request() */
bool usb_serial_control_request(struct usb_ctrlrequest* req)
{
- /* note: interrupt context */
-
bool handled = false;
switch (req->bRequest) {
case USB_REQ_SET_CONFIGURATION:
logf("serial: set config");
/* prime rx endpoint */
- usb_drv_recv(EP_RX, transfer_buffer, sizeof _transfer_buffer);
+ usb_drv_recv(EP_SERIAL, transfer_buffer, sizeof _transfer_buffer);
handled = true;
break;
@@ -72,3 +78,5 @@ bool usb_serial_control_request(struct usb_ctrlrequest* req)
return handled;
}
+
+#endif /*USB_SERIAL*/