head	1.5;
access;
symbols
	bg2_23:1.5
	bg2_22:1.5
	bg2_21:1.5
	bg2_20:1.5
	bg2_16:1.5
	bg2_15:1.5
	bg2_12:1.5
	bg2_07:1.5
	isorc2008_submission:1.4
	handbook_alpha_edition:1.4
	jtres2007_submission:1.4
	bg1_07:1.3
	bg1_06:1.3
	bg1_05:1.3
	TAL_101:1.3
	TAL_100:1.3
	jtres_submission:1.1
	wises06_submission:1.1
	lctes2006_submission:1.1
	rtgc_isorc2006:1.1.0.4
	isorc2006:1.1.0.2
	rtgc_paper:1.1
	bg1_00:1.1
	nohandle:1.1;
locks; strict;
comment	@# @;


1.5
date	2008.02.24.17.42.24;	author martin;	state Exp;
branches;
next	1.4;
commitid	224a47c1ac774567;

1.4
date	2007.01.24.19.34.23;	author martin;	state Exp;
branches;
next	1.3;
commitid	129e45b7b4bd4567;

1.3
date	2006.10.09.13.33.16;	author martin;	state Exp;
branches;
next	1.2;
commitid	1d84452a4f9b4567;

1.2
date	2006.10.04.16.21.33;	author martin;	state Exp;
branches;
next	1.1;
commitid	49d14523df3d4567;

1.1
date	2005.05.11.17.37.20;	author martin;	state Exp;
branches;
next	;
commitid	37a1428242cc4567;


desc
@@


1.5
log
@JOP goes GPL
@
text
@/*
  This file is part of JOP, the Java Optimized Processor
    see <http://www.jopdesign.com/>

  Copyright (C) 2001-2008, Martin Schoeberl (martin@@jopdesign.com)

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/*
 * Copyright (c) Martin Schoeberl, martin@@jopdesign.com
 * All rights reserved.
 *
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS 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 THE REGENTS OR 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.
 *
 */

package tal;

/**
*	Tal.java: test main.
*
*	Author: Martin Schoeberl (martin@@jopdesign.com)
*
*	2004-09-09	Version 0.05
*	2006-09-20	Version 0.06: shorten loop cycle to 5 ms to get short
*				pulses (10 ms)
*	2006-10-09	Version 1.00: update JOP to ignore HW handshake
*				by default
*
*/

import joprt.RtThread;
import util.Dbg;
import util.Serial;
import util.Timer;

import com.jopdesign.sys.Const;

import ejip.CS8900;
import ejip.Html;
import ejip.LinkLayer;
import ejip.Net;

/**
*	TAL Main.
*/

public class Tal {

	static Net net;
	static LinkLayer ipLink;
	static Serial ser;

	static Modem modem;
	static Fwp fwp;
	static Param par;
	private static Loop loop;	// reference not used by anyone else
	
	private static boolean run;
	
	private static boolean simpc;
	private static boolean evn;
	/**
	*	Start all threads and enter forever loop.
	*/
	
	public static void main(String[] args) {

simpc = args!=null;	// we provide a null pointer in Startup.java for JOP
evn = true;
		run = true;
		// not so good for final application
		// will be UDP...
		if (simpc) {
			Dbg.initSer();
		} else {
			Dbg.init();
		}

		//
		//	start TCP/IP and all (four) threads
		//
		net = Net.init();
		int[] outReg = new int[1];
		outReg[0] = 0;
		Html.setOutValArray(outReg);
		// don't use CS8900 when simulating on PC
		if (!simpc) {
			int[] eth = {0x00, 0xe0, 0x98, 0x33, 0xb0, 0xf8};
			int ip = (192<<24) + (168<<16) + (0<<8) + 123;
			ipLink = CS8900.init(eth, ip);
		}
		// use instead Slip for PC simulation
		// LinkLayer ipLink = Slip.init(Const.IO_UART_BG_MODEM_BASE,
		//	(192<<24) + (168<<16) + (1<<8) + 2); 

		//
		//	start device driver threads
		//

		new RtThread(5, 10000) {
			public void run() {
				for (;;) {
					waitForNextPeriod();
					net.loop();
					if (!simpc) ipLink.loop();
				}
			}
		};

		par = new Param();
		fwp = new Fwp();
		if (simpc) {
			ser = new Serial(Const.IO_UART_BG_MODEM_BASE);
		} else {
			ser = new Serial(Const.IO_UART1_BASE);
		}
		if (evn) {
			modem = Modem.getInstance(5, 100000, ser);
		} else {
			new Modbus(5, 10000, ser, outReg);
		}

		new RtThread(10, 3000) {
			public void run() {
				for (;;) {
					waitForNextPeriod();
					ser.loop();
				}
			}
		};
		
		loop = new Loop(7, 5000);

		RtThread.startMission();
		forever();
	}
	
	public static void stop() {
		run = false;
	}

	private static void forever() {

		//
		//	Just do the WD blink with lowest priority.
		//	=> if the other threads take to long there will be a reset
		//
		for (int cnt=0;cnt<20;) {
			RtThread.sleepMs(500);
			Timer.wd();
			if (!run) ++cnt;	// stop in 10 seconds
		}
	}
}
@


1.4
log
@local eth and ip
@
text
@d2 20
@


1.3
log
@Version 1.00
@
text
@d92 3
a94 1
			ipLink = CS8900.init(Net.eth, Net.ip);
@


1.2
log
@*** empty log message ***
@
text
@d30 2
@


1.1
log
@resync with current development
@
text
@d25 5
a29 1
*	Author: Martin Schoeberl (martin.schoeberl@@chello.at)
d132 1
a132 1
		loop = new Loop(7, 20000);
@

