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

📄 main.lst

📁 硬件是8051f340+cp2200。插上网线
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.08   MAIN                                                                  04/24/2008 18:17:35 PAGE 1   


C51 COMPILER V8.08, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c LARGE BROWSE DEBUG OBJECTEXTEND

line level    source

   1          //------------------------------------------------------------------------------
   2          // main.c
   3          //------------------------------------------------------------------------------
   4          // Copyright (C) 2005 Silicon Laboratories, Inc.
   5          //
   6          // Date: 05/19/06 09:38:45
   7          // Target: C8051F34x 
   8          //
   9          // Description:
  10          //    This file contains the main routine, MCU initialization code, and
  11          //    callback functions used by the TCP/IP Library.
  12          //
  13          // Generated by TCP/IP Configuration Wizard Version 3
  14          //
  15          #include "mn_userconst.h"                      // TCP/IP Library Constants
  16          #include "mn_stackconst.h"                     // TCP/IP Library Constants
  17          #include "mn_errs.h"                           // Library Error Codes
  18          #include "mn_defs.h"                           // Library Type definitions
  19          #include "mn_funcs.h"                          // Library Function Prototypes
  20          #include "VFILE_DIR\index.h"
  21          #include <string.h>                    // Standard 'C' Libraries
  22          #include <intrins.h>
  23          #include <stdio.h>
  24          #include <ctype.h> 
  25          #include <c8051F340.h>                         // Device-specific SFR Definitions
  26          #include "CP2200DK.H"
  27          
  28          
  29          
  30          //------------------------------------------------------------------------------
  31          // Function Prototypes
  32          //------------------------------------------------------------------------------
  33           sbit LED1=P2^4;
  34          // Initialization Routines
  35          void PORT_web (void);
  36          void SYSCLK_Init (void);
  37          void EMIF_Init(void);
  38          int establish_network_connection();
  39          void add();
  40          void Timer2_Init(void);
  41          void get_data (PSOCKET_INFO socket_ptr);
  42          void DelayMs(unsigned int n);//延时(n)MS
  43          
  44          void SysClkInit(void);//配置系统时钟
  45          void SystemInit(void);//系统配置
  46          void Port_Uart(void);//端口配置 
  47          void Port_com(void);
  48          
  49          bit_word16  num_buff[4]={10,20,30,40};
  50          unsigned char HTML_BUFFER[500];
  51          unsigned char num1;
  52          //-----------------------------------------------------------------------------
  53          // 16-bit SFR Definitions for 'F34x
  54          //-----------------------------------------------------------------------------
  55          sfr16 TMR2RL   = 0xca;                    // Timer2 reload value
