usbctl

Name

usbctl -- USB "Control" module

Synopsis



#define     USB_PKT_HDRLEN
#define     USB_VENDOR_ID
#define     USB_PRODUCT_ID
#define     USB_DEVICE_ID
#define     USB_MAX_PORTS
#define     USB_ENDPOINT_MAIN
#define     USB_ENDPOINT_ALTERNATE
#define     USB_PJB_PROTOCOL_PORT
#define     USB_PJB_DEBUG_PORT
#define     USB_PJB_PROTOCOL_ENDPOINT
#define     USB_PJB_DEBUG_ENDPOINT
int         usb_init                        (u8 *pool,
                                             int poolmemsize);
void        usb_uninit                      (void);
int         usb_linktest                    ();
int         usb_open                        (int protocol,
                                             int endpoint,
                                             int (*func) (EBUF *));
int         usb_close                       (int port);
EBUF*       usb_allocbuf                    (int port);
void        usb_freebuf                     (EBUF *buf);
int         usb_transmit                    (int port,
                                             PJBCOMMHANDLE *h,
                                             EBUF *buf);
void        usb_initbuf                     (EBUF *buf);
EBUF*       usb_receive                     (int port,
                                             PJBCOMMHANDLE *h,
                                             int timeout);

Description

This module provides a "multiplex" interface for the USB protocol used in the Personal Jukebox. At present, we only one type of packet through this interface, but should we add more types in the future (perhaps for different services) then this would be the place to do it.

Details

USB_PKT_HDRLEN

#define USB_PKT_HDRLEN	10		/* 10 bytes of header info */


USB_VENDOR_ID

#define USB_VENDOR_ID  	1183		/* "COMPAQ" */


USB_PRODUCT_ID

#define USB_PRODUCT_ID  0x504A          /* "Personal Jukebox" */


USB_DEVICE_ID

#define USB_DEVICE_ID 	0x100


USB_MAX_PORTS

#define USB_MAX_PORTS		2


USB_ENDPOINT_MAIN

#define USB_ENDPOINT_MAIN	0	/* for usb_open() */


USB_ENDPOINT_ALTERNATE

#define USB_ENDPOINT_ALTERNATE	1


USB_PJB_PROTOCOL_PORT

#define USB_PJB_PROTOCOL_PORT	0	/* for PJB protocol data */


USB_PJB_DEBUG_PORT

#define USB_PJB_DEBUG_PORT	1	/* for PJBTERM data */


USB_PJB_PROTOCOL_ENDPOINT

#define USB_PJB_PROTOCOL_ENDPOINT USB_ENDPOINT_MAIN


USB_PJB_DEBUG_ENDPOINT

#define USB_PJB_DEBUG_ENDPOINT	USB_ENDPOINT_ALTERNATE


usb_init ()

int         usb_init                        (u8 *pool,
                                             int poolmemsize);

Initialize the USB interface.

pool : address of buffer pool
poolmemsize : size of buffer pool, in bytes (not packed)
Returns : 0 if ok, else error code


usb_uninit ()

void        usb_uninit                      (void);

Undo the effect of usb_init()


usb_linktest ()

int         usb_linktest                    ();

Returns : 


usb_open ()

int         usb_open                        (int protocol,
                                             int endpoint,
                                             int (*func) (EBUF *));

Open a USB protocol

protocol : USB protocol ID (in packet header)
endpoint : USB endpoint ID (0=main, 1=alternate
func : function to call on tx/rx events
Returns : port # (same as protocol #)


usb_close ()

int         usb_close                       (int port);

Close a port

port : endpoin number to close
Returns : 0


usb_allocbuf ()

EBUF*       usb_allocbuf                    (int port);

Allocate a buffer for this port and reserve space in the buffer for any overhead that we plan on applying

port : port we want to request a buffer for
Returns : EBUF pointer or NULL if none left


usb_freebuf ()

void        usb_freebuf                     (EBUF *buf);

Free a buffer.

buf : buffer to free


usb_transmit ()

int         usb_transmit                    (int port,
                                             PJBCOMMHANDLE *h,
                                             EBUF *buf);

Transmit a usb packet

port : port to transmit buffer on
h : USB handle
buf : buffer (EBUF) to send
Returns : 0 if ok, else error


usb_initbuf ()

void        usb_initbuf                     (EBUF *buf);

Reinitialize an ebuf so we can start adding data to it.

buf : ebuf to hack on


usb_receive ()

EBUF*       usb_receive                     (int port,
                                             PJBCOMMHANDLE *h,
                                             int timeout);

Use the blocking receive call to wait for the next packet to arrive on the USB.

port : port to recieve buffer on
h : USB handle
timeout : milliseconds to wait, 0 to wait forever
Returns : ebuf pointer of packet received, or NULL if timeout occured