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

📄 ctrlreq.c

📁 SdCard_V2.1TinyFatFs.rar是单片机实现SD卡功能的FAT文件系统
💻 C
📖 第 1 页 / 共 2 页
字号:
            break;
        case GD_CONFIGURATION:
            if (HighSpeed)					//Jason 08/28/2006
            {
				HighSpeedConfigDscr[1] = DSCR_CONFIGURATION;//Kimi 12/19/2006-For chapter9 test!
                GD_ConfigDscr();
            }
            else
            {	
				FullSpeedConfigDscr[1] = DSCR_CONFIGURATION;//Kimi 12/19/2006-For chapter9 test!
                GD_OtherConfigDscr();
            } 
            break;
        case GD_STRING:
            GD_String();
            break;
        case GD_DEVICE_QUALIFIER:
            GD_DeviceQualDscr();
            break;
        case GD_OTHER_SPEED_CONFIGURATION:
            if (!HighSpeed)					//Jason 08/28/2006
            {
				HighSpeedConfigDscr[1] = DSCR_OTHER_SPEED_CONFIGURATION;//Kimi 12/19/2006-For chapter9 test!
                GD_ConfigDscr();
            }
            else   
            {
				FullSpeedConfigDscr[1] = DSCR_OTHER_SPEED_CONFIGURATION;//Kimi 12/19/2006-For chapter9 test!
                GD_OtherConfigDscr();
            }	 
            break;
        default:
            USB_STALL_EP0();
            break;
    }
}
/*$PAGE*/

/*
*********************************************************************************************************
*                                             DR_GETCONFIGURATION
*
* Description: Get configuration
*
* Arguments  : none
*
* Returns    : none
*********************************************************************************************************
*/
void  DR_GetConfiguration (void)
{
    EP0TXCNT    = 1;
    EP0TXDAT    = Configuration;
    EP0TXCS     = EP0TXCS | bmTX0_EN;
}
/*$PAGE*/

/*
*********************************************************************************************************
*                                             DR_SETCONFIGURATION
*
* Description: Set configuration
*
* Arguments  : none
*
* Returns    : none
*********************************************************************************************************
*/
void  DR_SetConfiguration (void)
{
    Configuration   = SetupData[2];
    EP0TXCNT        = 0;
    EP0TXCS         = EP0TXCS | bmTX0_EN;
}
/*$PAGE*/

/*
*********************************************************************************************************
*                                             DR_GETINTERFACE
*
* Description: Get interface
*
* Arguments  : none
*
* Returns    : none
*********************************************************************************************************
*/
void  DR_GetInterface (void)
{
    EP0TXCNT    = 1;                                   // Write data length
    EP0TXDAT    = AlternateSetting;                    // Write data
    EP0TXCS     = EP0TXCS | bmTX0_EN;                  // Enable TX
}
/*$PAGE*/

/*
*********************************************************************************************************
*                                             DR_SETINTERFACE
*
* Description: Set interface
*
* Arguments  : none
*
* Returns    : none
*********************************************************************************************************
*/
void  DR_SetInterface (void)
{
    AlternateSetting    = SetupData[2];
    EP0TXCNT            = 0;
    EP0TXCS             = EP0TXCS | bmTX0_EN;
}
/*$PAGE*/

/*
*********************************************************************************************************
*                                             GD_DEVICEDSCR
*
* Description: Get device descriptor
*
* Arguments  : none
*
* Returns    : none
*********************************************************************************************************
*/
void  GD_DeviceDscr (void)
{
    INT8U   i = 0, count;

    count               = SetupData[6];
    if (count > DSCR_DEVICE_LEN)
    {
        count           = DSCR_DEVICE_LEN;
    }
    /*if (USBFADDR == 0)
    {
        count           = 8;
    }*/
    EP0TXCNT            = count;
    while (count)
    {
        EP0TXDAT        = DeviceDscr[i];
        i++;
        count--;
    }
    EP0TXCS             = EP0TXCS | bmTX0_EN;
    while (EP0TXCS & bmTX0_EN);
}
/*$PAGE*/

/*
*********************************************************************************************************
*                                             GD_DEVICEQUALDSCR
*
* Description: Get device qualifier descriptor
*
* Arguments  : none
*
* Returns    : none
*********************************************************************************************************
*/
void  GD_DeviceQualDscr (void)
{
    INT8U   i = 0, count;

    count               = SetupData[6];
    if (count > DSCR_DEVICE_QUALIFIER_LEN)
    {
        count           = DSCR_DEVICE_QUALIFIER_LEN;
    }
    EP0TXCNT            = count;
    while (count)
    {
        EP0TXDAT        = DeviceQualDscr[i];
        i++;
        count--;
    }
    EP0TXCS             = EP0TXCS | bmTX0_EN;
    while (EP0TXCS & bmTX0_EN);
}
/*$PAGE*/

/*
*********************************************************************************************************
*                                             GD_CONFIGDSCR
*
* Description: Get config descriptor
*
* Arguments  : none
*
* Returns    : none
*********************************************************************************************************
*/
void  GD_ConfigDscr (void)
{
    INT8U   i = 0, count;

    count               = SetupData[6];
    if (count > DSCR_CONFIGURATION_TOTALLEN)
    {
        count           = DSCR_CONFIGURATION_TOTALLEN;
    }
    EP0TXCNT            = count;
    while (count)
    {
        EP0TXDAT        = HighSpeedConfigDscr[i];
        i++;
        count--;
    }
    EP0TXCS             = EP0TXCS | bmTX0_EN;
    while (EP0TXCS & bmTX0_EN);
}
/*$PAGE*/

/*
*********************************************************************************************************
*                                             GD_OTHERCONFIGDSCR
*
* Description: Get other configuration descriptor
*
* Arguments  : none
*
* Returns    : none
*********************************************************************************************************
*/
void  GD_OtherConfigDscr (void)
{
    INT8U   i = 0, count;

    count               = SetupData[6];
    if (count > DSCR_CONFIGURATION_TOTALLEN)
    {
        count           = DSCR_CONFIGURATION_TOTALLEN;
    }
    EP0TXCNT            = count;
    while (count)
    {
        EP0TXDAT        = FullSpeedConfigDscr[i];
        i++;
        count--;
    }
    EP0TXCS             = EP0TXCS | bmTX0_EN;
    while (EP0TXCS & bmTX0_EN);
}
/*$PAGE*/

/*
*********************************************************************************************************
*                                             GD_STRING
*
* Description: Get string
*
* Arguments  : none
*
* Returns    : none
*********************************************************************************************************
*/
void  GD_String (void)
{
    INT8U   i = 0, count;

    count               = SetupData[6];
    switch (SetupData[2])
    {
        case 0:
            if (count > DSCR_STRING0_LEN)
            {
                count   = DSCR_STRING0_LEN;
            }
            EP0TXCNT            = count;
            while (count)
            {
                EP0TXDAT        = StringDscr0[i];
                i++;
                count--;
            }
            break;
        case 1:
            if (count > DSCR_STRING1_LEN)
            {
                count   = DSCR_STRING1_LEN;
            }
            EP0TXCNT            = count;
            while (count)
            {
                EP0TXDAT        = StringDscr1[i];
                i++;
                count--;
            }
            break;
        case 2:
            if (count > DSCR_STRING2_LEN)
            {
                count   = DSCR_STRING2_LEN;
            }
            EP0TXCNT            = count;
            while (count)
            {
                EP0TXDAT        = StringDscr2[i];
                i++;
                count--;
            }
            break;
        case 3:
            if (count > DSCR_STRING3_LEN)
            {
                count   = DSCR_STRING3_LEN;
            }
            EP0TXCNT            = count;
            while (count)
            {
                EP0TXDAT        = StringDscr3[i];
                i++;
                count--;
            }
            break;
        default:
            EP0TXCNT            = 0;
            break;
    }
    EP0TXCS             = EP0TXCS | bmTX0_EN;
    while (EP0TXCS & bmTX0_EN);
}
/*$PAGE*/

⌨️ 快捷键说明

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