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

📄 usb_cpt.c

📁 ST72T63游戏杆源程序
💻 C
📖 第 1 页 / 共 2 页
字号:
                                                                                  else   // OUT endpoint
                                                                                  {
                                                                                                if (!ValBit(UsbwIndex[0], 0)) // Endpoint 0 
                                                                                                         {
                                                                                                                Endpoint0.Tx[0] = Endpoint0StatusInfo;
                                                                                                                Endpoint0.Tx[1] = 0;
                                                                                                                SetEP0TxTbc(2);                                                       
                                                                                                                SetEP0TxStatus(VALID);
                                                                                                         }
#ifdef USE_ENDPOINT1_OUT                                                                                                         
                                                                                                else      
                                                                                                        if (ValBit(UsbwIndex[0], 0)) // Endpoint 1 
                                                                                                                {
                                                                                                                        Endpoint0.Tx[0] = Endpoint1StatusInfo;
                                                                                                                        Endpoint0.Tx[1] = 0;
                                                                                                                        SetEP0TxTbc(2);                                                       
                                                                                                                        SetEP0TxStatus(VALID);
                                                                                                                 }
#endif
#ifdef USE_ENDPOINT2_OUT
                                                                                                        else
                                                                                                                if (ValBit(UsbwIndex[0], 1)) // Endpoint 2 
                                                                                                                        {
                                                                                                                                Endpoint0.Tx[0] = Endpoint2StatusInfo;
                                                                                                                                Endpoint0.Tx[1] = 0;
                                                                                                                                SetEP0TxTbc(2);                                                       
                                                                                                                                SetEP0TxStatus(VALID);
                                                                                                                         }
#endif                                                                    
                                                                                 }
                                                                 }
                                                }
}

/*-----------------------------------------------------------------------------
ROUTINE NAME : ClearFeature
INPUT/OUTPUT : None
DESCRIPTION               : Clear or disable a specific feature
-----------------------------------------------------------------------------*/
void ClearFeature(void)                                           
{
                                                if (UsbwValue[0] == ENDPOINT_HALT ) //Endpoint_Halt
                                                {
                                                                if (!ValBit(UsbwIndex[0], 0))    // Endpoint 0 addressed
                                                                {
                                                                  if (ValBit(UsbwIndex[0], 7))                                                  
                                                                                  SetEP0TxStatus(VALID); // Set endpoint 0 Tx to VALID                                            
                                                                                else    // Endpoint 1 In                                                                                                                  
                                                                                  SetEP0RxStatus(VALID); // Set endpoint 0 RX to VALID
                                                                                Endpoint0StatusInfo = 0;
                                                                }                                                                
#ifdef USE_ENDPOINT1                                                                      
                                                                else
                                                                        if (ValBit(UsbwIndex[0], 0))    // Endpoint 1 addressed
                                                                        {
#ifdef USE_ENDPOINT1_IN
                                                                                  SetEP1TxStatus(NAK); // Set endpoint 1 Tx to NAK                                                       
#endif 
#ifdef USE_ENDPOINT1_OUT
                                                                                  SetEP1RxStatus(NAK); // Set endpoint 1 RX to NAK
#endif
                                                                                Endpoint1StatusInfo = 0;
                                                                        }
#endif
#ifdef USE_ENDPOINT2
                                                                        else
                                                                        if (ValBit(UsbwIndex[0], 1))    // Endpoint 2 addressed
                                                                        {
#ifdef USE_ENDPOINT2_IN                                                                   
                                                                                  SetEP2TxStatus(NAK); // Set endpoint 2 Tx to NAK 
#endif                                                                                                                                  
#ifdef USE_ENDPOINT2_OUT                                                                                                        
                                                                                  SetEP2RxStatus(NAK); // Set endpoint 2 RX to NAK
#endif
                                                                                Endpoint2StatusInfo = 0;     
                                                                        }
#endif                                                                  
                                                }
                                                else if (UsbwValue[0] == DEVICE_REMOTE_WAKEUP)
                                                                 ClrBit(DeviceStatusInfo, 1); // Disable Remote wake-up capability
}

/*-----------------------------------------------------------------------------
ROUTINE NAME : SetFeature
INPUT/OUTPUT : None
DESCRIPTION               : Set or enable a specific feature
-----------------------------------------------------------------------------*/
void SetFeature(void)
{
                                                if (UsbwValue[0] == ENDPOINT_HALT ) //Endpoint_Halt
                                                {
                                                                if (!ValBit(UsbwIndex[0], 0))    // Endpoint 0 addressed
                                                                {
                                                                  if (ValBit(UsbwIndex[0], 7))                                                  
                                                                                SetEP0TxStatus(STALL); // Set endpoint 0 Tx to STALL                                                    
                                                                  else  // Endpoint 1 In                                                                                                                 
                                                                                SetEP0RxStatus(STALL); // Set endpoint 0 RX to STALL
                                                                  Endpoint0StatusInfo = 1;
                                                                }
#ifdef USE_ENDPOINT1
                                                                else
                                                                        if (ValBit(UsbwIndex[0], 0))    // Endpoint 1 addressed
                                                                        {
#ifdef USE_ENDPOINT1_IN
                                                                                  SetEP1TxStatus(STALL); // Set endpoint 1 Tx to STALL                                            
#endif                                                                          
#ifdef USE_ENDPOINT1_OUT                                                                                                                
                                                                                  SetEP1RxStatus(STALL); // Set endpoint 1 RX to STALL
#endif                                                                            
                                                                                Endpoint1StatusInfo = 1;
                                                                        }
#endif
#ifdef USE_ENDPOINT2
                                                                        else
                                                                        if (ValBit(UsbwIndex[0], 1))    // Endpoint 2 addressed
                                                                        {
#ifdef USE_ENDPOINT2_IN                                                                   
//                                                                                if (ValBit(UsbwIndex[0], 7))                                                  
                                                                                  SetEP2TxStatus(STALL); // Set endpoint 2 Tx to STALL 
#endif                                                                                                                                  
//                                                                                else  // Endpoint 2 Out                                                                                                                 
#ifdef USE_ENDPOINT2_OUT
                                                                                  SetEP2RxStatus(STALL); // Set endpoint 2 RX to STALL
#endif                                                                            
                                                                                Endpoint2StatusInfo = 1;     
                                                                        }
#endif
                                                }
                                                else if (UsbwValue[0] == DEVICE_REMOTE_WAKEUP)
                                                                 SetBit(DeviceStatusInfo, 1); // Enable Remote wake-up capability                                            
}

/*-----------------------------------------------------------------------------
ROUTINE NAME : GetProtocol
INPUT/OUTPUT : None
DESCRIPTION               : Send a protocol to the host
-----------------------------------------------------------------------------*/
void GetProtocol(void)
{
        TransmitEP0(&Protocol, 1);
}

/*-----------------------------------------------------------------------------
ROUTINE NAME : SetProtocol
INPUT/OUTPUT : None
DESCRIPTION               : Set a protocol received from the host
-----------------------------------------------------------------------------*/
void SetProtocol(void)
{
        Protocol = UsbwValue[0];
}


⌨️ 快捷键说明

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