http.c
来自「最新版IAR FOR ARM(EWARM)5.11中的代码例子」· C语言 代码 · 共 69 行
C
69 行
//-----------------------------------------------------------------------------
// HTTP
//-----------------------------------------------------------------------------
#include <string.h>
#include "tcpip_stack.h"
#include "tcp.h"
#include "http.h"
//-----------------------------------------------------------------------------
//Name:Receive_HTTP()
//Funcionality: HTTP server service routine
//-----------------------------------------------------------------------------
void Receive_HTTP(EthernetFrame *frame){
static u8 condition=0;
tcp_hdr *rx_tcp_hdr = (tcp_hdr *)((u8 *)frame + ETHER_HEADER_LENGTH + IP_HEADER_LENGTH);
/* char buf[] = "HTTP/1.0 200 OK\r\nServer: STMicroweb\r\nContent-Type: text/html\r\n\r\n"
"<html><head><title>STMicroweb</title></head><body bgcolor=blue><center><H1><FONT color=red>STMicroweb on SpearNet</H1><BR>"
"<HR><FONT color=white>This is a tiny version of Webserver dedicated for embedded applications.</center></body></html>";
*/
char *buf;
char buf0[] = "HTTP/1.0 200 OK\r\nServer: STMicroweb\r\nContent-Type: text/html\r\n\r\n"
"<html><head><title>SpearNet MicroWeb</title></head>"
"<script language=JavaScript><!--\n"
"function doLoad()\n"
"{setTimeout('Reload()',3000);}\n"
"function Reload(){window.location.reload();}\n"
"//-->\n"
"</script>"
"<body onLoad=\"doLoad()\" bgcolor=FFFF00>"
"<font color=3300ff><h1>SpearNet<sup>TM</sup> - ARM720T based Microcontroller</h1></font><h2>KEY FEATURES</h2><hr size=2>o Based on ARM720T (8k unified Cache and MMU included)<BR>o 10/100 Mbits/s Ethernet connection (IEEE802.3)<BR>o USB 2.0 Host Controller, supports 12Mbit/s Full Speed Devices<BR>o UART Interface: 115KBaud<BR>o I2C interface: Fast and Slow.<BR>o IEEE1284 Host Controller<BR>o Real Time Clock<BR>o Timers and Watchdog peripherals<BR>o Integrated PLL (25MHz Input, 48MHz Output)<BR>o Up to 12 GPIOs (including IEEE1284 port)<BR>o 8K SRAM shared with an External Microprocessor<BR>o Static Memory Controller (up to 2 Banks, Max 16M each)<BR>o DRAM Controller SDRAM/EDO (up to 4 Banks, Max 32M each)<BR>o External I/O Banks: 2 x 16KB.<BR>o Operating temperature range -40癈 105癈<BR>o Package LFBGA 180 (12x12mm x1.7mm) Lead Free<BR><h2>APPLICATIONS</h2><hr size=2>o Industrial Communication Controllers<BR>o Security Remote Controllers<BR>o Printer Servers<BR>o Decentralized Building Device Controllers<BR>o Companion communication controllers for motor drive applications<BR>o Power Meters<BR>"
"</body></html>";
char buf1[] = "HTTP/1.0 200 OK\r\nServer: STMicroweb\r\nContent-Type: text/html\r\n\r\n"
"<html><head><title>SpearNet MicroWeb</title></head>"
"<script language=JavaScript><!--\n"
"function doLoad()\n"
"{setTimeout('Reload()',3000);}\n"
"function Reload(){window.location.reload();}\n"
"//-->\n"
"</script>"
"<body onLoad=\"doLoad()\" bgcolor=CCFF99>"
"<font color=3300ff><h1>SpearNet<sup>TM</sup> - ARM720T based Microcontroller</h1></font><h2>KEY FEATURES</h2><hr size=2>o Based on ARM720T (8k unified Cache and MMU included)<BR>o 10/100 Mbits/s Ethernet connection (IEEE802.3)<BR>o USB 2.0 Host Controller, supports 12Mbit/s Full Speed Devices<BR>o UART Interface: 115KBaud<BR>o I2C interface: Fast and Slow.<BR>o IEEE1284 Host Controller<BR>o Real Time Clock<BR>o Timers and Watchdog peripherals<BR>o Integrated PLL (25MHz Input, 48MHz Output)<BR>o Up to 12 GPIOs (including IEEE1284 port)<BR>o 8K SRAM shared with an External Microprocessor<BR>o Static Memory Controller (up to 2 Banks, Max 16M each)<BR>o DRAM Controller SDRAM/EDO (up to 4 Banks, Max 32M each)<BR>o External I/O Banks: 2 x 16KB.<BR>o Operating temperature range -40癈 105癈<BR>o Package LFBGA 180 (12x12mm x1.7mm) Lead Free<BR><h2>APPLICATIONS</h2><hr size=2>o Industrial Communication Controllers<BR>o Security Remote Controllers<BR>o Printer Servers<BR>o Decentralized Building Device Controllers<BR>o Companion communication controllers for motor drive applications<BR>o Power Meters<BR>"
"</body></html>";
if (!condition) {
buf=buf0;
GPIO->DOUT0 = 0;
GPIO->DOUT1 = 1;
condition = 1;
}
else{
buf=buf1;
GPIO->DOUT0 = 1;
GPIO->DOUT1 = 0;
condition = 0;
}
u16 len = (u16) strlen(buf);
if (rx_tcp_hdr->control & TCP_ACK | TCP_SYN){
Tx_TCP_Frame(frame, TCP_ACK | TCP_PSH, (u8 *)buf, len);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?