📄 setup.c
字号:
/*******************************************************************/
#include "general.h"
#include "D12.h"
DEVICE_REQUEST DeviceRequest;
//*****************************************************************************
/*++
Routine Description:
process USB Standard Request
Arguments:
none
Return Value:
none
--*/
void CTLSETUP_StandardRequest(void)
{
if(DeviceRequest.bRequest==0x06) // get descriptor
{
if((DeviceRequest.wValue)==0x0100) // device descriptor
{
if(DeviceRequest.wLength>18)
{
#if(MSDC_OPTION == 1)
if(G_bChoose_MSDC == 1)
{
D12_WriteEndpoint(1,8,(UWord16 *)(&MSDC_Device_Descriptor)) ;
}
else
#endif
{
D12_WriteEndpoint(1,8,(UWord16 *)(&USB_Device_Descriptor)) ;
}
}
else
{
#if(MSDC_OPTION == 1)
if(G_bChoose_MSDC == 1)
{
D12_WriteEndpoint(1,18,(UWord16 *)(&MSDC_Device_Descriptor)) ;
}
else
#endif
{
D12_WriteEndpoint(1,18,(UWord16 *)(&USB_Device_Descriptor)) ;
}
}
}
else if(DeviceRequest.wValue==0x0200)//get configuration
{
if(DeviceRequest.wLength<10)
{
#if(MSDC_OPTION == 1)
if(G_bChoose_MSDC == 1)
{
D12_WriteEndpoint(1,(DeviceRequest.wLength),(UWord16 *)(&MSDC_CONFIGURATION_DESCRIPTOR)) ;
}
else
#endif
{
D12_WriteEndpoint(1,(DeviceRequest.wLength),(UWord16 *)(&USB_CONFIGURATION_DESCRIPTOR)) ;
}
}
else
{
#if(MSDC_OPTION == 1)
if(G_bChoose_MSDC == 1)
{
D12_WriteEndpoint(1,39,(UWord16 *)(&MSDC_CONFIGURATION_DESCRIPTOR)) ;
}
else
#endif
{
D12_WriteEndpoint(1,46,(UWord16 *)(&USB_CONFIGURATION_DESCRIPTOR)) ;
}
}
}
}
else if(DeviceRequest.bRequest==0x05) // set address
{
D12_SetAddressEnable((DeviceRequest.wValue), 1);
D12_WriteEndpoint(1,0,0);
}
else if(DeviceRequest.bRequest==0x09) // set configuration
{
D12_WriteEndpoint(1,0,0);
if(DeviceRequest.wValue==0x01)
{
D12_SetEndpointEnable(0); //disable the endpoint
D12_SetEndpointEnable(1); //enable the endpoint
}
}
else if(DeviceRequest.bRequest==0x0b) // set interface
{
D12_WriteEndpoint(1,0,0);
}
// standard request
}
//*****************************************************************************
/*++
Routine Description:
process USB Class Request
Arguments:
none
Return Value:
none
--*/
void CTLSETUP_ClassRequest(void) // get max lun
{
#if(MSDC_OPTION == 1)
if(DeviceRequest.bmRequestType == 0x0a1)
{
D12_WriteEndpoint(1,1,USB_Device_Descriptor+5); //0 length logic unit
}
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -