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

📄 ctlin.c

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

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

Module Name:

        ctlin.c

Abstract:

        Module related to in packet of control pipe

Environment:

        Keil C51 Compiler

Revision History:

        08/28/2001      Chi-Yeh Tsai    created                 

--*/

//=============================================================================
//Header file
//=============================================================================
#include "general.h"
#include "ctlin.h"
#include "ctlsetup.h"
#include "stdreq.h"
#include "vndreq.h"
#include "rsvreq.h"
#include "main.h"
//#include "usbaudc.h"
//#include "usbsidc.h"
#include "usbmsdc2.h"
#include "cardlink.h"
//#include "uiflow.h"
//#include "dosusr.h"
//#include "smcvar.h"
//#include "smcfunc.h"


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

//-----------------------------------------------------------------------------
//Variable
//-----------------------------------------------------------------------------
#if (USBVendor_OPTION==1)
data BIT _GUSBOutReady=0;
#endif

extern code    UCHAR   K_DeviceDescriptor[];

extern void 	dump_G_ucStorData(void);

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

Routine Description:

        process in packet of control pipe

Arguments:

        none

Return Value:

        none

--*/
{
        UCHAR type;

#if (USBVendor_OPTION==1)
	UCHAR i;
	USHORT PacketShift2SRAM;
#endif

        if (G_ucCtrlPhase == K_InDataPhase)               //in data phase
        {
                //check Type of bmRequestType
                type = G_pCtrlCommand->bmRequestType & 0x60;
                if (type == 0x00)
                {
                        CTLIN_StandardRequest();        //Standard request
                }
                else if (type == 0x20)
                {               
                        CTLIN_ClassRequest();           //Class request
                }
                else if (type == 0x40)
                {
                        CTLIN_VendorRequest();          //Vendor request
                }               
                else //if (type == 0x60)
                {
                        CTLIN_ReservedRequest();        //Reserved request
                }
        }
        else if (G_ucCtrlPhase == K_InResponsePhase)      //in response phase     
        {
                //just in zero packet - 0 byte in EP0 FIFO
		//patch4.3@richie@oh0530
//		DbgPrint("InPhase\n");
		G_ucCtrlPhase = K_CommandPhase;

#if (USBVendor_OPTION==1)								
	        if (G_pCtrlCommand->bRequest == 0xfe) //Vendor Command For Set the Vendor USB Configuration
		{

//   		  DbgPrint("wIndex=%x \n", G_pCtrlCommand->wIndex);
	
		  PacketShift2SRAM = G_pCtrlCommand->wIndex - 0x10;
		  if(G_pCtrlCommand->wIndex==0x20) PacketShift2SRAM = 0x06;
			
		  for (i=0;i<0x40;i++)
		  {					
//			  DbgPrint("0x%bx  ",G_ucCtrlData[i]);
//			  if((i!=0)&&(!(i%7)))
//			  DbgPrint("\n");
			  G_ucStorData[(PacketShift2SRAM*0x40)+i] = G_ucCtrlData[i];								 					 
		  }									
			  if(G_pCtrlCommand->wIndex==0x10)
			  {							

				G_ucStorData[8]=G_ucStorData[2]; 	//get LSB of VID
				G_ucStorData[9]=G_ucStorData[3];	//get MSB of VID
				G_ucStorData[10]=G_ucStorData[0];	//get LSB of PID
				G_ucStorData[11]=G_ucStorData[1];	//get MSB of PID
										
				G_ucStorData[0]=0x12;
				G_ucStorData[1]=0x01;
				G_ucStorData[2]=0x10;
				G_ucStorData[3]=0x01;
				G_ucStorData[4]=0;
				G_ucStorData[5]=0;
				G_ucStorData[6]=0;
				G_ucStorData[7]=0x08;

				G_ucStorData[12]=0;
				G_ucStorData[13]=0x01;
				G_ucStorData[14]=0x01;
				G_ucStorData[15]=0x02;
				G_ucStorData[16]=0x03;
				G_ucStorData[17]=0x01;										
												
			  }

			// Last Vendor Configuration Data			  					  			  
			if(G_pCtrlCommand->wIndex==0x20) _GUSBOutReady=1;
					
			
			  G_ucState2 = 0x01;								
		}

	

#endif										
        }
        else                                            //phase transition error
        {
                //phase transition error - in packet should not appear
                //                         at current phase
                //just in zero packet - 0 byte in EP0 FIFO
        }
}

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

Routine Description:

        process in packet of standard request

Arguments:

        none

Return Value:

        none

--*/
{
        CTLIN_SetInPacketData();        //just send the data if any 
        
        //phase transition
        if (G_ucCtrlPacketIndex > 0)        //n byte in EP0 FIFO    
        {
                G_ucCtrlPhase = K_InDataPhase;
        }
        else                            //0 byte in EP0 FIFO
        {
                STDREQ_PostInDataPhase();
                G_ucCtrlPhase = K_OutResponsePhase;
        }
}

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

Routine Description:

        process in packet of class request

Arguments:

        none

Return Value:

        none

--*/
{                                
        G_ucCtrlPacketIndex = 0;    //initialize packet index



//richie@0204
//        if (((G_pCtrlCommand->wIndex == K_StorageInterface1) ||  //reserved:0 / bInterfaceNumber:K_StorageInterface1
//             (G_pCtrlCommand->wIndex == K_StorageInterface2)) && //reserved:0 / bInterfaceNumber:K_StorageInterface2
//             (G_pCtrlCommand->wValue == 0x0000))       //reserved:0
	//if (G_ui_status == K_UI_mass_storage)
//        if ((G_UIStatus & 0xff00) == K_UISTATUS_USBMODE_MASS)  //yichang@replace
//        {
                CTLIN_SetInPacketData();        //just send the data if any 
        
                //phase transition
                if (G_ucCtrlPacketIndex > 0)        //n byte in EP0 FIFO    
                {
                        G_ucCtrlPhase = K_InDataPhase;
                }
                else                            //0 byte in EP0 FIFO
                {
                        USBMSDC_BoPostInDataPhase();
                        G_ucCtrlPhase = K_OutResponsePhase;
                }
//        }

}
//-----------------------------------------------------------------------------
// CTLIN_VendorRequest
//-----------------------------------------------------------------------------
void CTLIN_VendorRequest(void) USING_1
/*++

Routine Description:

        process in packet of vendor request

Arguments:

        none

Return Value:

        none

--*/
{
#if (USBVendor_OPTION==1)
        CTLIN_SetInPacketData();        //just send the data if any 
        
        //phase transition
        if (G_ucCtrlPacketIndex > 0)        //n byte in EP0 FIFO    
        {
                G_ucCtrlPhase = K_InDataPhase;
        }
        else                            //0 byte in EP0 FIFO
        {
                VNDREQ_PostInDataPhase();
                G_ucCtrlPhase = K_OutResponsePhase;
        }
#endif
}

//-----------------------------------------------------------------------------
//CTLIN_ReservedRequest
//-----------------------------------------------------------------------------
/*++

Routine Description:

        process in packet of reserved request

Arguments:

        none

Return Value:

        none

--*/
void CTLIN_ReservedRequest(void) USING_1
{
}

//-----------------------------------------------------------------------------
//CTLIN_SetInPacketData
//-----------------------------------------------------------------------------
void CTLIN_SetInPacketData(void)
/*++

Routine Description:

        set data for next in packet

Arguments:

        none

Return Value:

        none

--*/
{
        G_ucCtrlPacketIndex = 0;    //initialize packet index

        while ((G_ucCtrlPacketIndex < 8) && (G_usCtrlDataIndex < G_usCtrlDataLength))
        {
                XBYTE[0x2500] = G_pucCtrlDataPointer[G_usCtrlDataIndex]; 
                G_ucCtrlPacketIndex++;
                G_usCtrlDataIndex++;
        }
}

⌨️ 快捷键说明

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