msdbot.h

Go to the documentation of this file.
00001 /***************************************************************************/
00036 #ifndef __MSDBOT_H
00037 #define __MSDBOT_H
00038 
00039 /***************************************************************************/
00044 /***************************************************************************/
00049 #ifdef __cplusplus
00050 extern "C" {
00051 #endif
00052 
00055 #define CBW_LEN          31
00056 #define CSW_LEN          13
00057 
00058 #define BOT_DIR_IN       0x80                 /* bmCBWFlags value for bulk IN cmds.  */
00059 #define BOT_DIR_OUT      0x00                 /* bmCBWFlags value for bulk OUT cmds. */
00060 
00061 #define CSW_SIGNATURE    0x53425355           /* Ascii USBS */
00062 #define CBW_SIGNATURE    0x43425355           /* Ascii USBC */
00063 
00066 /**************************************************************************/
00069 EFM32_PACK_START(1)
00070 typedef struct
00071 {
00072   uint32_t dCBWSignature;           
00073   uint32_t dCBWTag;                 
00074   uint32_t dCBWDataTransferLength;  
00075   union
00076   {
00077     struct
00078     {
00079       uint8_t Reserved1 : 6;        
00080       uint8_t Obsolete  : 1;        
00081       uint8_t Direction : 1;        
00082     };
00083     uint8_t bmCBWFlags;             
00084   };
00085   union
00086   {
00087     struct
00088     {
00089       uint8_t Lun       : 4;        
00090       uint8_t Reserved2 : 4;        
00091     };
00092     uint8_t bCBWLUN;
00093   };
00094   union
00095   {
00096     struct
00097     {
00098       uint8_t CBLength  : 5;        
00099       uint8_t Reserved3 : 3;        
00100     };
00101     uint8_t bCBWCBLength;           
00102   };
00103   uint8_t CBWCB[ 16 ];              
00104 } __attribute__ ((packed)) MSDBOT_CBW_TypeDef;
00105 EFM32_PACK_END()
00106 
00107 /**************************************************************************/
00110 EFM32_PACK_START(1)
00111 typedef struct
00112 {
00113   uint32_t dCSWSignature;           
00114   uint32_t dCSWTag;                 
00115   uint32_t dCSWDataResidue;         
00116   uint8_t  bCSWStatus;              
00117 } __attribute__ ((packed)) MSDBOT_CSW_TypeDef;
00118 EFM32_PACK_END()
00119 
00121 typedef enum
00122 {
00123   MSDBOT_STATUS_OK  = 0,            
00124   MSDBOT_INIT_ERROR = -1,           
00125   MSDBOT_CMD_FAILED = -2,           
00126   MSDBOT_XFER_ERROR = -3,           
00127 } MSDBOT_Status_TypeDef;
00128 
00129 /*** MSDBOT Function prototypes ***/
00130 
00131 #if defined(USB_HOST)
00132 
00133 int MSDBOT_Init(USBH_Ep_TypeDef *out, USBH_Ep_TypeDef *in);
00134 int MSDBOT_Xfer(void* cbw, void* data);
00135 
00136 #endif
00137 
00138 #ifdef __cplusplus
00139 }
00140 #endif
00141 
00145 #endif /* __MSDBOT_H */