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

📄 usb9.i

📁 使用PIC芯片通过SPI-MODE读写SD存储卡,通过测试.
💻 I
📖 第 1 页 / 共 4 页
字号:
    struct
    {
        byte _byte[8 ];
    };
    
     
    struct
    {
        byte _byte0;
        byte _byte1;
        byte _byte2;
        byte _byte3;
        byte _byte4;
        byte _byte5;
        byte _byte6;
        byte _byte7;
    };
    struct
    {
        word _word0;
        word _word1;
        word _word2;
        word _word3;
    };

} CTRL_TRF_DATA;

#line 210 "./system\usb\usbdefs\usbdefs_ep0_buff.h"
#line 51 "./system\usb\usb.h"

#line 1 "./system\usb\usbmmap.h"

#line 35 "./system\usb\usbmmap.h"
 


#line 39 "./system\usb\usbmmap.h"

 
#line 1 "./system\typedefs.h"

#line 35 "./system\typedefs.h"
 

#line 156 "./system\typedefs.h"
#line 41 "./system\usb\usbmmap.h"


 

 
#line 47 "./system\usb\usbmmap.h"
#line 48 "./system\usb\usbmmap.h"
#line 49 "./system\usb\usbmmap.h"
#line 50 "./system\usb\usbmmap.h"
#line 51 "./system\usb\usbmmap.h"
#line 52 "./system\usb\usbmmap.h"
#line 53 "./system\usb\usbmmap.h"
#line 54 "./system\usb\usbmmap.h"
#line 55 "./system\usb\usbmmap.h"

 
#line 58 "./system\usb\usbmmap.h"
#line 59 "./system\usb\usbmmap.h"
#line 60 "./system\usb\usbmmap.h"
#line 61 "./system\usb\usbmmap.h"
#line 62 "./system\usb\usbmmap.h"
#line 63 "./system\usb\usbmmap.h"
#line 64 "./system\usb\usbmmap.h"

 
#line 67 "./system\usb\usbmmap.h"
#line 68 "./system\usb\usbmmap.h"

 
typedef union _USB_DEVICE_STATUS
{
    byte _byte;
    struct
    {
        unsigned RemoteWakeup:1;
        unsigned ctrl_trf_mem:1;
    };
} USB_DEVICE_STATUS;

typedef union _BD_STAT
{
    byte _byte;
    struct{
        unsigned BC8:1;
        unsigned BC9:1;
        unsigned BSTALL:1;              
        unsigned DTSEN:1;               
        unsigned INCDIS:1;              
        unsigned KEN:1;                 
        unsigned DTS:1;                 
        unsigned UOWN:1;                
    };
    struct{
        unsigned BC8:1;
        unsigned BC9:1;
        unsigned PID0:1;
        unsigned PID1:1;
        unsigned PID2:1;
        unsigned PID3:1;
        unsigned :1;
        unsigned UOWN:1;
    };
    struct{
        unsigned :2;
        unsigned PID:4;                 
        unsigned :2;
    };
} BD_STAT;                              

typedef union _BDT
{
    struct
    {
        BD_STAT Stat;
        byte Cnt;
        byte ADRL;                      
        byte ADRH;                      
    };
    struct
    {
        unsigned :8;
        unsigned :8;
        byte* ADR;                      
    };
} BDT;                                  

 
extern byte usb_device_state;
extern USB_DEVICE_STATUS usb_stat;
extern byte usb_active_cfg;
extern byte usb_alt_intf[1 ];

extern volatile far BDT ep0Bo;          
extern volatile far BDT ep0Bi;          
extern volatile far BDT ep1Bo;          
extern volatile far BDT ep1Bi;          
extern volatile far BDT ep2Bo;          
extern volatile far BDT ep2Bi;          
extern volatile far BDT ep3Bo;          
extern volatile far BDT ep3Bi;          
extern volatile far BDT ep4Bo;          
extern volatile far BDT ep4Bi;          
extern volatile far BDT ep5Bo;          
extern volatile far BDT ep5Bi;          
extern volatile far BDT ep6Bo;          
extern volatile far BDT ep6Bi;          
extern volatile far BDT ep7Bo;          
extern volatile far BDT ep7Bi;          
extern volatile far BDT ep8Bo;          
extern volatile far BDT ep8Bi;          
extern volatile far BDT ep9Bo;          
extern volatile far BDT ep9Bi;          
extern volatile far BDT ep10Bo;         
extern volatile far BDT ep10Bi;         
extern volatile far BDT ep11Bo;         
extern volatile far BDT ep11Bi;         
extern volatile far BDT ep12Bo;         
extern volatile far BDT ep12Bi;         
extern volatile far BDT ep13Bo;         
extern volatile far BDT ep13Bi;         
extern volatile far BDT ep14Bo;         
extern volatile far BDT ep14Bi;         
extern volatile far BDT ep15Bo;         
extern volatile far BDT ep15Bi;         

extern volatile far CTRL_TRF_SETUP SetupPkt;
extern volatile far CTRL_TRF_DATA CtrlTrfData;

#line 173 "./system\usb\usbmmap.h"
 
#line 175 "./system\usb\usbmmap.h"
extern volatile far unsigned char msd_report_out[64 ];
extern volatile far unsigned char msd_report_in[64 ]; 
#line 178 "./system\usb\usbmmap.h"

#line 180 "./system\usb\usbmmap.h"
#line 52 "./system\usb\usb.h"


#line 1 "./system\usb\usbdrv\usbdrv.h"

#line 35 "./system\usb\usbdrv\usbdrv.h"
 


#line 39 "./system\usb\usbdrv\usbdrv.h"

 
#line 1 "./system\typedefs.h"

#line 35 "./system\typedefs.h"
 

#line 156 "./system\typedefs.h"
#line 41 "./system\usb\usbdrv\usbdrv.h"

#line 1 "./system\usb\usb.h"

#line 35 "./system\usb\usb.h"
 

#line 45 "./system\usb\usb.h"
#line 59 "./system\usb\usb.h"
#line 61 "./system\usb\usb.h"
#line 62 "./system\usb\usb.h"
#line 64 "./system\usb\usb.h"
#line 65 "./system\usb\usb.h"
#line 42 "./system\usb\usbdrv\usbdrv.h"


 

 
#line 48 "./system\usb\usbdrv\usbdrv.h"
#line 49 "./system\usb\usbdrv\usbdrv.h"
#line 50 "./system\usb\usbdrv\usbdrv.h"
#line 51 "./system\usb\usbdrv\usbdrv.h"
#line 52 "./system\usb\usbdrv\usbdrv.h"
#line 53 "./system\usb\usbdrv\usbdrv.h"
#line 54 "./system\usb\usbdrv\usbdrv.h"
#line 55 "./system\usb\usbdrv\usbdrv.h"
#line 56 "./system\usb\usbdrv\usbdrv.h"
#line 57 "./system\usb\usbdrv\usbdrv.h"

 
#line 60 "./system\usb\usbdrv\usbdrv.h"
#line 61 "./system\usb\usbdrv\usbdrv.h"
#line 62 "./system\usb\usbdrv\usbdrv.h"
#line 63 "./system\usb\usbdrv\usbdrv.h"
#line 64 "./system\usb\usbdrv\usbdrv.h"
                                    


#line 74 "./system\usb\usbdrv\usbdrv.h"
 
#line 76 "./system\usb\usbdrv\usbdrv.h"
#line 77 "./system\usb\usbdrv\usbdrv.h"

#line 79 "./system\usb\usbdrv\usbdrv.h"
#line 80 "./system\usb\usbdrv\usbdrv.h"

#line 82 "./system\usb\usbdrv\usbdrv.h"
#line 83 "./system\usb\usbdrv\usbdrv.h"
#line 84 "./system\usb\usbdrv\usbdrv.h"
#line 85 "./system\usb\usbdrv\usbdrv.h"
#line 86 "./system\usb\usbdrv\usbdrv.h"
#line 87 "./system\usb\usbdrv\usbdrv.h"
#line 88 "./system\usb\usbdrv\usbdrv.h"
#line 89 "./system\usb\usbdrv\usbdrv.h"
#line 90 "./system\usb\usbdrv\usbdrv.h"
#line 91 "./system\usb\usbdrv\usbdrv.h"
#line 92 "./system\usb\usbdrv\usbdrv.h"
#line 93 "./system\usb\usbdrv\usbdrv.h"
#line 94 "./system\usb\usbdrv\usbdrv.h"
#line 95 "./system\usb\usbdrv\usbdrv.h"
#line 96 "./system\usb\usbdrv\usbdrv.h"
#line 97 "./system\usb\usbdrv\usbdrv.h"
#line 98 "./system\usb\usbdrv\usbdrv.h"
#line 99 "./system\usb\usbdrv\usbdrv.h"
#line 100 "./system\usb\usbdrv\usbdrv.h"
#line 101 "./system\usb\usbdrv\usbdrv.h"
#line 102 "./system\usb\usbdrv\usbdrv.h"
#line 103 "./system\usb\usbdrv\usbdrv.h"
#line 104 "./system\usb\usbdrv\usbdrv.h"
#line 105 "./system\usb\usbdrv\usbdrv.h"
#line 106 "./system\usb\usbdrv\usbdrv.h"
#line 107 "./system\usb\usbdrv\usbdrv.h"
#line 108 "./system\usb\usbdrv\usbdrv.h"
#line 109 "./system\usb\usbdrv\usbdrv.h"
#line 110 "./system\usb\usbdrv\usbdrv.h"
#line 111 "./system\usb\usbdrv\usbdrv.h"
#line 112 "./system\usb\usbdrv\usbdrv.h"
#line 113 "./system\usb\usbdrv\usbdrv.h"


#line 134 "./system\usb\usbdrv\usbdrv.h"
 

#line 139 "./system\usb\usbdrv\usbdrv.h"
#line 140 "./system\usb\usbdrv\usbdrv.h"


#line 157 "./system\usb\usbdrv\usbdrv.h"
 
#line 159 "./system\usb\usbdrv\usbdrv.h"

#line 163 "./system\usb\usbdrv\usbdrv.h"

#line 164 "./system\usb\usbdrv\usbdrv.h"
 


#line 188 "./system\usb\usbdrv\usbdrv.h"
 

#line 194 "./system\usb\usbdrv\usbdrv.h"
#line 195 "./system\usb\usbdrv\usbdrv.h"

 

 

 
void USBCheckBusStatus(void);
void USBDriverService(void);
void USBRemoteWakeup(void);
void USBSoftDetach(void); 

void ClearArray(byte* startAdr,byte count);
#line 208 "./system\usb\usbdrv\usbdrv.h"
#line 54 "./system\usb\usb.h"




#line 59 "./system\usb\usb.h"
#line 61 "./system\usb\usb.h"
#line 62 "./system\usb\usb.h"

#line 64 "./system\usb\usb.h"
#line 65 "./system\usb\usb.h"
#line 40 "usb9.c"

#line 1 "./io_cfg.h"

#line 35 "./io_cfg.h"
 


#line 39 "./io_cfg.h"

 
#line 1 "./autofiles\usbcfg.h"

#line 32 "./autofiles\usbcfg.h"
 


#line 55 "./autofiles\usbcfg.h"

#line 65 "./autofiles\usbcfg.h"

#line 87 "./autofiles\usbcfg.h"

#line 94 "./autofiles\usbcfg.h"

#line 101 "./autofiles\usbcfg.h"

#line 107 "./autofiles\usbcfg.h"

#line 108 "./autofiles\usbcfg.h"
#line 113 "./autofiles\usbcfg.h"
#line 41 "./io_cfg.h"


 
#line 45 "./io_cfg.h"
#line 46 "./io_cfg.h"

 
#line 49 "./io_cfg.h"

#line 51 "./io_cfg.h"
#line 52 "./io_cfg.h"
#line 53 "./io_cfg.h"
#line 55 "./io_cfg.h"

#line 57 "./io_cfg.h"

#line 59 "./io_cfg.h"
#line 60 "./io_cfg.h"
#line 61 "./io_cfg.h"
#line 63 "./io_cfg.h"


#line 66 "./io_cfg.h"
#line 67 "./io_cfg.h"
#line 68 "./io_cfg.h"
#line 69 "./io_cfg.h"
#line 70 "./io_cfg.h"
#line 71 "./io_cfg.h"

#line 73 "./io_cfg.h"

 
#line 76 "./io_cfg.h"

#line 78 "./io_cfg.h"
#line 79 "./io_cfg.h"
#line 80 "./io_cfg.h"
#line 81 "./io_cfg.h"

#line 83 "./io_cfg.h"
#line 84 "./io_cfg.h"
#line 85 "./io_cfg.h"
#line 86 "./io_cfg.h"

#line 88 "./io_cfg.h"
#line 89 "./io_cfg.h"
#line 90 "./io_cfg.h"
#line 91 "./io_cfg.h"

#line 93 "./io_cfg.h"
#line 94 "./io_cfg.h"
#line 95 "./io_cfg.h"
#line 96 "./io_cfg.h"

 
#line 99 "./io_cfg.h"
#line 100 "./io_cfg.h"
#line 101 "./io_cfg.h"
#line 102 "./io_cfg.h"
#line 103 "./io_cfg.h"

 
#line 106 "./io_cfg.h"

 
#line 109 "./io_cfg.h"
#line 110 "./io_cfg.h"

#line 112 "./io_cfg.h"
#line 113 "./io_cfg.h"

 
#line 116 "./io_cfg.h"
#line 117 "./io_cfg.h"

#line 119 "./io_cfg.h"
#line 120 "./io_cfg.h"

#line 122 "./io_cfg.h"
#line 41 "usb9.c"
                     

 
#pragma udata

 
void USBStdGetDscHandler(void);
void USBStdSetCfgHandler(void);
void USBStdGetStatusHandler(void);
void USBStdFeatureReqHandler(void);

 
#pragma code

#line 69 "usb9.c"
 
void USBCheckStdRequest(void)
{   
    if(SetupPkt.RequestType != STANDARD) return;
    
    switch(SetupPkt.bRequest)
    {
        case SET_ADR:
            ctrl_trf_session_owner = 1 ;
            usb_device_state = 4 ;       
             
            break;
        case GET_DSC:
            USBStdGetDscHandler();
            break;
        case SET_CFG:
            USBStdSetCfgHandler();
            break;
        case GET_CFG:
            ctrl_trf_session_owner = 1 ;
            pSrc.bRam = (byte*)&usb_active_cfg;         
            usb_stat.ctrl_trf_mem = 0 ;               
            ((wCount).v[0])  = 1;                            
            break;
        case GET_STATUS:
            USBStdGetStatusHandler();
            break;
        case CLR_FEATURE:
        case SET_FEATURE:
            USBStdFeatureReqHandler();
            break;
        case GET_INTF:
            ctrl_trf_session_owner = 1 ;
            pSrc.bRam = (byte*)&usb_alt_intf+SetupPkt.bIntfID;  
            usb_stat.ctrl_trf_mem = 0 ;               
            ((wCount).v[0])  = 1;                            
            break;
        case SET_INTF:
            ctrl_trf_session_owner = 1 ;
            usb_alt_intf[SetupPkt.bIntfID] = SetupPkt.bAltID;
            break;
        case SET_DSC:
        case SYNCH_FRAME:
        default:
            break;
    }
    
}


#line 135 "usb9.c"
 
