📄 ctlin.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"
//=============================================================================
//Symbol
//=============================================================================
//-----------------------------------------------------------------------------
//Constant
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//Variable
//-----------------------------------------------------------------------------
//=============================================================================
//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 (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
G_ucCtrlPhase = K_CommandPhase;
}
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
#if (USBMSDC_OPTION == 1) //Mass Storage Device Class (Control/Bulk/Interrupt)
if (((G_pCtrlCommand->wIndex == K_StorageInterface1) || //reserved:0 / bInterfaceNumber:K_StorageInterface1
(G_pCtrlCommand->wIndex == K_StorageInterface2)) && //reserved:0 / bInterfaceNumber:K_StorageInterface2
(G_pCtrlCommand->bRequest == 0x00) && //device-specific request code
(G_pCtrlCommand->wValue == 0x0000)) //reserved:0
{
//Never enter here!
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_CbiPostInDataPhase();
G_ucCtrlPhase = K_OutResponsePhase;
}
}
#endif
#if (USBMSDC_OPTION == 2) //Mass Storage Device Class (Bulk-Only)
//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
&& (G_CameraOptions.Storage == K_UIOPTION_STORAGE_MSDC) )
{
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;
}
}
#endif
#if (USBSIDC_OPTION == 1) //Still Image Device Class (PIMA-15740)
//richie@si0417 mark
//if ((G_pCtrlCommand->wIndex == 0x0000) && //value:0
// (G_pCtrlCommand->wValue == 0x0000)) //value:0
//richie@si0417
// if (G_ui_status == K_UI_still_image_class)
if ( ((G_UIStatus & 0xff00) == K_UISTATUS_USBMODE_MASS) //yichang@replace
&& (G_CameraOptions.Storage == K_UIOPTION_STORAGE_SIDC) )
{
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
{
USBSIDC_PostInDataPhase();
G_ucCtrlPhase = K_OutResponsePhase;
}
}
#endif
#if (USBAUDC_OPTION == 1) //Audio Device Class
if ((G_pCtrlCommand->wIndex & 0x000f) == K_AudioControlInterface) //Interface:K_AudioControlInterface
{
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
{
USBAUDC_PostInDataPhase();
G_ucCtrlPhase = K_OutResponsePhase;
}
}
#endif
}
//-----------------------------------------------------------------------------
// CTLIN_VendorRequest
//-----------------------------------------------------------------------------
void CTLIN_VendorRequest(void) USING_1
/*++
Routine Description:
process in packet of vendor 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
{
VNDREQ_PostInDataPhase();
G_ucCtrlPhase = K_OutResponsePhase;
}
}
//-----------------------------------------------------------------------------
//CTLIN_ReservedRequest
//-----------------------------------------------------------------------------
/*++
Routine Description:
process in packet of reserved request
Arguments:
none
Return Value:
none
--*/
void CTLIN_ReservedRequest(void) USING_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
{
RSVREQ_PostInDataPhase();
G_ucCtrlPhase = K_OutResponsePhase;
}
}
//-----------------------------------------------------------------------------
//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 + -