usbapi.h

Go to the documentation of this file.
00001 
00008 #include "type.h"
00009 #include "usbstruct.h"          // for TSetupPacket
00010 
00011 /*************************************************************************
00012         USB configuration
00013 **************************************************************************/
00014 
00015 #define MAX_PACKET_SIZE0        64              
00017 /*************************************************************************
00018         USB hardware interface
00019 **************************************************************************/
00020 
00021 // endpoint status sent through callback
00022 #define EP_STATUS_DATA          (1<<0)          
00023 #define EP_STATUS_STALLED       (1<<1)          
00024 #define EP_STATUS_SETUP         (1<<2)          
00025 #define EP_STATUS_NACKED        (1<<3)          
00026 #define EP_STATUS_ERROR         (1<<4)          
00028 // device status sent through callback
00029 #define DEV_STATUS_CONNECT              (1<<0)  
00030 #define DEV_STATUS_SUSPEND              (1<<2)  
00031 #define DEV_STATUS_RESET                (1<<4)  
00033 // interrupt bits for NACK events in USBHwNakIntEnable
00034 // (these bits conveniently coincide with the LPC214x USB controller bit)
00035 #define INACK_CI                (1<<1)                  
00036 #define INACK_CO                (1<<2)                  
00037 #define INACK_II                (1<<3)                  
00038 #define INACK_IO                (1<<4)                  
00039 #define INACK_BI                (1<<5)                  
00040 #define INACK_BO                (1<<6)                  
00042 BOOL USBHwInit                  (void);
00043 void USBHwISR                   (void);
00044 
00045 void USBHwNakIntEnable  (U8 bIntBits);
00046 
00047 void USBHwConnect               (BOOL fConnect);
00048 
00049 void USBHwSetAddress    (U8 bAddr);
00050 void USBHwConfigDevice  (BOOL fConfigured);
00051 
00052 // endpoint operations
00053 void USBHwEPConfig              (U8 bEP, U16 wMaxPacketSize);
00054 int  USBHwEPRead                (U8 bEP, U8 *pbBuf, int iMaxLen);
00055 int      USBHwEPWrite           (U8 bEP, U8 *pbBuf, int iLen);
00056 void USBHwEPStall               (U8 bEP, BOOL fStall);
00057 BOOL USBHwEPIsStalled   (U8 bEP);
00058 
00060 typedef void (TFnEPIntHandler)  (U8 bEP, U8 bEPStatus);
00061 void USBHwRegisterEPIntHandler  (U8 bEP, TFnEPIntHandler *pfnHandler);
00062 
00064 typedef void (TFnDevIntHandler) (U8 bDevStatus);
00065 void USBHwRegisterDevIntHandler (TFnDevIntHandler *pfnHandler);
00066 
00068 typedef void (TFnFrameHandler)(U16 wFrame);
00069 void USBHwRegisterFrameHandler(TFnFrameHandler *pfnHandler);
00070 
00071 
00072 /*************************************************************************
00073         USB application interface
00074 **************************************************************************/
00075 
00076 // initialise the complete stack, including HW
00077 BOOL USBInit(void);
00078 
00080 typedef BOOL (TFnHandleRequest)(TSetupPacket *pSetup, int *piLen, U8 **ppbData);
00081 void USBRegisterRequestHandler(int iType, TFnHandleRequest *pfnHandler, U8 *pbDataStore);
00082 void USBRegisterCustomReqHandler(TFnHandleRequest *pfnHandler);
00083 
00085 typedef BOOL (TFnGetDescriptor)(U16 wTypeIndex, U16 wLangID, int *piLen, U8 **ppbData);
00086 
00088 BOOL USBHandleStandardRequest(TSetupPacket *pSetup, int *piLen, U8 **ppbData);
00089 
00091 void USBHandleControlTransfer(U8 bEP, U8 bEPStat);
00092 
00094 void USBRegisterDescriptors(const U8 *pabDescriptors);
00095 BOOL USBGetDescriptor(U16 wTypeIndex, U16 wLangID, int *piLen, U8 **ppbData);

Generated on Sun Sep 3 23:15:09 2006 for LPCUSB by  doxygen 1.4.6