C51 COMPILER V8.08   MAIN                                                                  04/24/2008 18:17:35 PAGE 2   

  56          sfr16 TMR2     = 0xcc;                    // Timer2 counter
  57          sfr16 ADC0     = 0xbd;                    // ADC0 data register
  58          
  59          //------------------------------------------------------------------------------
  60          // Global Constants
  61          //------------------------------------------------------------------------------
  62          #define SYSCLK                  48000000L      // System Clock Frequency in Hz
  63          #define T2_OVERFLOW_RATE        80L            // Timer 2 Overflow Rate in Hz
  64          
  65          //-----------------------------------------------------------------------------
  66          // Main Routine
  67          //-----------------------------------------------------------------------------
  68          void main(void)
  69          {
  70   1         //unsigned char KeyBuff;
  71   1         // Disable watchdog timer
  72   1         //   PCA0MD&=~0x40;//禁止看门狗定时器
  73   1          PCA0MD = 0x00;
  74   1         // Initialize the MCU
  75   1         
  76   1         Timer2_Init();
  77   1                      Port_com();  
  78   1                
  79   1              SystemInit();//系统配置
  80   1              SysClkInit();//配置系统时钟
  81   1               Port_Uart();//端口配置
  82   1              Uart0Init();//串口初始化
  83   1              Uart0SendString("OK\n",3);
  84   1              
  85   1          PORT_web();
  86   1              SYSCLK_Init();
  87   1          EMIF_Init();
  88   1              
  89   1              Timer2_Init();
  90   1              Uart0SendString("KEY1\n",5);   
  91   1      
  92   1         while(1)
  93   1         { 
  94   2            // Initialize the TCP/IP stack.
  95   2            if (mn_init() < 0)
  96   2            {
  97   3               // If code execution enters this while(1) loop, the stack failed to initialize.
  98   3               // Verify that all boards are connected and powered properly.
  99   3               while(1);
 100   3            }
 101   2            
 102   2            // Connect to the network
 103   2            establish_network_connection();
 104   2      
 105   2            // Add web page to virtual file system.
 106   2            // The main page MUST be called index.htm or index.html.
 107   2            mn_vf_set_entry((byte *)"index.html", INDEX_SIZE, index_html, VF_PTYPE_FLASH);
 108   2            
 109   2                // Add CGI Script to Virtual File System         
 110   2            mn_pf_set_entry
 111   2            (
 112   2              (byte*)"get_data",                   // Script Name (ASCII)
 113   2              get_data                                      // Function Pointer
 114   2            );
 115   2            
 116   2            mn_server();
 117   2           
C51 COMPILER V8.08   MAIN                                                                  04/24/2008 18:17:35 PAGE 3   

 118   2            //add(); 
 119   2         }
 120   1         
 121   1      }
 122          
 123          //-----------------------------------------------------------------------------
 124          // establish_network_connection
 125          //-----------------------------------------------------------------------------
 126          //
 127          // This function calls mn_ether_init() to initialize the CP2200 and attach to
 128          // the network.
 129          //
 130          // If there is a network connection, the function returns 1.
 131          //
 132          // If there is no network connection, the function waits until either a
 133          // connection appears or the CP2200 is reset before calling mn_ether_init()
 134          // again. (The application may perform other tasks while polling
 135          // link_status and ether_reset).
 136          //
 137          int establish_network_connection()
 138          {
 139   1         int retval;
 140   1      
 141   1         do
 142   1         {
 143   2            // mn_ether_init() initializes the Ethernet controller.
 144   2            // AUTO_NEG indicates that the controller will auto-negotiate.
 145   2            retval = mn_ether_init(AUTO_NEG, 3, 0);
 146   2      
 147   2            // If there is no link, poll link_status until it sets or the
 148   2            // CP2200 resets and then call mn_ether_init() again.
 149   2            if (retval == LINK_FAIL)
 150   2            {
 151   3               while(!link_status && !ether_reset);
 152   3            }
 153   2      
 154   2            // If retval is less than zero and is not AUTO_NEG_FAIL, there is a 
 155   2            // hardware error.
 156   2            else if ((retval < 0) && (retval != AUTO_NEG_FAIL))
 157   2            {
 158   3               // Verify that the Ethernet controller is connected and powered properly.
 159   3               // Verity that the EMIF has been configured at a speed compatible with the
 160   3               //    Ethernet controller.
 161   3               while(1);
 162   3            }
 163   2      
 164   2         }while((retval < 0) && (retval != AUTO_NEG_FAIL));
 165   1      
 166   1         return (1);
 167   1      
 168   1      }//-----------------------------------------------------------------------------
 169          // Interrupt Service Routines
 170          //-----------------------------------------------------------------------------
 171          
 172          //-----------------------------------------------------------------------------
 173          // Timer2_ISR (T2_OVERFLOW_RATE Hz)
 174          //-----------------------------------------------------------------------------
 175          //
 176          void Timer2_ISR (void) interrupt 5
 177          {
 178   1      
 179   1         // Define static counters for real time clock (RTC).
C51 COMPILER V8.08   MAIN                                                                  04/24/2008 18:17:35 PAGE 4   

 180   1         static unsigned int RTC_counter = 0;
 181   1      
 182   1         // Clear Timer 2 Overflow Flag
 183   1         TF2H = 0;
 184   1      
 185   1         // Check if one second has passed and update RTC.
 186   1         if(RTC_counter >= T2_OVERFLOW_RATE){
 187   2      
 188   2            // Clear counter and update real time clock
 189   2            RTC_counter = 0;
 190   2            // num_buff[0]++;
 191   2                 Uart0Init();//串口初始化
 192   2              //Uart0SendString("OK\n",3);
 193   2              num1=Uart0Get();
 194   2          Uart0Send(num1);
 195   2              num_buff[3]=num1;
 196   2            //netfinder_update_RTC();
 197   2      
 198   2         } else {
 199   2            // Increment interrupt count
 200   2            RTC_counter++;
 201   2         }
 202   1      
 203   1      }
 204          //-----------------------------------------------------------------------------
 205          // CGI Script: get_data
 206          //-----------------------------------------------------------------------------
 207          //
 208          // This routine is called when the following is typed into the address bar
 209          // of a web browser:
 210          //    
 211          //    http://<ip-address>/get_data?arg1=hello&arg2=donotdisplay
 212          //
 213          //    where <ip-address> = the IP address of the embedded system
 214          //
 215          void get_data (PSOCKET_INFO socket_ptr)
 216          {
 217   1          byte msg_buff1[50],msg_buff2[10];    
 218   1         int status1,status2,status3;
 219   1      
 220   1          status1 = mn_http_find_value (BODYptr, (byte*)"type", msg_buff1);
 221   1             if(status1){  
 222   2                  //num_buff[0]+=2;
 223   2            sprintf(HTML_BUFFER, "<html><body bgcolor=blue text=yellow><center><span style=\"font-family: sans-s

⌨️ 快捷键说明

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