⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stdreq.c

📁 凌阳MP3 spSPCA755yuanma
💻 C
字号:
/*++

Copyright (c) 2001 Sunplus Technology Co., Ltd.

Module Name:

        stdreq.c

Abstract:

        Module related to standard request

Environment:

        Keil C51 Compiler

Revision History:

        08/28/2001      Chi-Yeh Tsai    created                 

--*/

//=============================================================================
//Header file
//=============================================================================
#include "general.h"
#include "stdreq.h"
#include "main.h"
#include "ctlsetup.h"
#include "stddesc.h"
#include "usbstr.h"
//#include "uiflow.h"
//#include "smcfunc.h"
#include  "cardlink.h"

//=============================================================================
//Symbol
//=============================================================================
//-----------------------------------------------------------------------------
//Constant
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
//Variable
//-----------------------------------------------------------------------------
//data   BIT   _GOneTim;

//=============================================================================
//Program
//=============================================================================
//-----------------------------------------------------------------------------
//STDREQ_NoDataPhase
//-----------------------------------------------------------------------------
void STDREQ_NoDataPhase(void) USING_1
/*++

Routine Description:

        process standard request without data phase

Arguments:

        none

Return Value:

        none

--*/
{
}

//-----------------------------------------------------------------------------
//STDREQ_PreInDataPhase
//-----------------------------------------------------------------------------
void STDREQ_PreInDataPhase(void) USING_1
/*++

Routine Description:

        pre-process setting of following in data phase

Arguments:

        none

Return Value:

        none

--*/
{
        switch (G_pCtrlCommand->bRequest)
        {
                case K_STDREQCODE_GET_DESCRIPTOR:
                        STDREQ_PreGetDescriptor();      //GET_DESCRIPTOR
                        break;

                default:
                        break;
        }
}

//-----------------------------------------------------------------------------
//STDREQ_PreOutDataPhase
//-----------------------------------------------------------------------------
void STDREQ_PreOutDataPhase(void) USING_1
/*++

Routine Description:

        pre-process setting of following out data phase

Arguments:

        none

Return Value:

        none

--*/
{
        G_pucCtrlDataPointer = G_ucCtrlData;
}

//-----------------------------------------------------------------------------
//STDREQ_PostInDataPhase
//-----------------------------------------------------------------------------
void STDREQ_PostInDataPhase(void) USING_1
/*++

Routine Description:

        post-process data of complete in data phase

Arguments:

        none

Return Value:

        none
                             
--*/
{
}

//-----------------------------------------------------------------------------
//STDREQ_PostOutDataPhase
//-----------------------------------------------------------------------------
void STDREQ_PostOutDataPhase(void) USING_1
/*++

Routine Description:

        post-process data of complete out data phase

Arguments:

        none

Return Value:

        none

--*/
{
}

