00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00030 #include "typedefs.h"
00031 #include "dev.h"
00032 #include "usb.h"
00033
00034 #ifndef _USBDRIVER_H
00035 #define _USBDRIVER_H
00036
00037 #define MAX_EP 8
00038
00039
00040 typedef union {
00041 byte value;
00042 struct{
00043 unsigned BC :2;
00044 unsigned BSTALL :1;
00045 unsigned DTSEN :1;
00046 unsigned INCDIS :1;
00047 unsigned KEN :1;
00048 unsigned DTS :1;
00049 unsigned UOWN :1;
00050 };
00051 struct{
00052 unsigned _BC :2;
00053 unsigned PID :4;
00054 unsigned :1;
00055 unsigned _UOWN :1;
00056 };
00057 } BDSTAT;
00058
00060 typedef struct {
00061 BDSTAT STAT;
00062 byte CNT;
00063 POINTER ADR;
00064 } BD;
00065
00066 typedef byte t_ep;
00067 typedef byte t_bid;
00068
00069 typedef union {
00070 struct {
00071 unsigned length : 10;
00072 unsigned PID : 4;
00073 unsigned unused : 2;
00074 } ;
00075 unsigned value;
00076 } t_transaction;
00077
00078 #define BUFFER(n) (byte __near*)(0x500+((n)*EP0_BUFF_SIZE))
00079
00081 void USB_Activate(void);
00082
00084 void USB_Shutdown(void);
00085
00086
00090 void USB_Initialize(void);
00091
00092
00093 typedef enum {
00094 DATA0,
00095 DATA1,
00096 DATAX
00097 } t_dts;
00098
00099 unsigned USB_Wait(t_ep ep, t_bid buffer, t_dts next);
00100 unsigned USB_Send(t_ep ep, t_bid buffer, unsigned length, t_dts first );
00101
00102
00103 extern t_dev usb_handler;
00104
00105
00106 #define EP0_BUFF_SIZE 16 // 8, 16, 32, or 64
00107
00108 #endif