/*
 *              Copyright (C) 2005, BroadOn Communications Corp.
 *
 * These coded instructions, statements, and computer programs contain
 * unpublished  proprietary information of BroadOn Communications Corp.,
 * and  are protected by Federal copyright law. They may not be disclosed
 * to  third  parties or copied or duplicated in any form, in whole or in
 * part, without the prior written consent of BroadOn Communications Corp.
 *
 */

#ifndef __USB_CH9_ENUM_
#define __USB_CH9_ENUM_

#define USB_VER                    0x0110
#define EP0_PKT_SIZE               8
#define U16_LOW_BYTE(x)            ((x) & 0xff)
#define U16_HIGH_BYTE(x)           (((x) >> 8) & 0xff) 

  /* USB Request Type*/
#define USB_REQ_TYPE_MASK          0x60
#define USB_REQ_TYPE_SHIFT         5
#define USB_REQ_TYPE(v)            (((v) & USB_REQ_TYPE_MASK) >> \
                                    USB_REQ_TYPE_SHIFT)

#define USB_REQ_HOST_TO_DEV        0x0
#define USB_REQ_DEV_TO_HOST        0x80

#define USB_REQ_REP_DEVICE         0
#define USB_REQ_REP_INTERFACE      1
#define USB_REQ_REP_EP             2
#define USB_REQ_REP_OTHER          3

#define USB_REQ_STANDARD           0x0
#define USB_REQ_CLASS              0x1
#define USB_REQ_VENDOR             0x2
#define USB_REQ_OTHER              0x3

  /* Standard USB Request Type */
#define USB_REQ_GET_STATUS         0
#define USB_REQ_CLEAR_FEATURE      1
#define USB_REQ_SET_FEATURE        3
#define USB_REQ_SET_ADDRESS        5
#define USB_REQ_GET_DESCRIPTOR     6
#define USB_REQ_SET_DESCRIPTOR     7
#define USB_REQ_GET_CONFIGURATION  8
#define USB_REQ_SET_CONFIGURATION  9

#define USB_GET_DESC_DEV           1
#define USB_GET_DESC_CONF          2
#define USB_GET_DESC_STRING        3

typedef struct {
    unsigned char  reqType;
    unsigned char  req;
    unsigned short wValue;
    unsigned short wIndex;
    unsigned short wLength;
} USBSetupPacket;

typedef struct {
    u8* (* getDevDesc) (int *len);
    u8* (* getConfDesc) (int *len);    
    u8* (* getDescString) (int which, int *len);
    void (*enumDone) ();
} Ch9CallBack;

IOSError Ch9Setup();
IOSError setupCh9Callback(Ch9CallBack *ptr);
IOSError Ch9RecvSetup();
IOSError Ch9RecvData(int len);
IOSError Ch9SendData(int len);

#endif
