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

📄 init.c

📁 cs8900 c51应用
💻 C
字号:
/*
 *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 init.c
 *	\brief Default initialization file for OpenTCP on Atmel's AT89S8252
 *	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\version 1.0
 *	\date 27.1.2003
 *	\bug
 *	\warning
 *	\todo
 *  
 *	This file contains a function that initializes the HW resources 
 *	of processor (Pins, Peripherals). For stack and memory mode 
 *	selection modify start.asm. For Interrupt level modify VECTORS.C. 
 */


/*	Alexey Selischev (bmp@beep.ru) */

#include <inet/arch/at89s8252/at89s8252.h>
#include <inet/datatypes.h>


void init (void)
{

	/** INIT I/O PINS	**/


	/*	Port 0	- set to Input state	*/
	P0 = 0xFF;	
	
	/*	Port 1	- set to Input state	*/
	P1 = 0xFF;	
	
	/*	Port 2	- set to Input state	*/
	P2 = 0xFF;	
	
	/* 	Port 3	- set to Input state	*/
	P3 = 0xFF;	


	/* Initialize 16 bit reload timer for slow 10 ms step SW timers	*/
	TH1 = T1_HIGH; /* 10 ms interrupt interval @12 MHz */
	TL1 = T1_LOW; /* Using Timer 1 */



	/* Initialize TIMER2 for UART clock */
/* Skip, if using MONITOR.  
* Generic 805x have only one UART, so
*/
#ifndef MONITOR
	SCON = 0x50;
	TI = 1;
	REN = 1;
	RCAP2L = RCAP2_LOW;
	RCAP2H = RCAP2_HIGH;
	TL2 = RCAP2_LOW;
	TH2 = RCAP2_HIGH;
	RCLK = 1;
	TCLK = 1;
	TR2 = 1;
#endif

	/* Initialize the time-base timer for fast 1ms interrupt for system timer	*/
	TH0 = T0_HIGH; /* ~1 ms interrupt interval using 12 MHz XTAL*/
	TL0 = T0_LOW;	/* using Timer 0 */

	/* Initialize timers 0 and 1 */
	TMOD = 0x11; /* as 16 bit timers */
	
	/* Initialize interrupts	*/

	ET1 = 1; /* Enable Timer 1 Interrupt request			*/
	ET0 = 1; /* Enable Timer 0 Interrupt request			*/
	TR1 = 1; /* Run Timer 1 */
	TR0 = 1; /* Run Timer 0 */

	EA = 1; /* Enable all interrupts */

	
	/* Kick WD	*/

}

⌨️ 快捷键说明

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