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

📄 cp2200.lst

📁 c8051f020_uip1.0.rar
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V9.00   CP2200                                                                02/08/2010 20:58:32 PAGE 1   


C51 COMPILER V9.00, COMPILATION OF MODULE CP2200
OBJECT MODULE PLACED IN .\cp2200.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\cp2200\cp2200.c LARGE BROWSE INCDIR(..\uip1.0\apps;..\uip1.0\uip;..\cp22
                    -00;..\cp2200;..\uip1.0\apps\dhcpc;..\uip1.0\apps\httpd) DEBUG OBJECTEXTEND PRINT(.\cp2200.lst) OBJECT(.\cp2200.obj)

line level    source

   1          #include "main.h"
   2          #include "cp220x_reg.h"
   3          
   4          
   5          
   6          u8_t xdata my_hwaddr[6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};  
   7          MACADDRESS xdata MYMAC;
   8          #define LINK_ERROR  0x20
   9          /*******************************************************************************/
  10                              
  11          void CP220x_RST_Low(void)                        
  12          {
  13   1         P4 &= ~0x20;                        // Set P4.5 Low      
  14   1      }
  15          
  16          void CP220x_RST_High(void)
  17          {
  18   1         P4 |= 0x20;     
  19   1                                            // Set P4.5 High      
  20   1      }
  21          /******************************************************************************
  22          **物理层
  23          ******************************************************************************/             
  24          u8_t PHY_Init()                     
  25          {
  26   1         u8_t temp_char;
  27   1         u8_t retval =LINK_ERROR;
  28   1                          
  29   1      //自适应同步       
  30   1                               
  31   1         //--------------------------------------------------------------------------
  32   1         // Auto-Negotiation Synchronization (Section 15.2 of CP220x Datasheet)                         
  33   1         //--------------------------------------------------------------------------
  34   1      
  35   1         // Step 1: Disable the PHY   
  36   1               
  37   1           PHYCN = 0x00;  
  38   1         
  39   1         // Step 2: Enable the PHY with link integrity test and auto-negotiation 
  40   1         // turned off           
  41   1            
  42   1            // A. Disable the Transmitter Power Save Option and Configure Options                        
  43   1            TXPWR = 0x80;
  44   1            PHYCF = ( SMSQ | JABBER | ADPAUSE | AUTOPOL );
  45   1      
  46   1            // B. Enable the Physical Layer       
  47   1            PHYCN = PHYEN;
  48   1            Delay1ms(50);     
  49   1      
  50   1         
  51   1            // C. Wait for the physical layer to power up                 
  52   1            // wait_ms(10);
  53   1      
  54   1            // D. Enable the Transmitter and Receiver             
C51 COMPILER V9.00   CP2200                                                                02/08/2010 20:58:32 PAGE 2   

  55   1            PHYCN = ( PHYEN | TXEN | RXEN );
  56   1         
  57   1            // Step 3: Poll the Wake-on-Lan Interrupt    
  58   1            Delay1ms(50);             //200--50
  59   1       
  60   1            // A. Clear Interrupt Flags          
  61   1            temp_char = INT1;
  62   1      
  63   1            // B. Start a new timeout for 1.5 seconds            
  64   1            // reset_timeout(ONE_SECOND+ONE_SECOND/2);                    
  65   1            
  66   1            // C. Check for a signal             
  67   1           
  68   1            // If no signal is deteced, wait 1.5s, then continue                
  69   1            // if(timeout_expired())
  70   1            // {               
  71   1            //   break;
  72   1            // }               
  73   1      
  74   1           
  75   1                                 
  76   1         //--------------------------------------------------------------------------
  77   1         // Physical Layer Initialization (Section 15.7 of CP220x Datasheet)                   
  78   1         //--------------------------------------------------------------------------
  79   1         
  80   1         // Step 1: Synchronization procedure implemented above                  
  81   1                                                                                                                                        
  82   1         // Step 2: Disable the physical layer                    
  83   1         PHYCN = 0x00; 
  84   1        
  85   1         // Step 3: Configure the desired physical layer options including 
  86   1         // auto-negotiation and link integrity           
  87   1         PHYCF = ( SMSQ | LINKINTG | JABBER | AUTONEG | ADPAUSE | AUTOPOL );
  88   1        
  89   1         // Step 4: Enable the physcial layer          
  90   1            
  91   1            // A. Enable the Physical Layer            
  92   1            PHYCN = PHYEN;
  93   1            Delay1ms(50);     
  94   1        
  95   1            // B. Wait for the physical layer to power up                 
  96   1            // wait_ms(10);
  97   1      
  98   1            // C. Enable the Transmitter and Receiver             
  99   1            // Auto-negotiation begins now       
 100   1            PHYCN = ( PHYEN | TXEN | RXEN );
 101   1        
 102   1      
 103   1            // Step 5: Wait for auto-negotiation to complete              
 104   1      
 105   1            // Clear INT1 Interrupt Flags              
 106   1            temp_char = INT1;
 107   1            Delay1ms(50);      //200--50
 108   1       
 109   1      
 110   1            //RXFILT=0;
 111   1            // Start a six second timeout                 
 112   1            //reset_timeout(6*ONE_SECOND);       
 113   1        
 114   1            // Check for autonegotiation fail or complete flag                 
 115   1                while(1)
 116   1                        {
C51 COMPILER V9.00   CP2200                                                                02/08/2010 20:58:32 PAGE 3   

 117   2                  // If Auto-Negotiation Completes/Fails, break                 
 118   2                  if(INT1RD & (ANCINT | ANFINT))
 119   2                              {                                         
 120   3                     break;            
 121   3                  }
 122   2      
 123   2                }
 124   1      
 125   1      
 126   1            // Mask out all bits except for auto negotiation bits 
 127   1            temp_char = INT1RD;
 128   1            temp_char &= (ANCINT | ANFINT);
 129   1      
 130   1            // Check if Auto-Negotiation has FAILED 
 131   1            if(temp_char & ANFINT)
 132   1                {
 133   2               // Auto-Negotiation has failed           
 134   2               retval = LINK_ERROR;
 135   2            }
 136   1      
 137   1                else  if(temp_char == ANCINT)
 138   1                {
 139   2               // Check if Auto-Negotiation has PASSED   
 140   2      
 141   2               // Auto-Negotiation has passed          
 142   2               retval = 0;
 143   2               // Enable Link LED and Activity LED                         
 144   2               IOPWR = 0x0C;   
 145   2            } 
 146   1                
 147   1                else 
 148   1            // Timeout Occured.   
 149   1            { 
 150   2                // Timeout    
 151   2               retval = LINK_ERROR; 
 152   2            }
 153   1      
 154   1            return retval;
 155   1           
 156   1      }
 157          /*---------------------------------------------------------------------------*/                   
 158          void MAC_Init(void)
 159          {  
 160   1      
 161   1         // Check the duplex mode and perform duplex-mode specific initializations               
 162   1         if(PHYCN & 0x10){
 163   2            
 164   2            // The device is in full-duplex mode, configure MAC registers                       
 165   2            // Padding is turned on.     
 166   2            MAC_Write(MACCF, 0x40B3);   
 167   2            MAC_Write(IPGT, 0x0015);
 168   2            
 169   2         } else {
 170   2      
 171   2            // The device is in half-duplex mode, configure MAC registers                       
 172   2            // Padding is turned off.     
 173   2            MAC_Write(MACCF, 0x4012);
 174   2            MAC_Write(IPGT, 0x0012);
 175   2      
 176   2         }
 177   1      
 178   1         // Configure the IPGR register          
C51 COMPILER V9.00   CP2200                                                                02/08/2010 20:58:32 PAGE 4   

 179   1         MAC_Write(IPGR, 0x0C12);
 180   1      
 181   1         // Configure the MAXLEN register to 1518 bytes                
 182   1         MAC_Write(MAXLEN, 0x05EE);
 183   1      
 184   1         // Copy MAC Address Stored in Flash to MYMAC            
 185   1         FLASHADDRH = 0x1F;
 186   1         FLASHADDRL = 0xFA;
 187   1      
 188   1         MYMAC.Char[0] = FLASHAUTORD;
 189   1         MYMAC.Char[1] = FLASHAUTORD;
 190   1         MYMAC.Char[2] = FLASHAUTORD;
 191   1         MYMAC.Char[3] = FLASHAUTORD;
 192   1         MYMAC.Char[4] = FLASHAUTORD;
 193   1         MYMAC.Char[5] = FLASHAUTORD;      
 194   1         my_hwaddr[0]=MYMAC.Char[0];    
 195   1         my_hwaddr[1]=MYMAC.Char[1];
 196   1         my_hwaddr[2]=MYMAC.Char[2];
 197   1         my_hwaddr[3]=MYMAC.Char[3];
 198   1         my_hwaddr[4]=MYMAC.Char[4];
 199   1         my_hwaddr[5]=MYMAC.Char[5];
 200   1         // Program the MAC address      
 201   1         MAC_SetAddress(&MYMAC); 
 202   1      
 203   1         // Enable Reception and configure Loopback mode                 
 204   1         MAC_Write(MACCN, 0x0001);           // Enable Reception without loopback              
 205   1                                                                                                                                                                       
 206   1      }
 207          
 208          void MAC_Write(u8_t mac_reg_offset, u16_t mac_reg_data)
 209          {
 210   1      
 211   1         // Step 1: Write the address of the indirect register to MACADDR.              
 212   1         MACADDR = mac_reg_offset;              
 213   1      
 214   1         // Step 2: Copy the contents of <mac_reg_data> to MACDATAH:MACDATAL              
 215   1         MACDATAH = (mac_reg_data >> 8);    // Copy High Byte    
 216   1         MACDATAL = (mac_reg_data & 0xFF);  // Copy Low Byte   
 217   1      
 218   1         // Step 3: Perform a write on MACRW to transfer the contents of MACDATAH:MACDATAL                     
 219   1         // to the indirect MAC register.              
 220   1         MACRW = 0;
 221   1         
 222   1         return;
 223   1      }
 224          
 225          
 226          /*****************************************************************************
 227           MAC_SetAddress         
 228          
 229           Return Value : None      
 230           Parameters   : 
 231             1)  MACADDRESS* pMAC - pointer to a 6-byte MAC address structure.                     
 232           
 233           Sets the current MAC address to the MAC address pointed to by <pMAC>.             
 234          *****************************************************************************/
 235          void MAC_SetAddress(MACADDRESS* pMAC)
 236          {
 237   1         UINT1 temp_int;
 238   1      
 239   1         temp_int.Char[0] = pMAC->Char[5];
 240   1         temp_int.Char[1] = pMAC->Char[4];

⌨️ 快捷键说明

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