From: borutr Date: Mon, 14 Aug 2006 12:51:48 +0000 (+0000) Subject: * support/regression/Makefile.in, X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=0d852308c6d0c677ded1f7e1b232a6fd845dfde8;p=fw%2Fsdcc * support/regression/Makefile.in, support/regression/ports/pic14/gpsim.cmd, support/regression/ports/pic14/spec.mk, support/regression/ports/pic14/support.c: added pic14 regression test git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4337 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 238155a8..de3ec415 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-08-14 Borut Razem + + * support/fegression/ports/pic14/gpsim.cmd, + support/fegression/ports/pic14/spec.mk, + support/fegression/ports/pic14/support.c: + added pic14 regression test + 2006-08-14 Maarten Brock * as/doc/asxhtm.html: documented changed ABS behaviour diff --git a/support/regression/Makefile.in b/support/regression/Makefile.in index 384a549e..cc4377d1 100644 --- a/support/regression/Makefile.in +++ b/support/regression/Makefile.in @@ -69,7 +69,7 @@ GENERATE_CASES = $(srcdir)/generate-cases.py # Each directory under ports/ is used as a port name. Each port is tested. # Each port must have a spec.mk which describes how to build the object # files and how to run the emulator. -ALL_PORTS = $(filter-out .svn xa51 z80 gbz80 pic16,$(notdir $(wildcard $(PORTS_DIR)/*))) +ALL_PORTS = $(filter-out .svn xa51 z80 gbz80 pic16 pic14,$(notdir $(wildcard $(PORTS_DIR)/*))) # These ports will be cleaned with 'make clean' CLEAN_PORTS = $(filter-out .svn,$(notdir $(wildcard $(PORTS_DIR)/*))) @@ -126,6 +126,10 @@ test-xa51: test-pic16: $(MAKE) test-port PORT=pic16 +# Helper rule for testing the pic14 port only(use gpsim simulator) +test-pic14: + $(MAKE) test-port PORT=pic14 + ### Helper rule for testing the host cc only test-host: $(MAKE) test-port PORT=host diff --git a/support/regression/ports/pic14/gpsim.cmd b/support/regression/ports/pic14/gpsim.cmd new file mode 100644 index 00000000..a06099aa --- /dev/null +++ b/support/regression/ports/pic14/gpsim.cmd @@ -0,0 +1,2 @@ +run +quit diff --git a/support/regression/ports/pic14/spec.mk b/support/regression/ports/pic14/spec.mk new file mode 100644 index 00000000..6d60ecef --- /dev/null +++ b/support/regression/ports/pic14/spec.mk @@ -0,0 +1,46 @@ +# Port specification for the pic14 port running with gpsim + +# path to gpsim +ifdef GPSIM_PATH + GPSIM := $(GPSIM_PATH)/gpsim +else + GPSIM := gpsim +endif + +SDCCFLAGS += -mpic14 -pp16f877 -I$(top_srcdir)/device/include/pic --nostdinc --less-pedantic -Wl,-q -DREENTRANT=reentrant -I$(top_srcdir) +LINKFLAGS = --nostdlib +LINKFLAGS += libsdcc.lib libm.lib +LIBDIR = $(top_builddir)device/lib/build/pic + +OBJEXT = .o +EXEEXT = .cod + +EXTRAS = $(PORT_CASES_DIR)/testfwk$(OBJEXT) $(PORT_CASES_DIR)/support$(OBJEXT) + +# Rule to link into .ihx +%$(EXEEXT): %$(OBJEXT) $(EXTRAS) + -$(SDCC) $(SDCCFLAGS) $(LINKFLAGS) -L $(LIBDIR) $(EXTRAS) $< -o $@ + +%$(OBJEXT): %.c + -$(SDCC) $(SDCCFLAGS) -c $< -o $@ + +$(PORT_CASES_DIR)/%$(OBJEXT): $(PORTS_DIR)/$(PORT)/%.c + -$(SDCC) $(SDCCFLAGS) -c $< -o $@ + +.PRECIOUS: gen/pic14/testfwk.o gen/pic14/support.o + +$(PORT_CASES_DIR)/%$(OBJEXT): fwk/lib/%.c + $(SDCC) $(SDCCFLAGS) -c $< -o $@ + +# run simulator with 25 seconds timeout +%.out: %$(EXEEXT) $(CASES_DIR)/timeout + mkdir -p $(dir $@) + -$(CASES_DIR)/timeout 25 "$(GPSIM)" -i -s $< -c $(PORTS_DIR)/pic14/gpsim.cmd > $@ || \ + echo -e --- FAIL: \"timeout, simulation killed\" in $(<:$(EXEEXT)=.c)"\n"--- Summary: 1/1/1: timeout >> $@ + python $(srcdir)/get_ticks.py < $@ >> $@ + -grep -n FAIL $@ /dev/null || true + +$(CASES_DIR)/timeout: fwk/lib/timeout.c + $(CC) $< -o $@ + +_clean: diff --git a/support/regression/ports/pic14/support.c b/support/regression/ports/pic14/support.c new file mode 100644 index 00000000..161d22f5 --- /dev/null +++ b/support/regression/ports/pic14/support.c @@ -0,0 +1,103 @@ +/*------------------------------------------------------------------------- + support.c - startup for PIC14 regression tests with gpsim + + Copyright (c) 2006 Borut Razem + + 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 2, 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, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#pragma preproc_asm - + +#include + + +void +_putchar(char c) +{ + while (!TXIF) + ; + TXREG = c; +} + + +void +_initEmu(void) +{ + /* load and configure the libgpsim_modules module */ + _asm + ;; Set frequency to 20MHz + .direct "e", ".frequency=20e6" + + ;; Load the USART library and module + .direct "e", "module library libgpsim_modules" + .direct "e", "module load usart U1" + + ;; Define a node + .direct "e", "node PIC_tx" + + ;; Tie the USART module to the PIC + .direct "e", "attach PIC_tx portc6 U1.RXPIN" + + ;; Set the USART module's Baud Rate + .direct "e", "U1.rxbaud = 9600" + + ;; Display the received character on terminal + .direct "e", "U1.console = true" + _endasm; + + /* USART initialization */ + PORTC |= 0x40; // Set TX pin to 1 + TRISC &= ~0x40; // TX pin is output + + //1. Initialize the SPBRG register for the appropriate + // baud rate. If a high speed baud rate is desired, + // set bit BRGH (Section 16.1). + BRGH = 1; + SPBRG = 129; + + //2. Enable the asynchronous serial port by clearing + // bit SYNC and setting bit SPEN. + SPEN = 1; + + //3. If interrupts are desired, set enable bit TXIE. + //4. If 9-bit transmission is desired, set transmit bit + // TX9. Can be used as address/data bit. + //5. Enable the transmission by setting bit TXEN, + // which will also set bit TXIF. + TXEN = 1; + + //6. If 9-bit transmission is selected, the ninth bit + // should be loaded in bit TX9D. + //7. Load data to the TXREG register (starts + // transmission). +} + + +void +_exitEmu(void) +{ + /* wait until the transmit buffer is empty */ + while (!TRMT) + ; + + /* set the breakpoint */ + _asm + .direct "a", "\"\"" + _endasm; +}