From: richardbarry Date: Sat, 27 May 2006 13:53:15 +0000 (+0000) Subject: New demo files for HCS12 GCC port. X-Git-Tag: V4.0.2~6 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ac5418a540eeb6a3c14cb0b06f3ce99db0e8147e;p=freertos New demo files for HCS12 GCC port. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@6 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Demo/HCS12_GCC_banked/FreeRTOSConfig.h b/Demo/HCS12_GCC_banked/FreeRTOSConfig.h new file mode 100644 index 000000000..03c66915f --- /dev/null +++ b/Demo/HCS12_GCC_banked/FreeRTOSConfig.h @@ -0,0 +1,92 @@ +/* + FreeRTOS V3.2.3 - Copyright (C) 2003-2005 Richard Barry. + + This file is part of the FreeRTOS distribution. + + FreeRTOS 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 of the License, or + (at your option) any later version. + + FreeRTOS 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 FreeRTOS; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + *************************************************************************** +*/ + +/** + * FreeRTOSConfig.h configures FreeRTOS for GCC/HCS12 version of FreeRTOS Demo + * + * Modified by Jefferson L Smith, Robotronics Inc. + */ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/* This port requires the compiler to generate code for the BANKED memory +model. */ +#define BANKED_MODEL + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + *----------------------------------------------------------*/ + +#define configUSE_PREEMPTION 1 +#define configUSE_IDLE_HOOK 1 +#define configUSE_TICK_HOOK 0 +#define configTICK_RATE_HZ ( ( portTickType ) 977 ) +#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 4 ) +#define configMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 300/*128*/ ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 10752 ) ) +#define configMAX_TASK_NAME_LEN ( 3 ) +#define configUSE_TRACE_FACILITY 0 +#define configUSE_16_BIT_TICKS 1 +#define configIDLE_SHOULD_YIELD 1 + +/* Co-routine definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* This parameter is normally affects the clock frequency. In this port, at the moment +it might just be used for reference. */ + +#define configCPU_CLOCK_HZ ( ( unsigned portLONG ) 24000000 ) + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ + +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 + + + + + +#endif /* FREERTOS_CONFIG_H */ diff --git a/Demo/HCS12_GCC_banked/Makefile b/Demo/HCS12_GCC_banked/Makefile new file mode 100644 index 000000000..4d19f27c7 --- /dev/null +++ b/Demo/HCS12_GCC_banked/Makefile @@ -0,0 +1,64 @@ +# Demo for GCC/HCS12 port of FreeRTOS +# Author Jefferson Smith +# +SRCDIR=../.. +RTOS_BASEDIR=$(SRCDIR)/Source + +# what board to compile for +TARGET_BOARD ?= dragon12-rom +CPU=m68hcs12 + +DEVC_PREFIX=m6811-elf- +CC=$(DEVC_PREFIX)gcc +AS=$(DEVC_PREFIX)as +AR=$(DEVC_PREFIX)ar +OBJCOPY=$(DEVC_PREFIX)objcopy +OBJDUMP=$(DEVC_PREFIX)objdump + +CPPFLAGS+=-I. -I./asm-$(CPU)/arch-dragon12 -I../Common/include \ + -I$(RTOS_BASEDIR)/include -DGCC_HCS12 -DM6812_DEF_SCI=1 -DPORT_LED=M6811_PORTB + +CFLAGS+=-$(CPU) -mshort -mlong-calls -g -Os -Wall -Wmissing-prototypes \ + -Wno-char-subscripts -fomit-frame-pointer -msoft-reg-count=0 -mauto-incdec +#-Os -fomit-frame-pointer + +LDFLAGS+=-$(CPU) -mshort -mlong-calls -Wl,-T,ldscript-rtos.x + +OBJCOPY_FLAGS=--srec-len=0x20 --change-addresses 0xffff0000 + +CSRCS=main.c startup.c vectors.c serial.c sci.c ParTest.c gelfunc.c \ + ../Common/Minimal/flash.c \ + ../Common/Minimal/dynamic.c \ + ../Common/Minimal/BlockQ.c \ + ../Common/Minimal/PollQ.c \ + ../Common/Minimal/comtest.c \ + ../Common/Minimal/integer.c \ + ../Common/Minimal/death.c \ + +RTOS_OBJS = $(RTOS_BASEDIR)/portable/GCC/HCS12/port.c \ + $(RTOS_BASEDIR)/portable/MemMang/heap_2.c \ + $(RTOS_BASEDIR)/list.c \ + $(RTOS_BASEDIR)/tasks.c \ + $(RTOS_BASEDIR)/queue.c + +OBJS=$(CSRCS:.c=.o) $(RTOS_OBJS:.c=.o) + +# +# *.elf for the simulator and gdb +# *.s19 is original S Records from ld +# *.s2 is S2 Records (from SRecCvt.exe) +# +all:: main.elf main.lst main.s19 + +main.elf: $(OBJS) + $(CC) $(LDFLAGS) -o $@ $^ -lc -lbcc -lc + +%.lst: %.elf + $(OBJDUMP) -htS $< >$@ + +%.s19: %.elf + $(OBJCOPY) --output-target=srec $(OBJCOPY_FLAGS) $< $*.s19 + +clean:: + $(RM) $(OBJS) *.elf *.s19 + diff --git a/Demo/HCS12_GCC_banked/PE_Error.h b/Demo/HCS12_GCC_banked/PE_Error.h new file mode 100644 index 000000000..bc1ca1a57 --- /dev/null +++ b/Demo/HCS12_GCC_banked/PE_Error.h @@ -0,0 +1,53 @@ +/** ################################################################### +** THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT. +** Filename : PE_Error.H +** Project : RTOSDemo +** Processor : MC9S12DP256BCPV +** Beantype : PE_Error +** Version : Driver 01.00 +** Compiler : Metrowerks HC12 C Compiler +** Date/Time : 13/06/2005, 20:14 +** Abstract : +** This bean "PE_Error" contains internal definitions +** of the error constants. +** Settings : +** Contents : +** No public methods +** +** (c) Copyright UNIS, spol. s r.o. 1997-2002 +** UNIS, spol. s r.o. +** Jundrovska 33 +** 624 00 Brno +** Czech Republic +** http : www.processorexpert.com +** mail : info@processorexpert.com +** ###################################################################*/ + +#ifndef __PE_Error_H +#define __PE_Error_H + +#define ERR_OK 0 /* OK */ +#define ERR_SPEED 1 /* This device does not work in the active speed mode. */ +#define ERR_RANGE 2 /* Parameter out of range. */ +#define ERR_VALUE 3 /* Parameter of incorrect value. */ +#define ERR_OVERFLOW 4 /* Timer overflow. */ +#define ERR_MATH 5 /* Overflow during evaluation. */ +#define ERR_ENABLED 6 /* Device is enabled. */ +#define ERR_DISABLED 7 /* Device is disabled. */ +#define ERR_BUSY 8 /* Device is busy. */ +#define ERR_NOTAVAIL 9 /* Requested value or method not available. */ +#define ERR_RXEMPTY 10 /* No data in receiver. */ +#define ERR_TXFULL 11 /* Transmitter is full. */ +#define ERR_BUSOFF 12 /* Bus not available. */ +#define ERR_OVERRUN 13 /* Overrun error is detected. */ +#define ERR_FRAMING 14 /* Framing error is detected. */ +#define ERR_PARITY 15 /* Parity error is detected. */ +#define ERR_NOISE 16 /* Noise error is detected. */ +#define ERR_IDLE 17 /* Idle error is detectes. */ +#define ERR_FAULT 18 /* Fault error is detected. */ +#define ERR_BREAK 19 /* Break char is received during communication. */ +#define ERR_CRC 20 /* CRC error is detected. */ +#define ERR_ARBITR 21 /* A node losts arbitration. This error occurs if two nodes start transmission at the same time. */ +#define ERR_PROTECT 22 /* Protection error is detected. */ + +#endif //__PE_Error_H diff --git a/Demo/HCS12_GCC_banked/ParTest.c b/Demo/HCS12_GCC_banked/ParTest.c new file mode 100644 index 000000000..4521014c8 --- /dev/null +++ b/Demo/HCS12_GCC_banked/ParTest.c @@ -0,0 +1,78 @@ +/* + FreeRTOS V3.2.3 - Copyright (C) 2003-2005 Richard Barry. + + This file is part of the FreeRTOS distribution. + + FreeRTOS 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 of the License, or + (at your option) any later version. + + FreeRTOS 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 FreeRTOS; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + *************************************************************************** +*/ + +/** + * ParTest.c controls bits (LEDs) for GCC/HCS12 version of FreeRTOS Demo + * + * Modified from CodeWarrior/HCS12 by Jefferson L Smith, Robotronics Inc. + */ + +#include + +/* Scheduler include files. */ +#include "FreeRTOS.h" +#include "portable.h" + +/* Demo application include files. */ +#include "partest.h" + +#define LEDIO PORTIO_8(PORT_LED) + +/*----------------------------------------------------------- + * Simple parallel port IO routines. + *-----------------------------------------------------------*/ + +void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue ) +{ + /* This function is required as it is called from the standard demo + application files. It manipulates a bit to control one LED. */ + portENTER_CRITICAL(); + + if (xValue) { /* Is it one to be written? */ + LEDIO |= (1< +#include + +/* Initialize SCI serial port to default baudrate and enable. */ +extern inline void +serial_init (void) +{ + SCIBD = M6811_DEF_BAUD; + SCICR1 = 0x00; //typical 8 bit + SCICR2 = 0x0c; //Enable sci for polling +} + +/* Return != 0 if there is something to read on the serial line. */ +extern inline unsigned char +serial_receive_pending (void) +{ + return SCISR1 & RDRF; +} + +/* Wait until the SIO has finished to send the character. */ +extern inline void +serial_flush (void) +{ + while (!(SCISR1 & TDRE)) + cop_optional_reset (); +} + +/* Return != 0 if serial port is ready to send another char. */ +extern inline unsigned char +serial_send_ready (void) +{ + return SCISR1 & TDRE; +} + +/* Send the character on the serial line. */ +extern inline void +serial_send (char c) +{ + serial_flush (); + SCIDRL = c; + SCICR2 |= (1<<3); +} + +/* Wait for a character on the serial line and return it. */ +extern inline unsigned char +serial_recv (void) +{ + while (!(SCISR1 & RDRF)) + cop_optional_reset (); + + return SCIDRL; +} + +extern void serial_print (const char *msg); +extern void serial_getline (char *buf); + +#endif /* _M68HC11_SIO_H */ + diff --git a/Demo/HCS12_GCC_banked/cpu.h b/Demo/HCS12_GCC_banked/cpu.h new file mode 100644 index 000000000..dfbfbe767 --- /dev/null +++ b/Demo/HCS12_GCC_banked/cpu.h @@ -0,0 +1,39 @@ +/** + * sci.c controls SCI for GCC/HCS12 version of FreeRTOS Demo + * To replace CodeWarrior Cpu.h + * + * Author Jefferson L Smith, Robotronics Inc. + */ + +#ifndef __Cpu +#define __Cpu + +/*Types definition*/ +typedef unsigned char bool; +typedef unsigned char byte; +typedef unsigned int word; +typedef unsigned long dword; + +#define ATTR_INT __attribute__((interrupt)) +#define ATTR_FAR __attribute__((far)) +#define ATTR_NEAR __attribute__((near)) +#define ATTR_BANK0 __attribute__((far,section (".bank0"))) +#define ATTR_BANK1 __attribute__((far,section (".bank1"))) +#define ATTR_BANK2 __attribute__((far,section (".bank2"))) +#define ATTR_BANK3 __attribute__((far,section (".bank3"))) +#define ATTR_BANK4 __attribute__((far,section (".bank4"))) +#define ATTR_BANK5 __attribute__((far,section (".bank5"))) +#define ATTR_BANK6 __attribute__((far,section (".bank6"))) +#define ATTR_BANK7 __attribute__((far,section (".bank7"))) +#define ATTR_BANK8 __attribute__((far,section (".bank8"))) +#define ATTR_BANK9 __attribute__((far,section (".bank9"))) +#define ATTR_BANK10 __attribute__((far,section (".bank10"))) +#define ATTR_BANK11 __attribute__((far,section (".bank11"))) +#define ATTR_BANK12 __attribute__((far,section (".bank12"))) +#define ATTR_BANK13 __attribute__((far,section (".bank13"))) + +#include "PE_Error.h" +#include +#include + +#endif /* ifndef __Cpu */ diff --git a/Demo/HCS12_GCC_banked/gelfunc.c b/Demo/HCS12_GCC_banked/gelfunc.c new file mode 100644 index 000000000..dcecfb4da --- /dev/null +++ b/Demo/HCS12_GCC_banked/gelfunc.c @@ -0,0 +1,25 @@ +/* gelfunc.c -- functions from GEL 1.6 + Author Jefferson Smith, Robotronics Inc. + +*/ + +#include "asm-m68hcs12/ports_def.h" +void cop_reset (void); +void cop_optional_reset (void); + +/* Reset the COP. */ +void +cop_reset (void) +{ + ARMCOP = 0x55; + ARMCOP = 0xAA; +} + +void +cop_optional_reset (void) +{ +#if defined(M6811_USE_COP) && M6811_USE_COP == 1 + cop_reset (); +#endif +} + diff --git a/Demo/HCS12_GCC_banked/ldscript-rtos.x b/Demo/HCS12_GCC_banked/ldscript-rtos.x new file mode 100644 index 000000000..c495844ea --- /dev/null +++ b/Demo/HCS12_GCC_banked/ldscript-rtos.x @@ -0,0 +1,266 @@ +/* Linker script for MC689S12DP256 Flash + rom banks. + + Author Jefferson L Smith; Robotronics, Inc. 2006 + */ +OUTPUT_FORMAT("elf32-m68hc12", "elf32-m68hc12", + "elf32-m68hc12") +OUTPUT_ARCH(m68hc12) +ENTRY(_start) + +/* Get memory banks definition from some user configuration file. + This file must be located in some linker directory (search path + with -L). See fixed memory banks emulation script. */ +INCLUDE memory.x; + +SECTIONS +{ + /* Concatenate .page0 sections. Put them in the page0 memory bank + unless we are creating a relocatable file. */ + .page0 : + { + *(.page0) + } > page0 + + /* PPAGE memory banks */ + + .bank0 : + { + *(.bank0) + . = ALIGN(2); + } > bank0 =0xff + .bank1 : + { + *(.bank1) + . = ALIGN(2); + } > bank1 =0xff + .bank2 : + { + *(.bank2) + . = ALIGN(2); + } > bank2 =0xff + .bank3 : + { + *(.bank3) + . = ALIGN(2); + } > bank3 =0xff + .bank4 : + { + *(.bank4) + . = ALIGN(2); + } > bank4 =0xff + .bank5 : + { + *(.bank5) + . = ALIGN(2); + } > bank5 =0xff + .bank6 : + { + *(.bank6) + . = ALIGN(2); + } > bank6 =0xff + .bank7 : + { + *(.bank7) + . = ALIGN(2); + } > bank7 =0xff + .bank8 : + { + *(.bank8) + . = ALIGN(2); + } > bank8 =0xff + .bank9 : + { + *(.bank9) + . = ALIGN(2); + } > bank9 =0xff + .bank10 : + { + *(.bank10) + . = ALIGN(2); + } > bank10 =0xff + .bank11 : + { + *(.bank11) + . = ALIGN(2); + } > bank11 =0xff + .bank12 : + { + *(.bank12) + . = ALIGN(2); + } > bank12 =0xff + .bank13 : + { + *(.bank13) + . = ALIGN(2); + } > bank13 =0xff + + /* Start of text section. */ + .text : + { + /* Put startup code at beginning so that _start keeps same address. */ + /* Startup code. */ + KEEP (*(.install0)) /* Section should setup the stack pointer. */ + KEEP (*(.install1)) /* Place holder for applications. */ + KEEP (*(.install2)) /* Optional installation of data sections in RAM. */ + KEEP (*(.install3)) /* Place holder for applications. */ + KEEP (*(.install4)) /* Section that calls the main. */ + *(.init) + *(.text) + *(.text.*) + *(.text_c) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.gnu.linkonce.t.*) + *(.tramp) + *(.tramp.*) + /* Finish code. */ + KEEP (*(.fini0)) /* Beginning of finish code (_exit symbol). */ + KEEP (*(.fini1)) /* Place holder for applications. */ + KEEP (*(.fini2)) /* C++ destructors. */ + KEEP (*(.fini3)) /* Place holder for applications. */ + KEEP (*(.fini4)) /* Runtime exit. */ + _etext = .; + PROVIDE (etext = .); + . = ALIGN(2); + } > text AT>bank14 =0xff + + .text_h : + { + *(.text_h) /* Bootloader; high Flash area unbanked */ + . = ALIGN(2); + } > text_h AT>bank15 =0xff + .rodata : + { + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r*) + . = ALIGN(2); + } > text_h AT>bank15 =0xff + .eh_frame : + { + KEEP (*(.eh_frame)) + . = ALIGN(2); + } > text_h AT>bank15 =0xff + + /* Constructor and destructor tables are in ROM. */ + .ctors : + { + PROVIDE (__CTOR_LIST__ = .); + KEEP (*(.ctors)) + PROVIDE(__CTOR_END__ = .); + . = ALIGN(2); + } > text_h AT>bank15 =0xff + .dtors : + { + PROVIDE(__DTOR_LIST__ = .); + KEEP (*(.dtors)) + PROVIDE(__DTOR_END__ = .); + . = ALIGN(2); + } > text_h AT>bank15 =0xff + + /* Start of the data section image in ROM. */ + __data_image = .; + PROVIDE (__data_image = .); + + /* All read-only sections that normally go in PROM must be above. + We construct the DATA image section in PROM at end of all these + read-only sections. The data image must be copied at init time. + Refer to GNU ld, Section 3.6.8.2 Output Section LMA. */ + .data : + { + __data_section_start = .; + PROVIDE (__data_section_start = .); + *(.sdata) + *(.data) + *(.data.*) + *(.data1) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + _edata = .; + PROVIDE (edata = .); + . = ALIGN(2); + } > data AT>bank15 =0xff + __data_section_size = SIZEOF(.data); + __data_image_end = __data_image + __data_section_size; + PROVIDE (__data_section_size = SIZEOF(.data)); + /* .install : + { + . = _data_image_end; + } > text */ + /* Relocation for some bss and data sections. */ + .softregs : + { + __softregs_section_start = .; + *(.softregs) + __softregs_section_end = .; + } > data + __softregs_section_size = SIZEOF(.softregs); + .bss : + { + __bss_start = .; + *(.sbss) + *(.scommon) + *(.dynbss) + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + PROVIDE (_end = .); + } > data + __bss_size = SIZEOF(.bss); + PROVIDE (__bss_size = SIZEOF(.bss)); + .eeprom : + { + *(.eeprom) + *(.eeprom.*) + . = ALIGN(2); + } > eeprom =0xff + + /* If the 'vectors_addr' symbol is defined, it indicates the start address + of interrupt vectors. This depends on the 9S12 operating mode: + Addr + Hardware location LMA 0x10ff80, mirror 0xff80 + Called by dbug12 LMA 0x10ef80, mirror 0xef80 + Ram called by dbug12 0x3e00 + The default vectors address is (LMA) 0x10ff80. This can be overriden + with the '-defsym vectors_addr=0x...' ld option. + */ + PROVIDE (_vectors_addr = DEFINED (vectors_addr) ? vectors_addr : 0x10ff80); + .vectors DEFINED (vectors_addr) ? vectors_addr : 0x10ff80 : + { + KEEP (*(.vectors)) + } + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. + Treatment of DWARF debug section must be at end of the linker + script to avoid problems when there are undefined symbols. It's necessary + to avoid that the DWARF section is relocated before such undefined + symbols are found. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } +} diff --git a/Demo/HCS12_GCC_banked/main.c b/Demo/HCS12_GCC_banked/main.c new file mode 100644 index 000000000..e1d9683f9 --- /dev/null +++ b/Demo/HCS12_GCC_banked/main.c @@ -0,0 +1,291 @@ + +/* + FreeRTOS V3.2.3 - Copyright (C) 2003-2005 Richard Barry. + + This file is part of the FreeRTOS distribution. + + FreeRTOS 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 of the License, or + (at your option) any later version. + + FreeRTOS 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 FreeRTOS; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + *************************************************************************** +*/ + + +/* + * + * main() creates all the demo application tasks, then starts the scheduler. + * The WEB documentation provides more details of the demo application tasks. + * + * main.c also creates a task called "Check". This only executes every three + * seconds but has the highest priority so is guaranteed to get processor time. + * Its main function is to check that all the other tasks are still operational. + * Each task (other than the "flash" tasks) maintains a unique count that is + * incremented each time the task successfully completes its function. Should + * any error occur within such a task the count is permanently halted. The + * check task inspects the count of each task to ensure it has changed since + * the last time the check task executed. If all the count variables have + * changed all the tasks are still executing error free, and the check task + * toggles the onboard LED. Should any task contain an error at any time + * the LED toggle rate will change from 3 seconds to 500ms. + * + * This file also includes the functionality implemented within the + * standard demo application file integer.c. This is done to demonstrate the + * use of an idle hook. See the documentation within integer.c for the + * rationale of the integer task functionality. + * */ + +/* Kernel includes. */ +#include "FreeRTOS.h" +#include "task.h" +#include "queue.h" + +#include "cpu.h" + +/* special prototypes for memory-banked functions */ +void vStartPolledQueueTasks( unsigned portBASE_TYPE uxPriority ); +portBASE_TYPE xArePollingQueuesStillRunning( void ); + +/* Demo application includes. */ +#include "flash.h" +#include "PollQ.h" +#include "dynamic.h" +#include "partest.h" +#include "comtest2.h" +#include "BlockQ.h" +#include "integer.h" +#include "death.h" + + +/*----------------------------------------------------------- + Definitions. +-----------------------------------------------------------*/ + +/* Priorities assigned to demo application tasks. */ +#define mainFLASH_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 ) +#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 1 ) +#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define mainDEATH_PRIORITY ( tskIDLE_PRIORITY + 1 ) + +/* LED that is toggled by the check task. The check task periodically checks +that all the other tasks are operating without error. If no errors are found +the LED is toggled with mainCHECK_PERIOD frequency. If an error is found +then the toggle rate increases to mainERROR_CHECK_PERIOD. */ +#define mainCHECK_TASK_LED ( 7 ) +#define mainCHECK_PERIOD ( ( portTickType ) 3000 / portTICK_RATE_MS ) +#define mainERROR_CHECK_PERIOD ( ( portTickType ) 500 / portTICK_RATE_MS ) + +/* The constants used in the idle task calculation. */ +#define intgCONST1 ( ( portLONG ) 123 ) +#define intgCONST2 ( ( portLONG ) 234567 ) +#define intgCONST3 ( ( portLONG ) -3 ) +#define intgCONST4 ( ( portLONG ) 7 ) +#define intgEXPECTED_ANSWER ( ( ( intgCONST1 + intgCONST2 ) * intgCONST3 ) / intgCONST4 ) + + +/* Baud rate used by the serial port tasks (ComTest tasks). +IMPORTANT: The function COM0_SetBaudRateValue() which is generated by the +Processor Expert is used to set the baud rate. As configured in the FreeRTOS +download this value must be one of the following: + +0 to configure for 38400 baud. +1 to configure for 19200 baud. +2 to configure for 9600 baud. +3 to configure for 4800 baud. */ +#define mainCOM_TEST_BAUD_RATE ( ( unsigned portLONG ) 2 ) + +/* LED used by the serial port tasks. This is toggled on each character Tx, +and mainCOM_TEST_LED + 1 is toggles on each character Rx. */ +#define mainCOM_TEST_LED ( 3 ) + +/*----------------------------------------------------------- + Local functions prototypes. +-----------------------------------------------------------*/ + +/* + * The 'Check' task function. See the explanation at the top of the file. + */ +static void ATTR_BANK1 vErrorChecks( void* pvParameters ); + +/* + * The idle task hook - in which the integer task is implemented. See the + * explanation at the top of the file. + */ +void ATTR_BANK0 vApplicationIdleHook( void ); + +/* + * Checks the unique counts of other tasks to ensure they are still operational. + */ +static portLONG ATTR_BANK0 prvCheckOtherTasksAreStillRunning( void ); + + + +/*----------------------------------------------------------- + Local variables. +-----------------------------------------------------------*/ + +/* A few tasks are defined within this file. This flag is used to indicate +their status. If an error is detected in one of the locally defined tasks then +this flag is set to pdTRUE. */ +portBASE_TYPE xLocalError = pdFALSE; + + +/*-----------------------------------------------------------*/ + +/* This is called from startup. */ +int ATTR_BANK0 main ( void ) +{ + /* Start some of the standard demo tasks. */ + vStartLEDFlashTasks( mainFLASH_PRIORITY ); + vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY ); + vStartDynamicPriorityTasks(); + vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED ); + vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); + vStartIntegerMathTasks( tskIDLE_PRIORITY ); + + /* Start the locally defined tasks. There is also a task implemented as + the idle hook. */ + xTaskCreate( vErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL ); + + /* Must be the last demo created. */ + vCreateSuicidalTasks( mainDEATH_PRIORITY ); + + /* All the tasks have been created - start the scheduler. */ + vTaskStartScheduler(); + + /* Should not reach here! */ + for( ;; ); + return 0; +} +/*-----------------------------------------------------------*/ + +static void vErrorChecks( void *pvParameters ) +{ +portTickType xDelayPeriod = mainCHECK_PERIOD; +portTickType xLastWakeTime; + + /* Initialise xLastWakeTime to ensure the first call to vTaskDelayUntil() + functions correctly. */ + xLastWakeTime = xTaskGetTickCount(); + + for( ;; ) + { + /* Delay until it is time to execute again. The delay period is + shorter following an error. */ + vTaskDelayUntil( &xLastWakeTime, xDelayPeriod ); + + /* Check all the demo application tasks are executing without + error. If an error is found the delay period is shortened - this + has the effect of increasing the flash rate of the 'check' task + LED. */ + if( prvCheckOtherTasksAreStillRunning() == pdFAIL ) + { + /* An error has been detected in one of the tasks - flash faster. */ + xDelayPeriod = mainERROR_CHECK_PERIOD; + } + + /* Toggle the LED each cycle round. */ + vParTestToggleLED( mainCHECK_TASK_LED ); + } +} +/*-----------------------------------------------------------*/ + +static portLONG prvCheckOtherTasksAreStillRunning( void ) +{ +portBASE_TYPE xAllTasksPassed = pdPASS; + + if( xArePollingQueuesStillRunning() != pdTRUE ) + { + xAllTasksPassed = pdFAIL; + } + + if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) + { + xAllTasksPassed = pdFAIL; + } + + if( xAreComTestTasksStillRunning() != pdTRUE ) + { + xAllTasksPassed = pdFALSE; + } + + if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) + { + xAllTasksPassed = pdFALSE; + } + + if( xAreBlockingQueuesStillRunning() != pdTRUE ) + { + xAllTasksPassed = pdFALSE; + } + + if( xIsCreateTaskStillRunning() != pdTRUE ) + { + xAllTasksPassed = pdFALSE; + } + + /* Also check the status flag for the tasks defined within this function. */ + if( xLocalError != pdFALSE ) + { + xAllTasksPassed = pdFAIL; + } + + return xAllTasksPassed; +} +/*-----------------------------------------------------------*/ + +void vApplicationIdleHook( void ) +{ +/* This variable is effectively set to a constant so it is made volatile to +ensure the compiler does not just get rid of it. */ +volatile portLONG lValue; + + /* Keep performing a calculation and checking the result against a constant. */ + + /* Perform the calculation. This will store partial value in + registers, resulting in a good test of the context switch mechanism. */ + lValue = intgCONST1; + lValue += intgCONST2; + lValue *= intgCONST3; + lValue /= intgCONST4; + + /* Did we perform the calculation correctly with no corruption? */ + if( lValue != intgEXPECTED_ANSWER ) + { + /* Error! */ + portENTER_CRITICAL(); + xLocalError = pdTRUE; + portEXIT_CRITICAL(); + } + + /* Yield in case cooperative scheduling is being used. */ + #if configUSE_PREEMPTION == 0 + { + taskYIELD(); + } + #endif +} +/*-----------------------------------------------------------*/ + diff --git a/Demo/HCS12_GCC_banked/memory.x b/Demo/HCS12_GCC_banked/memory.x new file mode 100644 index 000000000..97ff4b6dc --- /dev/null +++ b/Demo/HCS12_GCC_banked/memory.x @@ -0,0 +1,63 @@ +/* Flash Memory Banks + For Wytec Dragon12, Technological Arts Adapt9S12DP256 + with DBug12 v4 bootloader + + Author Jefferson L Smith; Robotronics, Inc. + */ + +MEMORY +{ + page0 (rwx) : ORIGIN = 0x0, LENGTH = 256 + + /* RAM */ + data (rwx) : ORIGIN = 0x1000, LENGTH = 12k + + eeprom (rx): ORIGIN = 0x0400, LENGTH = 3k + text (rx) : ORIGIN = 0x4000, LENGTH = 16k + + /* high fixed bank, reserve 0x100 vectors and security. */ + text_h (rx) : ORIGIN = 0xc000, LENGTH = 16k-0x100 + + /* Flash memory banks */ + bank0 (rx) : ORIGIN = 0x0d0000, LENGTH = 16k + bank1 (rx) : ORIGIN = 0x0d4000, LENGTH = 16k + bank2 (rx) : ORIGIN = 0x0d8000, LENGTH = 16k + bank3 (rx) : ORIGIN = 0x0dc000, LENGTH = 16k + bank4 (rx) : ORIGIN = 0x0e0000, LENGTH = 16k + bank5 (rx) : ORIGIN = 0x0e4000, LENGTH = 16k + bank6 (rx) : ORIGIN = 0x0e8000, LENGTH = 16k + bank7 (rx) : ORIGIN = 0x0ec000, LENGTH = 16k + bank8 (rx) : ORIGIN = 0x0f0000, LENGTH = 16k + bank9 (rx) : ORIGIN = 0x0f4000, LENGTH = 16k + bank10 (rx) : ORIGIN = 0x0f8000, LENGTH = 16k + bank11 (rx) : ORIGIN = 0x0fc000, LENGTH = 16k + bank12 (rx) : ORIGIN = 0x100000, LENGTH = 16k + bank13 (rx) : ORIGIN = 0x104000, LENGTH = 16k + + bank14 (rx) : ORIGIN = 0x108000, LENGTH = 16k + bank15 (rx) : ORIGIN = 0x10c000, LENGTH = 16k-0x100 +} +/* Setup the stack on the top of the data memory bank. */ +PROVIDE (_stack = 0x1000+12k); + +/* interrupt/reset vectors*/ +vectors_addr = 0x10ff80; + +SECTIONS +{ + /* PPAGE memory banks */ + + .bank2 : + { + ../Common/Minimal/flash.o(.text .rodata) + *(.bank2) + } > bank2 + + .bank3 : + { + ParTest.o(.text .rodata) + *(.bank3) + } > bank3 + +} + diff --git a/Demo/HCS12_GCC_banked/sci.c b/Demo/HCS12_GCC_banked/sci.c new file mode 100644 index 000000000..d32f7cde4 --- /dev/null +++ b/Demo/HCS12_GCC_banked/sci.c @@ -0,0 +1,75 @@ +/** + * sci.c controls SCI for GCC/HCS12 version of FreeRTOS Demo + * Parts taken from the CodeWarrior Demo in order to work similar. + * + * Author Jefferson L Smith, Robotronics Inc. + */ + +#include "sci.h" +#include + +//static word SerFlag; /* Flags for serial communication */ + /* Bits: 0 - OverRun error */ + /* 1 - Framing error */ + /* 2 - Parity error */ + /* 3 - Char in RX buffer */ + /* 4 - Full TX buffer */ + /* 5 - Running int from TX */ + /* 6 - Full RX buffer */ + /* 7 - Noise error */ + /* 8 - Idle character */ + /* 9 - Break detected */ + /* 10 - Unused */ +static word PrescaleValue; +//static byte NumMode; /* Number of selected baud mode */ + + +/** + * SCI_SetBaudRateMode + * + * Changes the speed (baud rate). + */ +byte SCI_SetBaudRateMode(byte Mod) +{ + // wired for 24 MHz bus --jeffs + static const word SCI_Presc[4] = {39,78,156,313}; + + if(Mod >= 4) /* Is mode in baud mode list */ + return ERR_VALUE; /* If no then error */ + //NumMode = Mod; /* New baud mode */ + PrescaleValue = SCI_Presc[Mod]; /* Prescaler in high speed mode */ + + /* SCI0CR1: LOOPS=0,SCISWAI=0,RSRC=0,M=0,WAKE=0,ILT=0,PE=0,PT=0 */ + SCICR1 = 0x00; /* Set the SCI configuration */ + /* SCI0SR2: ??=0,??=0,??=0,??=0,??=0,BRK13=0,TXDIR=0,RAF=0 */ + SCISR2 = 0x00; /* Set the Break Character Length and Transmitter pin data direction in Single-wire mode */ + SCISR1; /* Reset interrupt request flags */ + SCIBD = PrescaleValue; /* Set prescaler bits */ + /* SCI0CR2: SCTIE=0,TCIE=0,RIE=1,ILIE=0,TE=1,RE=1,RWU=0,SBK=0 */ + SCICR2 = 0x2c; /* Disable error interrupts */ + + return ERR_OK; /* OK */ +} + +#if 0 //(not used) + +/** + * SCI_Init (bean AsynchroSerial) + * + * This enables SCI. + */ +void SCI_Init(void) +{ + PrescaleValue = 39; /* Precaler in high speed mode */ + + /* SCI0CR1: LOOPS=0,SCISWAI=0,RSRC=0,M=0,WAKE=0,ILT=0,PE=0,PT=0 */ + SCICR1 = 0x00; /* Set the SCI configuration */ + /* SCI0SR2: ??=0,??=0,??=0,??=0,??=0,BRK13=0,TXDIR=0,RAF=0 */ + SCISR2 = 0x00; /* Set the Break Character Length and Transmitter pin data direction in Single-wire mode */ + SCISR1; /* Reset interrupt request flags */ + SCIBD = PrescaleValue; /* Set prescaler bits */ + /* SCI0CR2: SCTIE=0,TCIE=0,RIE=1,ILIE=0,TE=1,RE=1,RWU=0,SBK=0 */ + SCICR2 = 0x2c; /* Disable error interrupts */ +} +#endif + diff --git a/Demo/HCS12_GCC_banked/sci.h b/Demo/HCS12_GCC_banked/sci.h new file mode 100644 index 000000000..8a039f490 --- /dev/null +++ b/Demo/HCS12_GCC_banked/sci.h @@ -0,0 +1,34 @@ +/** + * sci.h controls SCI for GCC/HCS12 version of FreeRTOS Demo + * Parts taken from the CodeWarrior Demo in order to work similar. + * + * Author Jefferson L Smith, Robotronics Inc. + */ + +#ifndef __SCI +#define __SCI + +#include "cpu.h" + +#define COM0_Bm_38400baud 0 /* Constant for switch to mode 0 */ +#define COM0_Bm_19200baud 1 /* Constant for switch to mode 1 */ +#define COM0_Bm_9600baud 2 /* Constant for switch to mode 2 */ +#define COM0_Bm_4800baud 3 /* Constant for switch to mode 3 */ + + +/** + * SCI_SetBaudRateMode + * + * Changes the speed (baud rate). + */ +byte SCI_SetBaudRateMode(byte Mod); + + +/** + * SCI_Init (bean AsynchroSerial) + * + * This enables SCI. + */ +void SCI_Init(void); + +#endif /* ifndef __SCI */ diff --git a/Demo/HCS12_GCC_banked/serial.c b/Demo/HCS12_GCC_banked/serial.c new file mode 100644 index 000000000..93bc3b5d2 --- /dev/null +++ b/Demo/HCS12_GCC_banked/serial.c @@ -0,0 +1,150 @@ +/* + serial.c for using FreeRTOS + Copyright (C) 2005 Robotronics Inc. +*/ + + +/* BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER for port 1. + + GCC demo modifications by Jeff Smith, Robotronics Inc. 2005 +*/ + +#include "cpu.h" +#include + +/* Scheduler include files. */ +#include "FreeRTOS.h" +#include "queue.h" +#include "task.h" + +/* Demo application include files. */ +#include "sci.h" +#include "serial.h" + +/* The queues used to communicate between the task code and the interrupt +service routines. */ +static xQueueHandle xRxedChars; +static xQueueHandle xCharsForTx; + +/* Interrupt identification bits. */ +#define serOVERRUN_INTERRUPT ( '\x08' ) +#define serRX_INTERRUPT ( 0x20 ) +#define serTX_INTERRUPT ( 0x80 ) + +/*-----------------------------------------------------------*/ + + +/* + * Initialise port for interrupt driven communications. + */ +xComPortHandle xSerialPortInitMinimal( unsigned portLONG ulWantedBaud, unsigned portBASE_TYPE uxQueueLength ) +{ + /* Hardware setup is performed by the Processor Expert generated code. + This function just creates the queues used to communicate between the + interrupt code and the task code - then sets the required baud rate. */ + + xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) ); + xCharsForTx = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) ); + + SCI_SetBaudRateMode( ( portCHAR ) ulWantedBaud ); + + return NULL; +} +/*-----------------------------------------------------------*/ + +signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed portCHAR *pcRxedChar, portTickType xBlockTime ) +{ + /* Get the next character from the buffer queue. Return false if no characters + are available, or arrive before xBlockTime expires. */ + if( xQueueReceive( xRxedChars, pcRxedChar, xBlockTime ) ) + { + return pdTRUE; + } + else + { + return pdFALSE; + } +} +/*-----------------------------------------------------------*/ + +signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed portCHAR cOutChar, portTickType xBlockTime ) +{ + /* Place the character in the queue of characters to be transmitted. */ + if( xQueueSend( xCharsForTx, &cOutChar, xBlockTime ) != pdPASS ) + { + return pdFAIL; + } + + /* Turn on the Tx interrupt so the ISR will remove the character from the + queue and send it. This does not need to be in a critical section as + if the interrupt has already removed the character the next interrupt + will simply turn off the Tx interrupt again. */ + SCICR2 |= 0x80; // TIE + + return pdPASS; +} +/*-----------------------------------------------------------*/ + +void vSerialClose( xComPortHandle xPort ) +{ + /* Not supported. */ + //( void ) xPort; +} +/*-----------------------------------------------------------*/ + + +/* + * Interrupt service routine for the serial port. Must be in non-banked + * memory. + */ + +void ATTR_INT ATTR_NEAR vCOM_ISR( void ); + +void vCOM_ISR( void ) +{ +volatile unsigned portCHAR ucByte, ucStatus; +portBASE_TYPE xTaskWokenByPost = pdFALSE, xTaskWokenByTx = pdFALSE; + + /* What caused the interrupt? */ + ucStatus = SCISR1; + + if( ucStatus & serOVERRUN_INTERRUPT ) + { + /* The interrupt was caused by an overrun. Clear the error by reading + the data register. */ + ucByte = SCIDRL; + } + else + if( ucStatus & serRX_INTERRUPT ) + { + /* The interrupt was caused by a character being received. + Read the received byte. */ + ucByte = SCIDRL; + + /* Post the character onto the queue of received characters - noting + whether or not this wakes a task. */ + xTaskWokenByPost = xQueueSendFromISR( xRxedChars, ( void * ) &ucByte, pdFALSE ); + } + + if( ( ucStatus & serTX_INTERRUPT ) && ( SCICR2 & 0x80 ) ) + { + /* The interrupt was caused by a character being transmitted. */ + if( xQueueReceiveFromISR( xCharsForTx, ( void * ) &ucByte, &xTaskWokenByTx ) == pdTRUE ) + { + /* Clear the SCRF bit. */ + SCIDRL = ucByte; + } + else + { + /* Disable transmit interrupt */ + SCICR2 &= ~0x80; // TIE + } + } + + if( ( xTaskWokenByPost ) || ( xTaskWokenByTx ) ) + { + portYIELD(); + } + +} + diff --git a/Demo/HCS12_GCC_banked/startup.c b/Demo/HCS12_GCC_banked/startup.c new file mode 100644 index 000000000..48a7de53d --- /dev/null +++ b/Demo/HCS12_GCC_banked/startup.c @@ -0,0 +1,86 @@ +/* + FreeRTOS V3.2.3 - Copyright (C) 2003-2005 Richard Barry. + + This file is part of the FreeRTOS distribution. + + FreeRTOS 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 of the License, or + (at your option) any later version. + + FreeRTOS 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 FreeRTOS; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes FreeRTOS, without being obliged to provide + the source code for any proprietary components. See the licensing section + of http://www.FreeRTOS.org for full details of how and when the exception + can be applied. + + *************************************************************************** + See http://www.FreeRTOS.org for documentation, latest information, license + and contact details. Please ensure to read the configuration and relevant + port sections of the online documentation. + *************************************************************************** +*/ + + +/* + * startup.c + * Author Jefferson L Smith, Robotronics Inc. + * + * __premain() is the startup code to init hardware and ram to execute the + * C application. + * + */ + +#include +#include "cpu.h" + +void ATTR_NEAR __premain (void); + +void +__premain (void) +{ + // in case special mode enabled, avoid conflict on PORTE + PEAR |= NECLK; + // bgnd mode stops COP and RTI clocks + COPCTL = RSBCK; + // stops TCNT counter when debugging stops + TSCR1 |= (1<<5); // TFRZ + + // PLL + CLKSEL = 0; // disable PLL to configure + // xtal 16MHz, bus 24MHz + SYNR = 3 - 1; + REFDV = 2 - 1; + while (!(CRGFLG & 0x08)) // wait for PLL LOCK + cop_optional_reset(); + CLKSEL |= 0x80; // use PLL + + // init switch inputs + PERH = 0xff; // pullups + + // outputs +#if PORT_LED==M6811_PORTB //PORTB + DDRB = 0xff; // init LED +#elif PORT_LED==M6811_PORTA //PORTA + DDRA = 0xff; +#elif PORT_LED==M6811_PTT //PTT + DDRT = 0xff; +#elif PORT_LED==M6811_PTM //PTM + DDRM = 0xff; +#elif PORT_LED==M6811_PTP //PTP + DDRP = 0xff; +#elif PORT_LED==M6811_PTH //PTH + DDRH = 0xff; +#endif + +} + diff --git a/Demo/HCS12_GCC_banked/sys/interrupts.h b/Demo/HCS12_GCC_banked/sys/interrupts.h new file mode 100644 index 000000000..b783e4b95 --- /dev/null +++ b/Demo/HCS12_GCC_banked/sys/interrupts.h @@ -0,0 +1,73 @@ +/* Interrupt Vectors + Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc. + Written by Stephane Carrez (stcarrez@nerim.fr) + +This file 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. + +In addition to the permissions in the GNU General Public License, the +Free Software Foundation gives you unlimited permission to link the +compiled version of this file with other programs, and to distribute +those programs without any restriction coming from the use of this +file. (The General Public License restrictions do apply in other +respects; for example, they cover modification of the file, and +distribution when not linked into another program.) + +This file 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; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#ifndef _SYS_INTERRUPTS_H +#define _SYS_INTERRUPTS_H + +#include + +#ifdef mc6811 +//# include +#endif + +#ifdef mc68hcs12 +# include +#elif defined(mc6812) +//# include +#endif + +/*! Install an interrupt handler. + + Install the interrupt handler for an exception. The handler + is installed for \b bootstrap mode and also for \b normal operating + mode. + + @param id the interrupt number to be installed + @param handler the interrupt handler entry point +*/ +extern void +set_interrupt_handler (interrupt_vector_id id, interrupt_t handler); + +/*! Default and fatal interrupt handler. + + This function is an interrupt handler intended to be used to + handle all interrupt not used by a program. Since it is an + error to have an interrupt when it is not handled, the default + behavior is to print a message and stop. */ +extern void __attribute__((interrupt, noreturn)) +fatal_interrupt (void); + +#include + +/*! Entry point of any program. + + This function should never be called by itself. It represents the + entry point of any program. It is intended to be used in an + interrupt table to specify the function to jump to after reset. */ +extern void _start (void); + +#endif diff --git a/Demo/HCS12_GCC_banked/sys/param.h b/Demo/HCS12_GCC_banked/sys/param.h new file mode 100644 index 000000000..8dbf1a3a2 --- /dev/null +++ b/Demo/HCS12_GCC_banked/sys/param.h @@ -0,0 +1,56 @@ +/* param.h - Board specific parameters + Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc. + Written by Stephane Carrez (stcarrez@nerim.fr) + +This file 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. + +In addition to the permissions in the GNU General Public License, the +Free Software Foundation gives you unlimited permission to link the +compiled version of this file with other programs, and to distribute +those programs without any restriction coming from the use of this +file. (The General Public License restrictions do apply in other +respects; for example, they cover modification of the file, and +distribution when not linked into another program.) + +This file 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; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#ifndef _SYS_PARAM_H +#define _SYS_PARAM_H + +/*! Attribute unused. + Use this attribute to indicate that a parameter, a variable or a + static function is not used. The compiler will not warn about the + unused variable. */ +#define ATTRIBUTE_UNUSED __attribute__((unused)) + +/*! Attribute page0. + Use this attribute to put a global or static variable in page0. */ +#define PAGE0_ATTRIBUTE __attribute__((section(".page0"))) + +#ifdef mc6811 +//# include +#endif + +#ifdef mc68hcs12 +# include +#elif defined(mc6812) +//# include +#endif + +#include + +#define GNU_LINKER_WARNING(SYMBOL, MSG) \ + asm (".section .gnu.warning." SYMBOL "\n\t.string \"" MSG "\"\n\t.previous"); + +#endif diff --git a/Demo/HCS12_GCC_banked/sys/ports.h b/Demo/HCS12_GCC_banked/sys/ports.h new file mode 100644 index 000000000..934c2f399 --- /dev/null +++ b/Demo/HCS12_GCC_banked/sys/ports.h @@ -0,0 +1,69 @@ +/* sys/ports.h -- Definition of system ports + Copyright 2000, 2001, 2002 Free Software Foundation, Inc. + Written by Stephane Carrez (stcarrez@worldnet.fr) + +This file is part of GEL. + +GEL 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. + +GEL 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 GEL; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#ifndef _SYS_PORTS_H +#define _SYS_PORTS_H + +#ifdef __cplusplus +extern "C" { +#endif + + extern unsigned short get_timer_counter (void); + extern void set_timer_counter (unsigned short); + extern unsigned short get_input_capture_1 (void); + extern void set_input_capture_1 (unsigned short); + extern unsigned short get_input_capture_2 (void); + extern void set_input_capture_2 (unsigned short); + extern unsigned short get_input_capture_3 (void); + extern void set_input_capture_3 (unsigned short); + extern unsigned short get_output_compare_1 (void); + extern void set_output_compare_1 (unsigned short); + extern unsigned short get_output_compare_2 (void); + extern void set_output_compare_2 (unsigned short); + extern unsigned short get_output_compare_3 (void); + extern void set_output_compare_3 (unsigned short); + extern unsigned short get_output_compare_4 (void); + extern void set_output_compare_4 (unsigned short); + extern unsigned short get_output_compare_5 (void); + extern void set_output_compare_5 (unsigned short); + extern void set_bus_expanded (void); + extern void set_bus_single_chip (void); + extern void cop_reset (void); + extern void cop_optional_reset (void); + extern void timer_acknowledge (void); + extern void timer_initialize_rate (unsigned char); + +#ifdef mc6811 +//# include +#endif + +#ifdef mc68hcs12 +# include +#elif defined(mc6812) +//# include +#endif + +#ifdef __cplusplus +}; +#endif + +#endif /* _SYS_PORTS_H */ + diff --git a/Demo/HCS12_GCC_banked/sys/ports_def.h b/Demo/HCS12_GCC_banked/sys/ports_def.h new file mode 100644 index 000000000..8d2c74930 --- /dev/null +++ b/Demo/HCS12_GCC_banked/sys/ports_def.h @@ -0,0 +1,36 @@ +/* sys/ports_def.h -- Definition of system ports + Copyright 2000 Free Software Foundation, Inc. + Written by Stephane Carrez (stcarrez@worldnet.fr) + +This file is part of GEL. + +GEL 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. + +GEL 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 GEL; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#ifndef _SYS_PORTS_DEF_H +#define _SYS_PORTS_DEF_H + +#ifdef mc6811 +//# include +#endif + +#ifdef mc68hcs12 +# include +#elif defined(mc6812) +//# include +#endif + +#endif /* _SYS_PORTS_DEF_H */ + diff --git a/Demo/HCS12_GCC_banked/sys/sio.h b/Demo/HCS12_GCC_banked/sys/sio.h new file mode 100644 index 000000000..a28fe94fe --- /dev/null +++ b/Demo/HCS12_GCC_banked/sys/sio.h @@ -0,0 +1,80 @@ +/* sys/sio.h -- Utility methods to read/write the SIO + Copyright 2000 Free Software Foundation, Inc. + Written by Stephane Carrez (stcarrez@worldnet.fr) + +This file is part of GEL. + +GEL 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. + +GEL 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 GEL; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#ifndef _SYS_SIO_H +#define _SYS_SIO_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern void serial_init (void); + +/* Return != 0 if there is something to read on the serial line. */ +extern unsigned char serial_receive_pending (void); + +/* Wait until the SIO has finished to send the character. */ +extern void serial_flush (void); + +/* Return != 0 if serial port is ready to send another char. */ +extern unsigned char serial_send_ready (void); + +/* Send the character on the serial line. */ +extern void serial_send (char c); + +/* Wait for a character on the serial line and return it. */ +extern unsigned char serial_recv (void); + +/** Write the string on the serial line. + + @param msg null terminated string to write. + + @see serial_init, serial_send +*/ +extern void serial_print (const char *msg); + +/** Wait for a string from serial line. + + @param msg buffer that will hold the string. + + @see serial_init, serial_recv +*/ +extern void serial_getline (char *buf); + +#ifdef mc6811 +//# include +#endif + +#ifdef mc68hcs12 +# include +#elif defined(mc6812) +//# include +#endif + + +#ifdef __cplusplus +}; +#endif +#endif /* _SYS_SIO_H */ + diff --git a/Demo/HCS12_GCC_banked/vectors.c b/Demo/HCS12_GCC_banked/vectors.c new file mode 100644 index 000000000..2375a73b6 --- /dev/null +++ b/Demo/HCS12_GCC_banked/vectors.c @@ -0,0 +1,115 @@ +/* modrx.c -- wireless controller receiver for robots + Copyright 2004 Robotronics, Inc. + Author Jefferson Smith + + This file is part of the Modular Robot Design. +*/ + +#include "cpu.h" +#include +#include + +void fatal_interrupt () +{ + /* Infinite loop for debugging + Returning would not help as it's necessary to clear the interrupt flag. + */ + for (;;) cop_optional_reset(); +} + +#ifdef USE_INTERRUPT_TABLE + +/* NOTE: these ISR must be in non-banked memory (near) */ + +/* Manual context switch function. This is the SWI ISR. */ +void ATTR_INT ATTR_NEAR vPortYield( void ); + +/* Tick context switch function. This is the timer ISR. */ +void ATTR_INT ATTR_NEAR vPortTickInterrupt( void ); + +void ATTR_INT ATTR_NEAR vCOM_ISR( void ); + +/* Interrupt vectors table. + + Note: the `XXX_handler: foo' notation is a GNU extension which is + used here to ensure correct association of the handler in the struct. + This is why the order of handlers declared below does not follow + the MCU order. */ +const struct interrupt_vectors __attribute__((section(".vectors"))) vectors = +{ + pwm_shutdown_handler: fatal_interrupt, + ptpif_handler: fatal_interrupt, + can4_tx_handler: fatal_interrupt, + can4_rx_handler: fatal_interrupt, + can4_err_handler: fatal_interrupt, + can4_wake_handler: fatal_interrupt, + can3_tx_handler: fatal_interrupt, + can3_rx_handler: fatal_interrupt, + can3_err_handler: fatal_interrupt, + can3_wake_handler: fatal_interrupt, + can2_tx_handler: fatal_interrupt, + can2_rx_handler: fatal_interrupt, + can2_err_handler: fatal_interrupt, + can2_wake_handler: fatal_interrupt, + can1_tx_handler: fatal_interrupt, + can1_rx_handler: fatal_interrupt, + can1_err_handler: fatal_interrupt, + can1_wake_handler: fatal_interrupt, + can0_tx_handler: fatal_interrupt, + can0_rx_handler: fatal_interrupt, + can0_err_handler: fatal_interrupt, + can0_wake_handler: fatal_interrupt, + flash_handler: fatal_interrupt, + eeprom_handler: fatal_interrupt, + spi2_handler: fatal_interrupt, + spi1_handler: fatal_interrupt, + iic_handler: fatal_interrupt, + bdlc_handler: fatal_interrupt, + selfclk_mode_handler: fatal_interrupt, + pll_lock_handler: fatal_interrupt, + accb_overflow_handler: fatal_interrupt, + mccnt_underflow_handler: fatal_interrupt, + pthif_handler: fatal_interrupt, + ptjif_handler: fatal_interrupt, + atd1_handler: fatal_interrupt, + atd0_handler: fatal_interrupt, + sci1_handler: fatal_interrupt, + sci0_handler: fatal_interrupt, + spi0_handler: fatal_interrupt, + + /** Timer and Accumulator */ + acca_input_handler: fatal_interrupt, + acca_overflow_handler: fatal_interrupt, + timer_overflow_handler: fatal_interrupt, + + /** Input capture / Output compare Timers */ + tc7_handler: fatal_interrupt, + tc6_handler: fatal_interrupt, + tc5_handler: fatal_interrupt, + tc4_handler: fatal_interrupt, + tc3_handler: fatal_interrupt, + tc2_handler: fatal_interrupt, + tc1_handler: fatal_interrupt, + tc0_handler: fatal_interrupt, + + /** External Interrupts */ + rtii_handler: fatal_interrupt, + irq_handler: fatal_interrupt, + xirq_handler: fatal_interrupt, + + illegal_handler: fatal_interrupt, + cop_fail_handler: fatal_interrupt, + cop_clock_handler: fatal_interrupt, + + /** Vectors in use */ + swi_handler: vPortYield, + rtii_handler: vPortTickInterrupt, +#if M6812_DEF_SCI==1 + sci1_handler: vCOM_ISR, +#else + sci0_handler: vCOM_ISR, +#endif + reset_handler: _start +}; +#endif +