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

📄 system.h

📁 这同样是FS8610相关的代码.看起来不错啊.
💻 H
字号:
/**
 * \addtogroup system
 * @{
 */

/** 
 * \file system.h
 * \brief System Architecture Layer Function Header File.
 */
 
/*
******************************************************************************
*
Copyright (c) 2006 FameG Shanghai, Inc. All rights reserved.
*
This is unpublished proprietary source code of FameG Shanghai, Inc.
*
The copyright notice above does not evidence any actual or intended
*
publication of such source code.
******************************************************************************
*/
/*
******************************************************************************
*
Project: T4 Hardware TCP/IP
*
Filename: system.h
*
Date: 28/02/06
*
Purpose: System Architecture Defination
*
Author: Xiaofei Rui
******************************************************************************
*/


#ifndef __SYSTEM_H__
#define __SYSTEM_H__

#include "kernel/config.h"
//#include "user_config.h"

#include "hw/dp8051.h"
/// @cond DOXYGEN_SKIP
//#define GET_GLB_INT_STATUS()    inb(SYS_GLBINTSTAT)
/// @endcond
#define XDATA   xdata   /**< Point to 8051 xdata memory space. \hideinitializer */
#define DATA	data    /**< Point to 8051 data memory space. \hideinitializer */
#define IDATA	idata   /**< Point to 8051 idata memory space. \hideinitializer */
#define PDATA	pdata   /**< point to 8051 pdata memory space. \hideinitializer */
#define CODE	code    /**< point to 8051 code memory space. \hideinitializer */
#define FAR     far

/* data type defination */
#define BYTE 	unsigned char	/**< 8 bit unsigned \hideinitializer */	
#define WORD 	unsigned int 	/**< 16 bit unsigned \hideinitializer */
//#define DWORD	unsigned long 	/**< 32 bit unsigned \hideinitializer */

#define UINT8	unsigned char 	/**< 8 bit unsigned \hideinitializer */
#define INT8	signed char 	/**< 8 bit signed \hideinitializer */
#define	UINT16	unsigned int 	/**< 16 bit unsigned \hideinitializer */
#define INT16	signed int 		/**< 16 bit signed \hideinitializer */
#define UINT32	unsigned long 	/**< 32 bit unsigned \hideinitializer */
#define INT32 	signed long 	/**< 32 bit signed \hideinitializer */

#define uint8	unsigned char 	/**< 8 bit unsigned \hideinitializer */
#define int8	signed char 	/**< 8 bit signed \hideinitializer */
#define	uint16	unsigned int 	/**< 16 bit unsigned \hideinitializer */
#define int16	signed int 		/**< 16 bit signed \hideinitializer */
#define uint32	unsigned long 	/**< 32 bit unsigned \hideinitializer */
#define int32 	signed long 	/**< 32 bit signed \hideinitializer */

#define BOOL    unsigned char   /**< Boolean define \hideinitializer */

/* Boolean	values */
#define TRUE  1	/**< Boolean TRUE value \hideinitializer */
#define FALSE 0	/**< Boolean FALSE value \hideinitializer */

#ifndef NULL
#define NULL  0   /**< used for pointer \hideinitializer */
#endif

#define RETURN_TYPE INT8  /**< Used for function return value, 
                           * \hideinitializer  */
#define SUCCESS	0         /**< Function returns with success. \hideinitializer */
#define ERROR	-1        /**< Function returns with Error. \hideinitializer */

/// @cond DOXYGEN_SKIP
#define BIT0	0x01
#define BIT1	0x02
#define BIT2	0x04
#define BIT3	0x08
#define BIT4	0x10
#define BIT5	0x20
#define BIT6	0x40
#define BIT7	0x80
/// @endcond

/* IO access micros defination */
#define writeb(v,p)   *(volatile UINT8 xdata *)(p)=v  /**< Write a byte to Register. \hideinitializer */
#define writew(v,p)                                   /**< Write a word to Register, 8051 does NOT support.*/
#define writel(v,p)                                   /**< Write a double word to Register, 8051 does NOT support.*/

#define readb(p)      *(volatile UINT8 xdata *)(p)    /**< Read a byte out from Register. \hideinitializer */
#define readw(p)                                      /**< Read a word from Register, 8051 does NOT support.*/
#define readl(p)                                      /**< Read a double word from Register, 8051 does NOT support.*/

#define outb(v,p)     *(volatile UINT8 xdata *)(p)=v  /**< Write a byte to Register. \hideinitializer */
#define outw(v,p)                                     /**< Write a word to Register, 8051 does NOT support.*/
#define outl(v,p)                                     /**< Write a double word to Register, 8051 does NOT support.*/   

#define inb(p)        *(volatile UINT8 xdata *)(p)    /**< Read a byte out from Register. \hideinitializer*/
#define inw(p)                                        /**<Read a word from Register, 8051 does NOT support.*/
#define inl(p)                                        /**< Read a double word from Register, 8051 does NOT support.*/ 

/** Define Timer 0 reload values \hideinitializer */
#define T0FREQ	(1000/TICK_UNIT)/* 10ms or 1ms */

#define DISABLE_IRQ()    EA=0
#define ENABLE_IRQ()     EA=1

/** Calculate complement code of a number */
#define COMPLEMENT_CODE(n)		((~n)+1)

/** A union for double word in two formats. */
union dword_byte_u
{
	UINT32 bit32;     /**< Double word in 32bit format. */
	UINT8  bit8[4];   /**< Double word in 4 bytes format. */
};

union word_byte_u
{
	UINT16 bit16;     /**< Word in 16bit format. */
	UINT8  bit8[2];   /**< Word in 2 bytes format. */
};


/* link mode configuration options */
#define	NET_MODE_FIXEDIP	0
#define	NET_MODE_DHCP		1
#define	NET_MODE_PPPOE	2

/* link status identification options */
#define	NET_STATUS_UP		0x01	//bit 0
#define	NET_STATUS_DOWN	0x00
#define	NET_STATUS_IP_OK	0x02	//bit 1
#define	NET_STATUS_IP_FAIL	0x00
#define   NET_STATUS_DNS_OK 0x04


/** \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.
 */
typedef struct _net_if {

	/** \brief Network Mode
	 *
	 *	This variable indicates system network mode: Fixed IP, DHCP, or PPPOE.
	 *		\li Fixed IP: Assign fixed IP, netmask, gateway, and DNS server
	 *		\li DHCP: Fetch all IP information form DHCP server
	 *		\li PPPOE: Fetech IP, and DNS by PPPoE dial-up
	 *
	 */
	UINT8	net_mode;	

	/** \brief Network Status
	 *
	 *	This variable restore system network status:
	 *		\li Physical link status: UP or DOWN
	 * 		\li IP layer connection status: IP_OK, IP_FAIL
	 *
	 */
	UINT8	net_status;	

	/** \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.
	 *
	 */
	UINT8	localHW[6];
	
	/** \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.
	 */
	UINT32	localip;

	/**	\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).
	 */
	UINT32	netmask;

	/** \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.
	 */
	UINT32	gateway;

//#if	(INCLUDE_DNS_CLIENT || INCLUDE_PPPOE_STACK)
	/**	\brief	Primary DNS server
	 *
	 * 	Primary DNS server. 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).
	 */
	UINT32	first_dns;

	/**	\brief	Second DNS server
	 *
	 * 	Second DNS server. 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).
	 */
	UINT32	second_dns;
//#endif	/* INCLUDE_DNS_CLIENT */
} net_if_T;


typedef void (*int_function)(void);

/* Function Defination */
extern void mcu_Init(UINT8 program_wait, UINT8 data_wait);
extern void soft_reset(void);
extern void timer0_init(void);
extern void sys_config_CSB123(UINT8 csb_no, UINT32 start_add, UINT32 end_add, UINT8 wait_state);
extern void sys_config_PLL(UINT8 clock);

extern volatile UINT32 IDATA jiffies;		/* System 10 msec timer	*/
/* Buffers					*/
extern UINT8 	TX_BUF[];	/**< See system.c */
extern UINT8	RX_BUF[];

extern net_if_T g_local_netif;				/**< <b> MUST BE PUT SOMEWHERE </b> */ 

#endif /*__SYSTEM_H__*/

/** @} */

⌨️ 快捷键说明

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