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

📄 system.h

📁 cs8900 c51应用
💻 H
📖 第 1 页 / 共 2 页
字号:
/*
 *Copyright (c) 2000-2002 Viola Systems Ltd.
 *All rights reserved.
 *
 *Redistribution and use in source and binary forms, with or without 
 *modification, are permitted provided that the following conditions 
 *are met:
 *
 *1. Redistributions of source code must retain the above copyright 
 *notice, this list of conditions and the following disclaimer.
 *
 *2. Redistributions in binary form must reproduce the above copyright 
 *notice, this list of conditions and the following disclaimer in the 
 *documentation and/or other materials provided with the distribution.
 *
 *3. The end-user documentation included with the redistribution, if 
 *any, must include the following acknowledgment:
 *	"This product includes software developed by Viola 
 *	Systems (http://www.violasystems.com/)."
 *
 *Alternately, this acknowledgment may appear in the software itself, 
 *if and wherever such third-party acknowledgments normally appear.
 *
 *4. The names "OpenTCP" and "Viola Systems" must not be used to 
 *endorse or promote products derived from this software without prior 
 *written permission. For written permission, please contact 
 *opentcp@opentcp.org.
 *
 *5. Products derived from this software may not be called "OpenTCP", 
 *nor may "OpenTCP" appear in their name, without prior written 
 *permission of the Viola Systems Ltd.
 *
 *THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 
 *WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
 *MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
 *IN NO EVENT SHALL VIOLA SYSTEMS LTD. OR ITS CONTRIBUTORS BE LIABLE 
 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 *CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 *SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 *WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
 *OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
 *EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *====================================================================
 *
 *OpenTCP is the unified open source TCP/IP stack available on a series 
 *of 8/16-bit microcontrollers, please see <http://www.opentcp.org>.
 *
 *For more information on how to network-enable your devices, or how to 
 *obtain commercial technical support for OpenTCP, please see 
 *<http://www.violasystems.com/>.
 */

/** \file system.h
 *	\brief OpenTCP system interface file
 *	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\version 1.0
 *	\date 23.6.2002
 * 	
 *	OpenTCP system function declarations, constants, general 
 *	assignments, etc.
 */
#ifndef SYSTEM_H_INCLUDE
#define SYSTEM_H_INCLUDE

#include <inet/datatypes.h>
#include <inet/globalvariables.h>

#ifdef CS8900
#include <inet/cs8900.h> /* prototypes for functions in macros */
#endif

#ifdef SLIP
#include <inet/SLIP.h> /* prototypes for functions in macros */
#endif
/** \def OPENTCP_VERSION
 *	\brief OpenTCP major version number
 *
 *	This define represents OpenTCP version information. Version
 *	is in the format MAJOR.MINOR.PATCH.
 */
#define OPENTCP_VERSION	"1.0.2"

/* Boolean	values*/
#define TRUE  1	/**< Boolean TRUE value as used in the OpenTCP */
#define FALSE 0	/**< Boolean FALSE value as used in the OpenTCP */

/**	\def NETWORK_TX_BUFFER_SIZE
 *	\ingroup opentcp_config
 *	\brief Transmit buffer size 
 *
 *	NETWORK_TX_BUFFER_SIZE defines the size of the network buffer
 *	used for data transmission by ICMP as well as TCP and UDP applications.
 *	
 *	See net_buf documentation for more reference on the shared transmit
 *	buffer.
 */
#define	NETWORK_TX_BUFFER_SIZE	1024			

/** \struct netif system.h
 *	\brief Network Interface declaration
 *
 *	This structure holds information about the network interface. This means
 *	that all of the network-related information are stored in this kind
 *	of structure.
 */
struct netif{
	/** \brief IP address of a device
	 *
	 *	IP address of a happy device using OpenTCP :-). This must hold
	 *	proper-value IP address in order for the networking stuff to work.
	 *
	 *	Possible scenarios for filling this field are:
	 *		\li By assigning static IP address to a device always after reset
	 *		\li By allowing user to choose IP address by some tool (e.g. through
	 *		serial communication, storing that information to some external
	 *		flash,...)
	 *		\li By using BOOTP or DHCP clients for obtaining dynamically
	 *		assigned address
	 *		\li	By obtaining the IP address from the first ICMP packet
	 *		the device receives
	 *
	 *	First three approaches can also be used for obtaining gateway
	 *	and subnet-mask information.
	 */
	LWORD	localip;
	
	/** \brief Ethernet address given to a device
	 *
	 *	This array holds an Ethernet address assigned to a device. Note that
	 *	these must be unique so if you're shipping your product to outside
	 *	world you must purchase sufficient address range.
	 *
	 */
	BYTE 	localHW[6];
	
	/** \brief	Default network gateway
	 *
	 *	IP address of a default network gateway. This is needed if the
	 *	device is to communicate with the outside network (Internet) and
	 *	not only intranet.
	 */
	LWORD	defgw;
	
	/**	\brief	Network submask
	 *
	 * 	Network submask. Also needed if the the device is to communicate
	 *	with the outside network. Used when determining whether the 
	 *	host we're sending some data to is on the local network (send 
	 *	data directly) or not (send through gateway).
	 */
	LWORD	netmask;
};

/* System variable definitions	*/

#define	MASTER_MS_CLOCK		base_timer		/**< Interrupt driven msec free-running clock	*/
#define TXBUF	net_buf		/**< TXBUF points to transmit network buffer */

/*	System macros		*/

/**	\def RESET_SYSTEM
 *	\brief Macro used to reset the MCU
 *
 *	By default this macro is only an infinite loop and the system is 
 *	reset by the (presumably) running watchdog timer.
 *
 *	Change this if another form of reset is desired/needed.
 */
#define	RESET_SYSTEM()	while(1)		/* Let the watchdog bite	*/

/**	\def OS_EnterCritical
 *	\brief Macro used to enter critical sections
 *	\todo 
 *		\li Move this to other arch-dependant place
 *
 *	This is highly dependant on the architecture that is used and/or
 *	possible operating system beeing used so it will be moved to some
 *	other place in the future.
 *
 *	Usually disabling globally interrupts works just fine :-)
 */
#define OS_EnterCritical()		EA = 0

/**	\def OS_ExitCritical
 *	\brief Macro used to exit critical sections
 *	\todo 
 *		\li Move this to other arch-dependant place
 *	
 *	This is highly dependant on the architecture that is used and/or
 *	possible operating system beeing used so it will be moved to some
 *	other place in the future.
 *
 *	For now this only globally enables interrupts
 */
#define	OS_ExitCritical()		EA = 1

/** \def RECEIVE_NETWORK_B
 *	\brief Use this macro to read data from Ethernet controller
 *
 *	This macro should be used to read data from the Ethernet
 *	controller. Procedure for doing this would be as follows:
 *		\li Initialize reading of data from certain address in the
 *		Ethernet controller (usually you will do that based on buf_index
 *		value of ip_frame, udp_frame or tcp_frame type of variables; 
 *		in certain special situations you can also use buf_index from 
 *		ethernet_frame type of var.
 *		\li Keep invoking RECEIVE_NETWORK_B() to read one byte at a time from
 *		the ethernet controller. Take care not to read more data than
 *		actually received
 *		\li If needed, reinitialize reading of data again and start all
 *		over again
 *		\li When finished discard the current frame in the Ethernet
 *		controller by invoking NETWORK_RECEIVE_END() macro
 *
 */

/**********************************************************************
*	CS8900 section
***********************************************************************/

⌨️ 快捷键说明

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