//-----------------------------------------------------------------------------
//STDREQ_PreGetDescriptor
//-----------------------------------------------------------------------------
void STDREQ_PreGetDescriptor(void) USING_1
/*++

Routine Description:

        prepare standard request of get descriptor

Arguments:

        none

Return Value:

        none

--*/
{
        USHORT sizeAvailable = 0;

        //get descriptor length
        switch (G_pCtrlCommand->wValue & 0xff00)
        {
                case K_DEVICE_DESCRIPTOR:
                        //get device descriptor
                        //DbgPrint("STDREQ_PreGetDescriptor: get device descriptor\n");
//richie@g0109
//richie@si0417
#if (USBVendor_OPTION==1)&&(USBVendorConfiguration_OPTION == 0) 			
			// Vendor Device Descriptor 																											
	                        G_pucCtrlDataPointer = (UCHAR *)&K_VendorDeviceDescriptor; // WWWW
	                        sizeAvailable = K_VendorDEVICE_DESCRIPTOR_SIZE; 
#endif

#if  (USBVendor_OPTION==0)&&(USBVendorConfiguration_OPTION == 1) 
			// MSDC Get Device Descriptor from NAND Flash !
				G_pucCtrlDataPointer = (UCHAR *)&G_ucStorData;
	                        sizeAvailable = K_MSDC_DEVICE_DESCRIPTOR_SIZE; 
#endif
#if  (USBVendor_OPTION==0)&&(USBVendorConfiguration_OPTION == 0) 
			// MSDC Get Device Descriptor from ROM Table  !
	                        G_pucCtrlDataPointer = (UCHAR *)&K_MSDC_DeviceDescriptor; // WWWW
	                        sizeAvailable = K_MSDC_DEVICE_DESCRIPTOR_SIZE; 

#endif

                        break;

                case K_CONFIGURATION_DESCRIPTOR:
                        //get configuration descriptor
                        //DbgPrint("STDREQ_PreGetDescriptor: get configuration descriptor\n");
//richie@g0109
//richie@si0417
//                                                if (G_ui_status == K_UI_mass_storage)//(1)//((XBYTE[0x2041] & 0x10) == 0x00)
#if (USBVendor_OPTION==1)
			// Vendor Device Descriptor's configuration 
	                        G_pucCtrlDataPointer = (UCHAR *)&K_VendorConfigurationDescriptor; // WWWW
	                        sizeAvailable = K_VendorCONFIGURATION_DESCRIPTOR_SIZE;
#else
			// MSDC Get Device Descriptor from ROM Table !
	                        G_pucCtrlDataPointer = (UCHAR *)&K_MSDC_ConfigurationDescriptor; // WWWW
	                        sizeAvailable = K_MSDC_CONFIGURATION_DESCRIPTOR_SIZE;
#endif
                        break;

                case K_STRING_DESCRIPTOR:
                        //get string descriptor
                        //DbgPrint("STDREQ_PreGetDescriptor: get string descriptor\n");
                        switch (G_pCtrlCommand->wValue & 0x00ff)
                        {
                                case 0x0000:    
                                        //get language ID string        
                                        G_pucCtrlDataPointer = K_LanguageIdString;       
                                        sizeAvailable = K_LANGUAGE_ID_STRING_SIZE;
                                        break;

                                case 0x0001:    
                                        //get manufacturer string        
#if  (USBVendorConfiguration_OPTION == 1) 
				// Get the Manufacturer Strings from NAND Flash 
					G_pucCtrlDataPointer = &G_ucStorData+64; 						
#else
				// Get the Manufacturer Strings from ROM Table					
                                        G_pucCtrlDataPointer = K_ManufacturerString; 
#endif      
                                        sizeAvailable = K_MANUFACTURER_STRING_SIZE;
                                        break;

                                case 0x0002:   
                                        //get product string        
#if  (USBVendorConfiguration_OPTION == 1) 
				// Get the Product Strings from NAND Flash 
					G_pucCtrlDataPointer = &G_ucStorData+128; 
#else 
				// Get the Product Strings from ROM Table					
                                        G_pucCtrlDataPointer = K_ProductString; 
#endif      
                                        sizeAvailable = K_PRODUCT_STRING_SIZE;
                                        break;
//#if 0	//chamber@030127
                                case 0x0003:    
                                        //get serial number string
#if  (USBVendorConfiguration_OPTION == 1) 
				// Get the Serial Number Strings from NAND Flash 
					G_pucCtrlDataPointer = &G_ucStorData+192;
#else
				// Get the Serial Number Strings from ROM Table					
                                        G_pucCtrlDataPointer = K_SerialNumberString;
#endif
                                        sizeAvailable = K_SERIAL_NUMBER_STRING_SIZE;
                                        break;

#if 0
                                case 0x0004:    
                                        //get configuration string
#if  (USBVendorConfiguration_OPTION == 1) 
				// Get the Configuration Strings from NAND Flash 
					G_pucCtrlDataPointer = &G_ucStorData+256;
#else
				// Get the Configuration Strings from ROM Table					
                                        G_pucCtrlDataPointer = K_ConfigurationString;
#endif
                                        sizeAvailable = K_CONFIGURATION_STRING_SIZE;
                                        break;

                                case 0x0005:    
                                        //get interface string
#if  (USBVendorConfiguration_OPTION == 1) 
				// Get the Interface Strings from NAND Flash 
					G_pucCtrlDataPointer = &G_ucStorData+320;
#else
				// Get the Interface Strings from ROM Table					
                                        G_pucCtrlDataPointer = K_InterfaceString;
#endif
                                        sizeAvailable = K_INTERFACE_STRING_SIZE;
                                        break;
#endif

                                default:
                                        G_usCtrlDataLength = 0;
                                        break;
                        }
                        break;

                default:
                        G_usCtrlDataLength = 0;
                        break;
        }

        //min(sizeAvailable, wLength) -> DataLength
        if (sizeAvailable < G_usCtrlDataLength)
                G_usCtrlDataLength = sizeAvailable;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -