usbdrv/peripheral/public/d32usbcshared.inl
branchRCL_3
changeset 43 012cc2ee6408
parent 42 f92a4f87e424
child 45 ee9b31ff95f7
child 52 3d9964be03bc
equal deleted inserted replaced
42:f92a4f87e424 43:012cc2ee6408
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32/include/d32usbcshared.inl
       
    15 // User side class definitions for USB Device support.
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file d32usbcshared.inl
       
    21  @publishedPartner
       
    22  @released
       
    23 */
       
    24 
       
    25 #ifndef __D32USBCSHARED_INL__
       
    26 #define __D32USBCSHARED_INL__
       
    27 
       
    28 inline TInt MaxEndpointPacketSize(TInt aSizes)
       
    29 	{
       
    30 	return (aSizes & KUsbEpSize1024) ? 1024 :
       
    31 		((aSizes & KUsbEpSize1023) ? 1023 :
       
    32 		 ((aSizes & KUsbEpSize512) ? 512 :
       
    33 		  ((aSizes & KUsbEpSize256) ? 256 :
       
    34 		   ((aSizes & KUsbEpSize128) ? 128 :
       
    35 			((aSizes & KUsbEpSize64) ? 64 :
       
    36 			 ((aSizes & KUsbEpSize32) ? 32 :
       
    37 			  ((aSizes & KUsbEpSize16) ? 16 :
       
    38 			   ((aSizes & KUsbEpSize8) ? 8 : 0))))))));
       
    39 	}
       
    40 
       
    41 
       
    42 inline TInt MinEndpointPacketSize(TInt aSizes)
       
    43 	{
       
    44 	return (aSizes & KUsbEpSize8) ? 8 :
       
    45 		((aSizes & KUsbEpSize16) ? 16 :
       
    46 		 ((aSizes & KUsbEpSize32) ? 32 :
       
    47 		  ((aSizes & KUsbEpSize64) ? 64 :
       
    48 		   ((aSizes & KUsbEpSize128) ? 128 :
       
    49 			((aSizes & KUsbEpSize256) ? 256 :
       
    50 			 ((aSizes & KUsbEpSize512) ? 512 :
       
    51 			  ((aSizes & KUsbEpSize1023) ? 1023 :
       
    52 			   ((aSizes & KUsbEpSize1024) ? 1024 : 0))))))));
       
    53 	}
       
    54 
       
    55 inline TInt TUsbcEndpointCaps::MaxPacketSize() const
       
    56 	{
       
    57 	return (iSizes & KUsbEpSize1024) ? 1024 :
       
    58 		((iSizes & KUsbEpSize1023) ? 1023 :
       
    59 		 ((iSizes & KUsbEpSize512) ? 512 :
       
    60 		  ((iSizes & KUsbEpSize256) ? 256 :
       
    61 		   ((iSizes & KUsbEpSize128) ? 128 :
       
    62 			((iSizes & KUsbEpSize64) ? 64 :
       
    63 			 ((iSizes & KUsbEpSize32) ? 32 :
       
    64 			  ((iSizes & KUsbEpSize16) ? 16 :
       
    65 			   ((iSizes & KUsbEpSize8) ? 8 : 0))))))));
       
    66 	}
       
    67 
       
    68 
       
    69 inline TInt TUsbcEndpointCaps::MinPacketSize() const
       
    70 	{
       
    71 	return (iSizes & KUsbEpSize8) ? 8 :
       
    72 		((iSizes & KUsbEpSize16) ? 16 :
       
    73 		 ((iSizes & KUsbEpSize32) ? 32 :
       
    74 		  ((iSizes & KUsbEpSize64) ? 64 :
       
    75 		   ((iSizes & KUsbEpSize128) ? 128 :
       
    76 			((iSizes & KUsbEpSize256) ? 256 :
       
    77 			 ((iSizes & KUsbEpSize512) ? 512 :
       
    78 			  ((iSizes & KUsbEpSize1023) ? 1023 :
       
    79 			   ((iSizes & KUsbEpSize1024) ? 1024 : 0))))))));
       
    80 	}
       
    81     
       
    82 static inline TUint PacketSize2Mask(TInt aSize)
       
    83 	{
       
    84 	return (aSize == 8) ? KUsbEpSize8 :
       
    85 		((aSize == 16) ? KUsbEpSize16 :
       
    86 		 ((aSize == 32) ? KUsbEpSize32 :
       
    87 		  ((aSize == 64) ? KUsbEpSize64 :
       
    88 		   ((aSize == 128) ? KUsbEpSize128 :
       
    89 			((aSize == 256) ? KUsbEpSize256 :
       
    90 			 ((aSize == 512) ? KUsbEpSize512 :
       
    91 			  ((aSize == 1023) ? KUsbEpSize1023 :
       
    92 			   ((aSize == 1024) ? KUsbEpSize1024 : 0))))))));
       
    93 	}
       
    94 
       
    95 
       
    96 static inline TUint EpTypeMask2Value(TInt aType)
       
    97 	{
       
    98 	return (aType & UsbShai::KUsbEpTypeControl) ? KUsbEpAttr_TransferTypeControl :
       
    99 		((aType & UsbShai::KUsbEpTypeIsochronous) ? KUsbEpAttr_TransferTypeIsochronous :
       
   100 		 ((aType & UsbShai::KUsbEpTypeBulk) ? KUsbEpAttr_TransferTypeBulk :
       
   101 		  ((aType & UsbShai::KUsbEpTypeInterrupt) ? KUsbEpAttr_TransferTypeInterrupt : -1)));
       
   102 	}
       
   103 
       
   104 
       
   105 /** @internalTechnology
       
   106 */
       
   107 struct TEndpointDescriptorInfo
       
   108 	{
       
   109 	TInt iSetting;											// alternate setting
       
   110 	TInt iEndpoint;											// excludes ep0
       
   111 	TAny* iArg;												// address of data
       
   112 	};
       
   113 
       
   114 
       
   115 /** @internalTechnology
       
   116 */
       
   117 struct TCSDescriptorInfo
       
   118 	{
       
   119 	TInt iSetting;											// alternate setting
       
   120 	TInt iEndpoint;											// excludes ep0, not used for CS ifc desc
       
   121 	TAny* iArg;												// address of data
       
   122 	TInt iSize;												// size of data (descriptor block)
       
   123 	};
       
   124 
       
   125 inline TUsbcEndpointInfo::TUsbcEndpointInfo(TUint aType, TUint aDir, TInt aSize,
       
   126 											TInt aInterval, TInt aExtra)
       
   127 	{
       
   128     iType = aType; 
       
   129     iDir = aDir; 
       
   130     iSize = aSize; 
       
   131     iInterval = aInterval;
       
   132 	iInterval_Hs = -1; 
       
   133     iTransactions = 0; 
       
   134     iExtra = aExtra; 
       
   135     iFeatureWord1 = 0;
       
   136 	iReserved = 0;
       
   137     }
       
   138     
       
   139 inline TUsbcClassInfo::TUsbcClassInfo(TInt aClass, TInt aSubClass, TInt aProtocol)
       
   140 	: iClassNum(aClass), iSubClassNum(aSubClass), iProtocolNum(aProtocol), iReserved(0)
       
   141 	{}
       
   142     
       
   143 #endif
       
   144 
       
   145