void USBStdGetDscHandler(void)
{
    if(SetupPkt.bmRequestType == 0x80)
    {
        switch(SetupPkt.bDscType)
        {
            case 0x01 :
                ctrl_trf_session_owner = 1 ;
                pSrc.bRom = (rom byte*)&device_dsc;
                wCount._word = sizeof(device_dsc);          
                break;
            case 0x02 :
                ctrl_trf_session_owner = 1 ;
                pSrc.bRom = *(USB_CD_Ptr+SetupPkt.bDscIndex);
                wCount._word = *(pSrc.wRom+1);              
                break;
            case 0x03 :
                ctrl_trf_session_owner = 1 ;
                pSrc.bRom = *(USB_SD_Ptr+SetupPkt.bDscIndex);
                wCount._word = *pSrc.bRom;                  
                break;
        }
        
        usb_stat.ctrl_trf_mem = 1 ;                       
    }
}


#line 179 "usb9.c"
 
void USBStdSetCfgHandler(void)
{
    ctrl_trf_session_owner = 1 ;
    ClearArray((byte*)&UEP1,15); ;                          
    ClearArray((byte*)&usb_alt_intf,1 );
    usb_active_cfg = SetupPkt.bCfgValue;
    if(SetupPkt.bCfgValue == 0)
        usb_device_state = 5 ;
    else
    {
        usb_device_state = 6 ;

         
        
#line 195 "usb9.c"
#line 197 "usb9.c"
        
         

    }
}


#line 217 "usb9.c"
 
void USBStdGetStatusHandler(void)
{
    CtrlTrfData._byte0 = 0;                         
    CtrlTrfData._byte1 = 0;
        
    switch(SetupPkt.Recipient)
    {
        case RCPT_DEV:
            ctrl_trf_session_owner = 1 ;
            
#line 230 "usb9.c"
 
            if(PORTAbits.RA2  == 1)                     
                CtrlTrfData._byte0|=0b000000001;    
            
            if(usb_stat.RemoteWakeup == 1)          
                CtrlTrfData._byte0|=0b00000010;     
            break;
        case RCPT_INTF:
            ctrl_trf_session_owner = 1 ;     
            break;
        case RCPT_EP:
            ctrl_trf_session_owner = 1 ;
            
#line 244 "usb9.c"
 
            pDst.bRam = (byte*)&ep0Bo+(SetupPkt.EPNum*8)+(SetupPkt.EPDir*4);
            if(*pDst.bRam & 0x04 )    
                CtrlTrfData._byte0=0x01;
            break;
    }
    
    if(ctrl_trf_session_owner == 1 )
    {
        pSrc.bRam = (byte*)&CtrlTrfData;            
        usb_stat.ctrl_trf_mem = 0 ;               
        ((wCount).v[0])  = 2;                            
    }
}


#line 274 "usb9.c"
 
void USBStdFeatureReqHandler(void)
{
    if((SetupPkt.bFeature == DEVICE_REMOTE_WAKEUP)&&
       (SetupPkt.Recipient == RCPT_DEV))
    {
        ctrl_trf_session_owner = 1 ;
        if(SetupPkt.bRequest == SET_FEATURE)
            usb_stat.RemoteWakeup = 1;
        else
            usb_stat.RemoteWakeup = 0;
    }
    
    if((SetupPkt.bFeature == ENDPOINT_HALT)&&
       (SetupPkt.Recipient == RCPT_EP)&&
       (SetupPkt.EPNum != 0))
    {
        ctrl_trf_session_owner = 1 ;
         
        pDst.bRam = (byte*)&ep0Bo+(SetupPkt.EPNum*8)+(SetupPkt.EPDir*4);
        
        if(SetupPkt.bRequest == SET_FEATURE)
            *pDst.bRam = 0x80 |0x04 ;
        else
        {
            if(SetupPkt.EPDir == 1) 
                *pDst.bRam = 0x00 ;
            else
                *pDst.bRam = 0x80 |0x00 |0x08 ;
        }
    }
}

 

⌨️ 快捷键说明

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