usbdriver.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *  $Id: usbdriver.h 150 2008-06-16 20:17:25Z merdmann $
00003  *
00004  *  Thu Nov 29 20:55:57 2007
00005  *  Copyright  2007 Michael Erdmann
00006  *  Email: michael.erdmann@snafu.de
00007  ****************************************************************************/
00008 
00009 /*
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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 /* specify the next data packaet type */
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

Generated on Mon Sep 29 19:56:47 2008 for mKernel by  doxygen 1.4.6