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

📄 usb_cpt.c

📁 ST72T63游戏杆源程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/**************** (c) 1998         STMicroelectronics **********************

PROJECT : USB - ST7
COMPILER : ST7 HICROSS C (HIWARE)

MODULE  :  usb_cpt.c
VERSION :  V 1.1

CREATION DATE :  25/05/98

AUTHOR : / MICROCONTROLLER DIVISION / ST Rousset

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

DESCRIPTION : ST7263 USB driver.

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

MODIFICATIONS :
Rev. 1.1 23/09/98
-Added:
#include "usb_cpt.h"

******************************************************************************/

#include <hidef.h>
#include "lib_bits.h"
#include "usb_var.h"                                                                                                            
#include "usr_var.h"
#include "define.h"
#include "descript.h"
#include "usbrc.h"
#include "usb.h"
#include "CondComp.h"
#include "usb_ail.h"
#include "usb_cpt.h"

/*-----------------------------------------------------------------------------
ROUTINE NAME : SetDescriptor
INPUT/OUTPUT : None
DESCRIPTION               : Get the descriptor sent by the Host
-----------------------------------------------------------------------------*/                                         
void SetDescriptor(void)
{
        SetEP0RxStatus(STALL); // Not supported 
}

/*-----------------------------------------------------------------------------
ROUTINE NAME : GetConfiguration
INPUT/OUTPUT : None
DESCRIPTION               : Send the device configuration to the Host
-----------------------------------------------------------------------------*/
void GetConfiguration(void)
{
                TransmitEP0(&ConfigurationValue, 1);
}

/*-----------------------------------------------------------------------------
ROUTINE NAME : SetConfiguration
INPUT/OUTPUT : None
DESCRIPTION               : Get the device configuration sent by the Host
-----------------------------------------------------------------------------*/
void SetConfiguration(void)
{
                                                SetEP0RxStatus(STALL); // STALL if not supported
                                                if ((UsbbmRequestType & RECIPIENT) == REDEVICE)
                                                        if( UsbwValue[0] == 0) // Should valid Address state in spec. 1.1        
                                                        { 
                                                                ConfigurationValue = 0;
                                                                SetEP0RxStatus(VALID); // Set Endpoint0 Rx Valid for next reception
                                                        }
                                                        else     
                                                        if(ConfDescriptor[5] == UsbwValue[0])// Should valid Configure state in spec. 1.1 
                                                        { 
                                                                ConfigurationValue = ConfDescriptor[5];
                                                                SetEP0RxStatus(VALID); // Set Endpoint0 Rx Valid for next reception
                                                        }

}
/*-----------------------------------------------------------------------------
ROUTINE NAME : GetInterface
INPUT/OUTPUT : None
DESCRIPTION               : Send the selected alternate setting for the specified interface
                                                                                                         to the Host
-----------------------------------------------------------------------------*/
void GetInterface(void)                          
{
                                                SetEP0TxStatus(STALL); // STALL if not supported
                                                if ((UsbbmRequestType & RECIPIENT) == REINTERFACE)
                                                        TransmitEP0(&InterfaceValue, 1);
}

/*-----------------------------------------------------------------------------
ROUTINE NAME : SetInterface
INPUT/OUTPUT : None
DESCRIPTION               : Allow the Host to select an alternate setting for the specified interface
-----------------------------------------------------------------------------*/
void SetInterface(void)
{
                                                if ((UsbbmRequestType & RECIPIENT) == REINTERFACE)
                                                                 InterfaceValue = UsbwValue[0];
        SetEP0RxStatus(STALL); // STALL if not alternate interface supported
}

/*-----------------------------------------------------------------------------
ROUTINE NAME : GetStatus
INPUT/OUTPUT : None
DESCRIPTION               : Send the status for the specified recipient
-----------------------------------------------------------------------------*/
void GetStatus(void)
{
                                                if ((UsbbmRequestType & TYPE) == STANDARD)
                                                {
                                                                 if ((UsbbmRequestType & RECIPIENT) == REDEVICE)
                                                                 {                                                                                                                                                                              
                                                                                  {
                                                                                        Endpoint0.Tx[0] = DeviceStatusInfo;
                                                                                        Endpoint0.Tx[1] = 0;
                                                                                        SetEP0TxTbc(2);                                                       
                                                                                        SetEP0TxStatus(VALID);
                                                                                  }
                                                                 }
                                                                 else
                                                                 if ((UsbbmRequestType & RECIPIENT) == REENDPOINT)
                                                                 {                
                                                                                  if (ValBit(UsbwIndex[0], 7))   // IN endpoint
                                                                                  {
                                                                                                if (!ValBit(UsbwIndex[0], 0))    // Endpoint 0 
                                                                                                         {
                                                                                                                Endpoint0.Tx[0] = Endpoint0StatusInfo;
                                                                                                                Endpoint0.Tx[1] = 0;
                                                                                                                SetEP0TxTbc(2);                                                       
                                                                                                                SetEP0TxStatus(VALID);
                                                                                                         }
#ifdef USE_ENDPOINT1_IN
                                                                                                else      
                                                                                                        if (ValBit(UsbwIndex[0], 0)) // Endpoint 1 
                                                                                                                {
                                                                                                                        Endpoint0.Tx[0] = Endpoint1StatusInfo;
                                                                                                                        Endpoint0.Tx[1] = 0;
                                                                                                                        SetEP0TxTbc(2);                                                       
                                                                                                                        SetEP0TxStatus(VALID);
                                                                                                                 }
#endif
#ifdef USE_ENDPOINT2_IN                                                                                                           
                                                                                                        else
                                                                                                                if (ValBit(UsbwIndex[0], 1)) // Endpoint 2 
                                                                                                                        {
                                                                                                                                Endpoint0.Tx[0] = Endpoint2StatusInfo;
                                                                                                                                Endpoint0.Tx[1] = 0;
                                                                                                                                SetEP0TxTbc(2);                                                       
                                                                                                                                SetEP0TxStatus(VALID);
                                                                                                                         }
#endif   
                                                                                  }              

⌨️ 快捷键说明

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