usb.h

Go to the documentation of this file.
00001 /**************************************************************************/
00017 #ifndef _USB_H
00018 #define _USB_H
00019 
00020 /******************************************************************************
00021                    Define(s) section
00022 ******************************************************************************/
00023 // \cond
00024 // USB device API return values
00025 // Indicates the operation was successful
00026 #define STATUS_SUCCESS             0
00027 // Endpoint/device is already busy
00028 #define STATUS_BUSY                1
00029 // Operation has been aborted
00030 #define STATUS_ABORTED             2
00031 // Operation has been aborted because the device was configured
00032 #define STATUS_RESET               3
00033 // \endcond
00034 
00035 /******************************************************************************
00036                    Types section
00037 ******************************************************************************/
00038 // transaction callback type
00039 typedef void (* TransferCallback_t)(void *pArg, uint8_t status, uint16_t transferred, uint16_t remaining);
00040 
00041 BEGIN_PACK
00042 // Usb endpoint descriptor
00043 typedef struct PACK
00044 {
00045   uint8_t  bLength;          // Size of the descriptor in bytes
00046   uint8_t  bDescriptorType;  // Descriptor type
00047   uint8_t  bEndpointAddress; // Address and direction of the endpoint
00048   uint8_t  bmAttributes;     // Endpoint type and additional characteristics (for isochronous endpoints)
00049   uint16_t wMaxPacketSize;   // Maximum packet size (in bytes) of the endpoint
00050   uint8_t  bInterval;        // Polling rate of the endpoint
00051 } HAL_UsbEndPointDescptr_t;
00052 END_PACK
00053 
00054 /******************************************************************************
00055                    Prototypes section
00056 ******************************************************************************/
00057 /**************************************************************************/
00063 void HAL_RegisterRequestHandler(void (* f)(uint8_t *req));
00064 
00065 /**************************************************************************/
00071 void HAL_RegisterEndOfBusResetHandler(void (* f)(void));
00072 
00073 /**************************************************************************/
00079 void HAL_RegisterResumeHandler(void (* f)(void));
00080 
00081 /**************************************************************************/
00087 void HAL_RegisterSuspendHandler(void (* f)(void));
00088 
00089 /**************************************************************************/
00095 void HAL_ConfigureEndpoint(HAL_UsbEndPointDescptr_t *descriptor);
00096 
00097 /**************************************************************************/
00124 uint8_t HAL_UsbWrite(uint8_t eptnum, void *data, uint32_t size, TransferCallback_t callback, void *argument);
00125 
00126 /**************************************************************************/
00150 uint8_t HAL_UsbRead(uint8_t eptnum, void *data, uint32_t size, TransferCallback_t callback, void *argument);
00151 
00152 /**************************************************************************/
00158 void HAL_Halt(uint8_t eptnum);
00159 
00160 /**************************************************************************/
00166 void HAL_Unhalt(uint8_t eptnum);
00167 
00168 /**************************************************************************/
00178 uint8_t HAL_IsHalted(uint8_t eptnum);
00179 
00180 /**************************************************************************/
00190 uint8_t HAL_Stall(uint8_t eptnum);
00191 
00192 /**************************************************************************/
00198 void HAL_SetAddress(uint8_t *address);
00199 
00200 /**************************************************************************/
00206 void HAL_SetConfiguration(uint8_t cfgnum);
00207 
00208 /**************************************************************************/
00216 void HAL_UsbInit(uint8_t *reqMem);
00217 
00218 /**************************************************************************/
00224 uint8_t HAL_GetState(void);
00225 
00226 #endif /* _USB_H */

Generated on Mon Feb 16 17:53:40 2009 for BitCloud Stack Documentation by  doxygen 1.5.1-p1