usbmgmt/usbmgr/device/classdrivers/acm/classimplementation/ecacm/src/ClassDescriptor.cpp
changeset 0 c9bc50fca66e
child 29 59aa7d6e3e0f
equal deleted inserted replaced
-1:000000000000 0:c9bc50fca66e
       
     1 /*
       
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "ClassDescriptor.h"
       
    19 #include "AcmPanic.h"
       
    20 #include <usb/usblogger.h>
       
    21 
       
    22 #ifdef __FLOG_ACTIVE
       
    23 _LIT8(KLogComponent, "ECACM");
       
    24 #endif
       
    25 
       
    26 TDes8& TUsbCsClassDescriptor::Des()
       
    27 /**
       
    28  * This function packs the TUsbCsClassDescriptor class into a descriptor with 
       
    29  * the correct byte alignment for transmission on the USB bus.
       
    30  *
       
    31  * @return Correctly-aligned buffer. NB The buffer returned is a member of 
       
    32  * this class and has the same lifetime.
       
    33  */
       
    34 	{
       
    35 	TUint index = 0;
       
    36 
       
    37 	iBuffer.SetLength(KUsbClassSpecificBufferSize);
       
    38 
       
    39 	iBuffer[index++] = iHdrSize;
       
    40 	iBuffer[index++] = iHdrType;
       
    41 	iBuffer[index++] = iHdrSubType;
       
    42 	iBuffer[index++] = (TUint8) ( iHdrBcdCDC & 0x00ff);
       
    43 	iBuffer[index++] = (TUint8) ((iHdrBcdCDC & 0xff00) >> 8);
       
    44 	iBuffer[index++] = iAcmSize;
       
    45 	iBuffer[index++] = iAcmType;
       
    46 	iBuffer[index++] = iAcmSubType;
       
    47 	iBuffer[index++] = iAcmCapabilities;
       
    48 	iBuffer[index++] = iUnSize;
       
    49 	iBuffer[index++] = iUnType;
       
    50 	iBuffer[index++] = iUnSubType;
       
    51 	iBuffer[index++] = iUnMasterInterface;
       
    52 	iBuffer[index++] = iUnSlaveInterface;
       
    53 
       
    54 #if defined(DISABLE_ACM_CF_COUNTRY_SETTING)
       
    55 
       
    56 	// no functional descriptor needed
       
    57 
       
    58 #elif defined(ENABLE_ACM_CF_COUNTRY_SETTING)
       
    59 
       
    60 	// CDC Country Selection Functional Descriptor
       
    61 	iBuffer[index++] = iCsSize;
       
    62 	iBuffer[index++] = iCsType;
       
    63 	iBuffer[index++] = iCsSubType;
       
    64 	iBuffer[index++] = iCsRelDate;
       
    65 
       
    66 	for ( TUint scan = 0 ; scan < KUsbCommNumCountries ; scan++ )
       
    67 		{
       
    68 		iBuffer[index++] = (TUint8) (iCsCountryCode[scan] & 0x00ff);
       
    69 		iBuffer[index++] = (TUint8) ((iCsCountryCode[scan] & 0xff00) >> 8);
       
    70 		}
       
    71 
       
    72 #endif
       
    73 
       
    74 	__ASSERT_DEBUG(index == KUsbClassSpecificBufferSize, 
       
    75 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
       
    76 
       
    77 	return iBuffer;
       
    78 	}
       
    79 
       
    80 //
       
    81 // End of file