下载

Rev. 0.6 6/06 Copyright © 2006 by Silicon Laboratories AN237
AN237
TCP/IP LIBRARY PROGRAMMER’S GUIDE
Relevant Devices
This application note applies to the following devices:
C8051F120, C8051F121, C8051F122, C8051F123, C8051F124, C8051F125, C8051F126, C8051F127,
C8051F130, C8051F131, C8051F132, C8051F133, C8051F020, C8051F021, C8051F022, C8051F023,
C8051F340, C8051F341, C8051F342, C8051F343, C8051F344, C8051F345, C8051F346, C8051F347
1. Introduction
The Silicon Laboratories TCP/IP stack is designed to add network connectivity to the ‘F12x, ‘F13x, ‘F02x, and ‘F34x
family of microcontrollers. It is highly configurable and has a small memory footprint. The TCP/IP stack is packaged
with a Configuration Wizard that can generate the framework code required to develop a networked application and
numerous examples to jump-start development and minimize time to market.
The TCP/IP stack includes the following features:
HTTP web server with CGI scripting, SMTP e-mail client, FTP server, TFTP client, Netfinder, DNS
client, and virtual file system.
Up to 127 simultaneous TCP or UDP sockets. Direct access to sockets allows custom application
development.
Support for Ethernet with DHCP/BOOTP capability. Interfaces to a CP220x through the external
memory parallel interface. Custom driver support allows any Ethernet controller to be used.
Support for PPP and SLIP with customizable modem settings (C8051F12x only). Interfaces to an
Si2457 modem through the serial port. Supports any standard "AT" serial modem.
The TCP/IP stack is freely available for use with a Silicon Laboratories MCU and can be downloaded from the
Silicon Laboratories web site. It is also included in the Embedded Ethernet Development Kit (Ethernet-DK) and the
Embedded Modem Development Kit (Modem-DK), which include:
C8051F12x Target Board, USB Debug Adapter, and Universal Power Supply.
AB4 Ethernet Development Board or the Si2457FT18-EVB Modem Board and AB3 Modem Adapter
Board. Note: A direct telephone line or phone simulator is required to communicate with the modem.
Evaluation version of the Keil C51 toolchain limited to 4 kB object code generated from application
code. TCP/IP library code does not count towards the 4 kB limit with BL51 linker Version 5.15 or higher.
TCP/IP Configuration Wizard to generate custom libraries and example projects that demonstrate how
to set up an HTTP web server, send an e-mail, and send and receive TCP and UDP packets.
2. API Function Overview
The TCP/IP stack provides a set of functions that implement an application programming interface (API). These
functions provide the microcontroller an Ethernet or dial-up network interface via the CP220x (Ethernet) or Si2457
(Modem). All low-level hardware details and protocols are handled by the API and do not require management by
application code. The API is provided in the form of a library file pre-compiled under the Keil C51 tool chain. (Device
firmware must be developed using the Keil C51 tool chain.) Some commonly-used API functions are listed below:
mn_init() Initializes all sockets and stack variables
mn_send() Sends data using a TCP or UDP socket
mn_recv() Waits for data to arrive on a TCP or UDP socket
mn_server() Starts an HTTP or FTP Server
mn_smtp_send_mail() Sends an e-mail to an SMTP mail server