|
1 // Copyright (c) 2007-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 // |
|
15 |
|
16 #include "usbtransferstrategy.h" |
|
17 |
|
18 #include <d32usbtransfers.h> |
|
19 #include <d32usbdi_errors.h> |
|
20 #include "usbdiutils.h" |
|
21 |
|
22 |
|
23 TPacketLengths::TPacketLengths(TUint16* aRecvPtr, TUint16* aReqPtr, TInt& aMaxNumPackets) |
|
24 : iRecvPtr(aRecvPtr) |
|
25 , iReqPtr(aReqPtr) |
|
26 , iMaxNumPackets(aMaxNumPackets) |
|
27 {} |
|
28 |
|
29 EXPORT_C TPacketLengths::TLength TPacketLengths::At(TInt aIndex) |
|
30 { |
|
31 __ASSERT_ALWAYS(aIndex >= 0 && aIndex < iMaxNumPackets, UsbdiUtils::Panic(UsbdiPanics::EOutOfBoundsOfLengthArray)); |
|
32 return TPacketLengths::TLength(*(iRecvPtr + aIndex), *(iReqPtr + aIndex)); |
|
33 } |
|
34 |
|
35 EXPORT_C const TPacketLengths::TLength TPacketLengths::At(TInt aIndex) const |
|
36 { |
|
37 __ASSERT_ALWAYS(aIndex >= 0 && aIndex < iMaxNumPackets, UsbdiUtils::Panic(UsbdiPanics::EOutOfBoundsOfLengthArray)); |
|
38 return TPacketLengths::TLength(*(iRecvPtr + aIndex), *(iReqPtr + aIndex)); |
|
39 } |
|
40 |
|
41 EXPORT_C TPacketLengths::TLength TPacketLengths::operator[](TInt aIndex) |
|
42 { |
|
43 return At(aIndex); |
|
44 } |
|
45 |
|
46 EXPORT_C const TPacketLengths::TLength TPacketLengths::operator[](TInt aIndex) const |
|
47 { |
|
48 return At(aIndex); |
|
49 } |
|
50 |
|
51 EXPORT_C TInt TPacketLengths::MaxNumPackets() |
|
52 { |
|
53 return iMaxNumPackets; |
|
54 } |
|
55 |
|
56 EXPORT_C TUint16 TPacketLengths::TLength::operator=(TUint16 aValue) |
|
57 { |
|
58 iRecv = aValue; |
|
59 iReq = aValue; |
|
60 return aValue; |
|
61 } |
|
62 |
|
63 EXPORT_C TPacketLengths::TLength::operator TUint16() const |
|
64 { |
|
65 return iRecv; |
|
66 } |
|
67 |
|
68 TPacketLengths::TLength::TLength(TUint16& aRecv, TUint16& aReq) |
|
69 : iRecv(aRecv) |
|
70 , iReq(aReq) |
|
71 { |
|
72 } |
|
73 |
|
74 |
|
75 TPacketResults::TPacketResults(TInt* aResPtr, TInt& aMaxNumPackets) |
|
76 : iResPtr(aResPtr) |
|
77 , iMaxNumPackets(aMaxNumPackets) |
|
78 { |
|
79 } |
|
80 |
|
81 EXPORT_C TInt TPacketResults::At(TInt aIndex) const |
|
82 { |
|
83 __ASSERT_ALWAYS(aIndex >= 0 && aIndex < iMaxNumPackets, UsbdiUtils::Panic(UsbdiPanics::EOutOfBoundsOfResultArray)); |
|
84 return *(iResPtr + aIndex); |
|
85 } |
|
86 |
|
87 EXPORT_C TInt TPacketResults::operator[](TInt aIndex) const |
|
88 { |
|
89 return At(aIndex); |
|
90 } |
|
91 |
|
92 EXPORT_C TInt TPacketResults::MaxNumPackets() |
|
93 { |
|
94 return iMaxNumPackets; |
|
95 } |
|
96 |
|
97 |
|
98 |
|
99 void RUsbTransferStrategy::Close() |
|
100 { |
|
101 // Doesn't currently own any resources. |
|
102 } |
|
103 |
|
104 void RUsbTransferStrategy::SetTransferHandle(RUsbTransferDescriptor& aTransfer, TInt aHandle) const |
|
105 { |
|
106 aTransfer.iHandle = aHandle; |
|
107 aTransfer.iTransferStrategy = const_cast<RUsbTransferStrategy*>(this); |
|
108 if(aTransfer.iType == RUsbTransferDescriptor::EIsochronous) |
|
109 { |
|
110 static_cast<RUsbIsocTransferDescriptor&>(aTransfer).iWriteHandle = aHandle; |
|
111 } |
|
112 } |
|
113 |
|
114 |