summaryrefslogtreecommitdiffstats
path: root/firmware/usbstack/usb_serial.c
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2008-04-26 19:02:16 +0000
committerFrank Gevaerts <frank@gevaerts.be>2008-04-26 19:02:16 +0000
commitbec6aa3176fc6d5ce80bcd4d6022358aa6c01629 (patch)
treedfbaa924ba3e13d6f73dc446b1a2149610ed3e67 /firmware/usbstack/usb_serial.c
parent33c44461e1b5fb9aff2f8ba7470ad2449b3c410e (diff)
downloadrockbox-bec6aa3176fc6d5ce80bcd4d6022358aa6c01629.tar.gz
rockbox-bec6aa3176fc6d5ce80bcd4d6022358aa6c01629.tar.bz2
rockbox-bec6aa3176fc6d5ce80bcd4d6022358aa6c01629.zip
- change the usb class driver framework to allow for device classes with more than one interface or more than one endpoint pair
- move the charging-only dummy driver out of usb_core git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17252 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/usbstack/usb_serial.c')
-rw-r--r--firmware/usbstack/usb_serial.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/firmware/usbstack/usb_serial.c b/firmware/usbstack/usb_serial.c
index 08eb1213ea..197ef47cb7 100644
--- a/firmware/usbstack/usb_serial.c
+++ b/firmware/usbstack/usb_serial.c
@@ -28,7 +28,7 @@
#ifdef USB_SERIAL
/* serial interface */
-struct usb_interface_descriptor __attribute__((aligned(2)))
+static struct usb_interface_descriptor __attribute__((aligned(2)))
interface_descriptor =
{
.bLength = sizeof(struct usb_interface_descriptor),
@@ -42,7 +42,8 @@ struct usb_interface_descriptor __attribute__((aligned(2)))
.iInterface = 0
};
-struct usb_endpoint_descriptor __attribute__((aligned(2))) endpoint_descriptor =
+
+static struct usb_endpoint_descriptor __attribute__((aligned(2))) endpoint_descriptor =
{
.bLength = sizeof(struct usb_endpoint_descriptor),
.bDescriptorType = USB_DT_ENDPOINT,
@@ -90,31 +91,42 @@ static void sendout(void)
busy_sending=true;
}
-int usb_serial_get_config_descriptor(unsigned char *dest,int max_packet_size,
- int interface_number,int endpoint)
+int usb_serial_set_first_endpoint(int endpoint)
{
- endpoint_descriptor.wMaxPacketSize=max_packet_size;
- interface_descriptor.bInterfaceNumber=interface_number;
+ usb_endpoint = endpoint;
+ return endpoint + 1;
+}
+int usb_serial_set_first_interface(int interface)
+{
+ usb_interface = interface;
+ return interface + 1;
+}
+
+
+int usb_serial_get_config_descriptor(unsigned char *dest,int max_packet_size)
+{
+ unsigned char *orig_dest = dest;
+
+ endpoint_descriptor.wMaxPacketSize=max_packet_size;
+ interface_descriptor.bInterfaceNumber=usb_interface;
memcpy(dest,&interface_descriptor,sizeof(struct usb_interface_descriptor));
dest+=sizeof(struct usb_interface_descriptor);
- endpoint_descriptor.bEndpointAddress = endpoint | USB_DIR_IN,
+ endpoint_descriptor.bEndpointAddress = usb_endpoint | USB_DIR_IN,
memcpy(dest,&endpoint_descriptor,sizeof(struct usb_endpoint_descriptor));
dest+=sizeof(struct usb_endpoint_descriptor);
- endpoint_descriptor.bEndpointAddress = endpoint | USB_DIR_OUT,
+ endpoint_descriptor.bEndpointAddress = usb_endpoint | USB_DIR_OUT,
memcpy(dest,&endpoint_descriptor,sizeof(struct usb_endpoint_descriptor));
- return sizeof(struct usb_interface_descriptor) +
- 2 * sizeof(struct usb_endpoint_descriptor);
+ dest+=sizeof(struct usb_endpoint_descriptor);
+
+ return (dest - orig_dest);
}
-void usb_serial_init_connection(int interface,int endpoint)
+void usb_serial_init_connection(void)
{
- usb_interface = interface;
- usb_endpoint = endpoint;
-
/* prime rx endpoint */
usb_drv_recv(usb_endpoint, receive_buffer, sizeof receive_buffer);
@@ -187,8 +199,9 @@ void usb_serial_send(unsigned char *data,int length)
}
/* called by usb_core_transfer_complete() */
-void usb_serial_transfer_complete(bool in, int status, int length)
+void usb_serial_transfer_complete(int ep,bool in, int status, int length)
{
+ (void)ep;
switch (in) {
case false:
logf("serial: %s", receive_buffer);