📄 main.lst
字号:
C51 COMPILER V8.08 MAIN 04/01/2008 20:10:55 PAGE 1
C51 COMPILER V8.08, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\SiLabs\MCU\IDEfiles\C51\Bin\C51.exe main.c DB OE LARGE
line level source
1 //------------------------------------------------------------------------------
2 // main.c
3 //------------------------------------------------------------------------------
4 // Copyright (C) 2005 Silicon Laboratories, Inc.
5 //
6 // Date: 05/16/06 13:15:34
7 // Target: C8051F34x
8 // Version: 1.31
9 //
10 // Description:
11 //
12 // This example uses HTTP to act as a web server.
13 //
14 // It runs on a C8051F340 connected to a CP2200 via AB4 board.
15 //
16 // This file contains the main routine, MCU initialization code, and
17 // callback functions used by the TCP/IP Library.
18 //
19 // Steps for running this example code:
20 //
21 // 1. Replace IP_SRC_ADDR in mn_userconst.h with the desired IP address.
22 //
23 // 2. Connect to the C8051F340.
24 //
25 // 3. Compile and build the project code.
26 //
27 // 4. Download the code to the C8051F340 and press "Go".
28 //
29 // 5. Open a web browser on the PC and enter "http:\\XXX.XXX.XXX.XXX"
30 // into the URL bar (where XXX.XXX.XXX.XXX is the IP address
31 // assigned in Step 1).
32 //
33 // 6. The web browser will display a "Hello World" HTML document.
34 //
35
36 #include "mn_userconst.h" // TCP/IP Library Constants
37 #include "mn_stackconst.h" // TCP/IP Library Constants
38 #include "mn_errs.h" // Library Error Codes
39 #include "mn_defs.h" // Library Type definitions
40 #include "mn_funcs.h" // Library Function Prototypes
41 //#include "stdio.h"
42 //#include "string.h"
43 #include "VFILE_DIR\index.h"
44 #include <c8051F340.h> // Device-specific SFR Definitions
45
46 //------------------------------------------------------------------------------
47 // Global Variable
48 //------------------------------------------------------------------------------
49 unsigned char HTML_BUFFER[400];
50 //------------------------------------------------------------------------------
51 // Function Prototypes
52 //------------------------------------------------------------------------------
53
54 // Initialization Routines
55 void PORT_Init (void);
C51 COMPILER V8.08 MAIN 04/01/2008 20:10:55 PAGE 2
56 void SYSCLK_Init (void);
57 void EMIF_Init(void);
58 int establish_network_connection();
59 // CGI Script
60 //void get_data (PSOCKET_INFO socket_ptr);
61
62 //-----------------------------------------------------------------------------
63 // Main Routine
64 //-----------------------------------------------------------------------------
65 void main(void)
66 {
67 1 int retval;
68 1
69 1 // Disable watchdog timer
70 1 PCA0MD = 0x00;
71 1
72 1 // Initialize the MCU
73 1 PORT_Init();
74 1 SYSCLK_Init();
75 1 EMIF_Init();
76 1
77 1 while(1)
78 1 {
79 2 // Initialize the TCP/IP stack.
80 2 if (mn_init() < 0)
81 2 {
82 3 // If code execution enters this while(1) loop, the stack failed to initialize.
83 3 // Verify that all boards are connected and powered properly.
84 3 while(1);
85 3 }
86 2
87 2 // Connect to the network
88 2 establish_network_connection();
89 2
90 2 // Add web page to virtual file system.
91 2 // The main page MUST be called index.htm or index.html.
92 2 mn_vf_set_entry((byte *)"index.html", INDEX_SIZE, index_html, VF_PTYPE_FLASH);
93 2 // Add CGI Script to Virtual File System
94 2 mn_pf_set_entry
95 2 (
96 2 (byte*)"get_data", // Script Name (ASCII)
97 2 get_data // Function Pointer
98 2 );
*** ERROR C202 IN LINE 98 OF MAIN.C: 'get_data': undefined identifier
99 2
100 2 // Start the Application Layer Services
101 2 // If this routine exits, check the return value for an error code.
102 2 retval = mn_server();
103 2
104 2 }
105 1 }
106
107 /*
108 //-----------------------------------------------------------------------------
109 // CGI Script: get_data
110 //-----------------------------------------------------------------------------
111 //
112 // This routine is called when the following is typed into the address bar
113 // of a web browser:
114 //
115 // http://<ip-address>/get_data?arg1=hello&arg2=donotdisplay
116 //
C51 COMPILER V8.08 MAIN 04/01/2008 20:10:55 PAGE 3
117 // where <ip-address> = the IP address of the embedded system
118 //
119
120 void get_data (PSOCKET_INFO socket_ptr)
121 {
122 byte msg_buff1[52];
123 byte msg_buff2[52];
124 int status1,status2;
125 // Search for the “type” field and store the result in <msg_buff1>.
126 status1 = mn_http_find_value (BODYptr,(byte*)"type", msg_buff1);
127 // Search for the “setbgcolor” field and store the result in <msg_buff2>.
128 status2 = mn_http_find_value (BODYptr,(byte*)"setbgcolor",msg_buff2);
129 // Check status1 and status2 to determine if msg_buff1 and msg_buff2 are valid.
130 if(status1 && status2){
131 static byte html_buffer[256];
132 // Write the HTML code to a buffer.
133 int ambient_light=5;
134 sprintf( html_buffer, "<HTML>%i</HTML>" ,ambient_light);
135 // Fill the socket with data to send.
136 socket_ptr->send_ptr = html_buffer;
137 socket_ptr->send_len = strlen(html_buffer);
138 // Return from the CGI script
139 return;
140 }
141
142 }
143 */
144
145
146
147 //-----------------------------------------------------------------------------
148 // establish_network_connection
149 //-----------------------------------------------------------------------------
150 //
151 // This function calls mn_ether_init() to initialize the CP2200 and attach to
152 // the network.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -