New demo files for HCS12 GCC port.
This commit is contained in:
92
Demo/HCS12_GCC_banked/FreeRTOSConfig.h
Normal file
92
Demo/HCS12_GCC_banked/FreeRTOSConfig.h
Normal file
@ -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 */
|
64
Demo/HCS12_GCC_banked/Makefile
Normal file
64
Demo/HCS12_GCC_banked/Makefile
Normal file
@ -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
|
||||
|
53
Demo/HCS12_GCC_banked/PE_Error.h
Normal file
53
Demo/HCS12_GCC_banked/PE_Error.h
Normal file
@ -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
|
78
Demo/HCS12_GCC_banked/ParTest.c
Normal file
78
Demo/HCS12_GCC_banked/ParTest.c
Normal file
@ -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 <sys/ports.h>
|
||||
|
||||
/* 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<<uxLED); /* Set appropriate bit on port */
|
||||
}
|
||||
else { /* Is it zero to be written? */
|
||||
LEDIO &= ~(1<<uxLED); /* Clear appropriate bit on port */
|
||||
}
|
||||
portEXIT_CRITICAL();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
|
||||
{
|
||||
/* This function is required as it is called from the standard demo
|
||||
application files. It manipulates a bit to control one LED. */
|
||||
portENTER_CRITICAL();
|
||||
LEDIO ^= (1<<uxLED); /* Invert appropriate bit on port */
|
||||
portEXIT_CRITICAL();
|
||||
}
|
||||
|
85
Demo/HCS12_GCC_banked/README.txt
Normal file
85
Demo/HCS12_GCC_banked/README.txt
Normal file
@ -0,0 +1,85 @@
|
||||
##-------------------------------------------------------------------
|
||||
## Readme.txt
|
||||
##
|
||||
## FreeRTOS Port Example for GCC/HCS12, called "Demo/HCS12_GCC_banked"
|
||||
## Author Jefferson L Smith
|
||||
##
|
||||
##-------------------------------------------------------------------
|
||||
This project stationery is designed to get you up and running quickly with GCC for MC9S12.
|
||||
|
||||
This port is tested with the development board Dragon12 (http://www.evbplus.com/ ).
|
||||
|
||||
This GCC release has been tested:
|
||||
gnu-m68hc1x 3.1 from http://m68hc11.serveftp.org/
|
||||
|
||||
The following folders are derived from GEL 1.6 (http://gel.sourceforge.net/ ):
|
||||
- sys: starting point for GEL system includes
|
||||
- asm-m68hcs12: specific 9S12 support, mostly referenced by sys
|
||||
|
||||
The demo was partially derived from Demo HCS12_CodeWarrior_banked.
|
||||
|
||||
|
||||
##------------------------------------------------------------------------
|
||||
## Getting Started
|
||||
##------------------------------------------------------------------------
|
||||
|
||||
---
|
||||
The COM (SCI) port to use can be changed in the Makefile. Change this parameter in
|
||||
CPPFLAGS: -DM6812_DEF_SCI=1
|
||||
0 uses SCI0
|
||||
1 uses SCI1
|
||||
|
||||
---
|
||||
The LED port address can be changed in the Makefile. Change this parameter in
|
||||
CPPFLAGS: -DPORT_LED=M6811_PORTB
|
||||
|
||||
The known ports are: M6811_PORTA, M6811_PORTB, M6811_PTT, M6811_PTP, M6811_PTM, and M6811_PTH. Any other port address could be used.
|
||||
|
||||
If a known port (above) is used, "startup.c" will initialize the correct port. If any other port is used (by typing the port address), it will need to be manually configured as outputs.
|
||||
|
||||
|
||||
##------------------------------------------------------------------------
|
||||
## Memory Banks (PPAGE)
|
||||
##------------------------------------------------------------------------
|
||||
|
||||
---
|
||||
HCS12_GCC_banked uses two methods of placing certain code/data into PPAGE banks. The simple way is to edit each function's prototype or definition with an attribute macro ATTR_BANKn as defined in "cpu.h". Replace the 'n' with the number of the bank [0..13].
|
||||
|
||||
Also see "memory.x" sections .bank2 and .bank3 for examples of linking .text and .rodata of a specific ".o" object file into a specific bank.
|
||||
|
||||
|
||||
##------------------------------------------------------------------------
|
||||
## Technical Issues
|
||||
##------------------------------------------------------------------------
|
||||
|
||||
---
|
||||
Passing a function pointer to vCreateTasks() does not include the PPAGE value. The result is that it's stack is initialized with PPAGE 0x30. That is not a problem because GCC generates a "trampoline" routine in unbanked memory which will bounce to the far address of the target function. The 16-bit function pointer passed is actually pointing to that trampoline. The trampoline would only be called once--when starting the task.
|
||||
|
||||
---
|
||||
Here are three aspects to consider when defining ISR:
|
||||
|
||||
1. The ISR might be simple enough to not generate header code such as saving _.frame and has no local variables. This type can be defined as a normal routine (no interrupt attribute) or "naked" if it were implemented in this GCC. IMPORTANT: Use these special port macros defined in "portmacro.h". They go at the beginning and end of the function:
|
||||
|
||||
portISR_HEAD() First line of the ISR
|
||||
portISR_TAIL() Last line of the ISR
|
||||
|
||||
This ensures all the needed softregs (pseudo CPU registers) are saved on the stack in case of a task swap within the ISR. Because this sets up the stack for a task swap, portTASK_SWITCH_FROM_ISR() could also be used in the ISR to save time and stack space.
|
||||
|
||||
2. The ISR may have one or more local variables. Define it using the interrupt attribute. The special portTASK_SWITCH_FROM_ISR() won't work. If a task is awakened within this ISR, use taskYIELD() which completely saves the appropriate softregs again and uses more stack.
|
||||
|
||||
3. Writing an ISR in assembly avoids the challenges with compiler-generated code. The steps would have to execute the way they execute in the C ISR.
|
||||
|
||||
---
|
||||
If editing "startup.c", note that the function __premain() executes before global variables are initialized, and before the BSS section is cleared. So using any global variables may have unexpected results.
|
||||
|
||||
---
|
||||
If you need to use other softregs, edit "portmacro.h" and "port.c" to save/restore them For example _.d1, _.d2, enabled by "-msoft-reg-count=2" on gcc commandline.
|
||||
|
||||
This port expects "-msoft-reg-count=0". This might be the gcc default, but is specified to be certain.
|
||||
|
||||
|
||||
##------------------------------------------------------------------------
|
||||
## TODO
|
||||
##------------------------------------------------------------------------
|
||||
|
||||
---
|
43
Demo/HCS12_GCC_banked/asm-m68hcs12/arch-dragon12/arch/exit.h
Normal file
43
Demo/HCS12_GCC_banked/asm-m68hcs12/arch-dragon12/arch/exit.h
Normal file
@ -0,0 +1,43 @@
|
||||
/* exit.h - Dragon12 development board
|
||||
Copyright (C) 2004 Robotronics, Inc.
|
||||
Author Jefferson Smith, Robotronics
|
||||
|
||||
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 _M68HC12_ARCH_DRAGON12_EXIT_H
|
||||
#define _M68HC12_ARCH_DRAGON12_EXIT_H
|
||||
|
||||
extern void _exit (short status) __attribute__((noreturn));
|
||||
|
||||
/* For Dbug monitor, use swi to enter in the monitor upon exit. */
|
||||
extern inline void
|
||||
_exit (short status)
|
||||
{
|
||||
while (1) {
|
||||
__asm__ __volatile__ ("bgnd" : : );
|
||||
__asm__ __volatile__ ("swi" : : "d"(status));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,41 @@
|
||||
/* interrupts.h - Register interrupt vectors (if ram based)
|
||||
Copyright (C) 2004 Robotronics, Inc.
|
||||
Author Jefferson Smith, Robotronics
|
||||
|
||||
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 _M68HC12_ARCH_DRAGON12_INTERRUPTS_H
|
||||
#define _M68HC12_ARCH_DRAGON12_INTERRUPTS_H
|
||||
|
||||
#define USE_INTERRUPT_TABLE
|
||||
|
||||
/* Only for RAM target. Initializes an interrupt handler vector. */
|
||||
extern inline void
|
||||
set_interrupt_handler (interrupt_vector_id id ATTRIBUTE_UNUSED,
|
||||
interrupt_t handler ATTRIBUTE_UNUSED)
|
||||
{
|
||||
_vectors_addr[id] = handler;
|
||||
}
|
||||
|
||||
#endif /* _M68HC12_ARCH_DRAGON12_INTERRUPTS_H */
|
@ -0,0 +1,47 @@
|
||||
/* param.h - Dragon12 development board
|
||||
Copyright (C) 2004 Robotronics, Inc.
|
||||
Author Jefferson Smith, Robotronics
|
||||
|
||||
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 _M68S12_ARCH_DRAGON12_PARAM_H
|
||||
#define _M68S12_ARCH_DRAGON12_PARAM_H
|
||||
|
||||
/* Wytec Dragon12 board definitions. */
|
||||
#define DRAGON12
|
||||
|
||||
/* An application can use these to determine resources of MCU. --jeffs */
|
||||
#undef RAM_SIZE
|
||||
#define RAM_SIZE (12*1024) /* Kb of ram */
|
||||
|
||||
#undef ROM_SIZE
|
||||
#define ROM_SIZE (256*1024) /* Kb read-only */
|
||||
|
||||
#undef DATA_SIZE
|
||||
#define DATA_SIZE RAM_SIZE /* Data section size. */
|
||||
|
||||
#undef TEXT_SIZE
|
||||
#define TEXT_SIZE ROM_SIZE /* Text section size. */
|
||||
|
||||
#endif
|
197
Demo/HCS12_GCC_banked/asm-m68hcs12/interrupts-dp256.h
Normal file
197
Demo/HCS12_GCC_banked/asm-m68hcs12/interrupts-dp256.h
Normal file
@ -0,0 +1,197 @@
|
||||
/* Interrupt Vectors defined
|
||||
Copyright (C) 2004 Robotronics, Inc.
|
||||
Author Jefferson Smith, Robotronics
|
||||
|
||||
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 _M68HC12_ASM_INTERRUPTS_DP256_H
|
||||
#define _M68HC12_ASM_INTERRUPTS_DP256_H
|
||||
|
||||
/** Interrupt vectors as a struct. */
|
||||
struct interrupt_vectors
|
||||
{
|
||||
interrupt_t res0_handler; /* 0x80 */
|
||||
interrupt_t res1_handler; /* 0x82 */
|
||||
interrupt_t res2_handler; /* 0x84 */
|
||||
interrupt_t res3_handler; /* 0x86 */
|
||||
interrupt_t res4_handler; /* 0x88 */
|
||||
interrupt_t res5_handler; /* 0x8a */
|
||||
interrupt_t pwm_shutdown_handler; /* 0x8c */
|
||||
interrupt_t ptpif_handler;
|
||||
|
||||
/** Controller Area Networking */
|
||||
interrupt_t can4_tx_handler;
|
||||
interrupt_t can4_rx_handler;
|
||||
interrupt_t can4_err_handler;
|
||||
interrupt_t can4_wake_handler;
|
||||
interrupt_t can3_tx_handler;
|
||||
interrupt_t can3_rx_handler;
|
||||
interrupt_t can3_err_handler;
|
||||
interrupt_t can3_wake_handler;
|
||||
interrupt_t can2_tx_handler;
|
||||
interrupt_t can2_rx_handler;
|
||||
interrupt_t can2_err_handler;
|
||||
interrupt_t can2_wake_handler;
|
||||
interrupt_t can1_tx_handler;
|
||||
interrupt_t can1_rx_handler;
|
||||
interrupt_t can1_err_handler;
|
||||
interrupt_t can1_wake_handler;
|
||||
interrupt_t can0_tx_handler;
|
||||
interrupt_t can0_rx_handler;
|
||||
interrupt_t can0_err_handler;
|
||||
interrupt_t can0_wake_handler;
|
||||
|
||||
interrupt_t flash_handler;
|
||||
interrupt_t eeprom_handler;
|
||||
interrupt_t spi2_handler;
|
||||
interrupt_t spi1_handler;
|
||||
interrupt_t iic_handler;
|
||||
interrupt_t bdlc_handler;
|
||||
interrupt_t selfclk_mode_handler;
|
||||
interrupt_t pll_lock_handler;
|
||||
interrupt_t accb_overflow_handler;
|
||||
interrupt_t mccnt_underflow_handler;
|
||||
interrupt_t pthif_handler;
|
||||
interrupt_t ptjif_handler;
|
||||
interrupt_t atd1_handler;
|
||||
interrupt_t atd0_handler;
|
||||
interrupt_t sci1_handler;
|
||||
interrupt_t sci0_handler;
|
||||
interrupt_t spi0_handler;
|
||||
|
||||
/** Timer and Accumulator */
|
||||
interrupt_t acca_input_handler;
|
||||
interrupt_t acca_overflow_handler;
|
||||
interrupt_t timer_overflow_handler;
|
||||
|
||||
/** Input capture / Output compare Timers */
|
||||
interrupt_t tc7_handler;
|
||||
interrupt_t tc6_handler;
|
||||
interrupt_t tc5_handler;
|
||||
interrupt_t tc4_handler;
|
||||
interrupt_t tc3_handler;
|
||||
interrupt_t tc2_handler;
|
||||
interrupt_t tc1_handler;
|
||||
interrupt_t tc0_handler;
|
||||
|
||||
/** External Interrupts */
|
||||
interrupt_t rtii_handler;
|
||||
interrupt_t irq_handler;
|
||||
interrupt_t xirq_handler;
|
||||
|
||||
/** Software Interrupt */
|
||||
interrupt_t swi_handler;
|
||||
|
||||
/** Illegal Instruction Reset */
|
||||
interrupt_t illegal_handler;
|
||||
|
||||
/** COP Timeout Reset */
|
||||
interrupt_t cop_fail_handler;
|
||||
|
||||
/** Clock Monitor Fail Reset */
|
||||
interrupt_t cop_clock_handler;
|
||||
|
||||
/** Start or Reset vector */
|
||||
interrupt_t reset_handler;
|
||||
};
|
||||
typedef struct interrupt_vectors interrupt_vectors_t;
|
||||
|
||||
/** Interrupt vector id. */
|
||||
enum interrupt_vector_id
|
||||
{
|
||||
RES0_VECTOR = 0,
|
||||
RES1_VECTOR,
|
||||
RES2_VECTOR,
|
||||
RES3_VECTOR,
|
||||
RES4_VECTOR,
|
||||
RES5_VECTOR,
|
||||
PWM_SHUTDOWN_VECTOR,
|
||||
PTPIF_VECTOR,
|
||||
CAN4_TX_VECTOR,
|
||||
CAN4_RX_VECTOR,
|
||||
CAN4_ERR_VECTOR,
|
||||
CAN4_WAKE_VECTOR,
|
||||
CAN3_TX_VECTOR,
|
||||
CAN3_RX_VECTOR,
|
||||
CAN3_ERR_VECTOR,
|
||||
CAN3_WAKE_VECTOR,
|
||||
CAN2_TX_VECTOR,
|
||||
CAN2_RX_VECTOR,
|
||||
CAN2_ERR_VECTOR,
|
||||
CAN2_WAKE_VECTOR,
|
||||
CAN1_TX_VECTOR,
|
||||
CAN1_RX_VECTOR,
|
||||
CAN1_ERR_VECTOR,
|
||||
CAN1_WAKE_VECTOR,
|
||||
CAN0_TX_VECTOR,
|
||||
CAN0_RX_VECTOR,
|
||||
CAN0_ERR_VECTOR,
|
||||
CAN0_WAKE_VECTOR,
|
||||
FLASH_VECTOR,
|
||||
EEPROM_VECTOR,
|
||||
SPI2_VECTOR,
|
||||
SPI1_VECTOR,
|
||||
IIC_VECTOR,
|
||||
BDLC_VECTOR,
|
||||
SELFCLK_MODE_VECTOR,
|
||||
PLL_LOCK_VECTOR,
|
||||
ACCB_OVERFLOW_VECTOR,
|
||||
MCCNT_UNDERFLOW_VECTOR,
|
||||
PTHIF_VECTOR,
|
||||
PTJIF_VECTOR,
|
||||
ATD1_VECTOR,
|
||||
ATD0_VECTOR,
|
||||
SCI1_VECTOR,
|
||||
SCI0_VECTOR,
|
||||
SPI0_VECTOR,
|
||||
ACCA_INPUT_VECTOR,
|
||||
ACCA_OVERFLOW_VECTOR,
|
||||
TIMER_OVERFLOW_VECTOR,
|
||||
TC7_VECTOR,
|
||||
TC6_VECTOR,
|
||||
TC5_VECTOR,
|
||||
TC4_VECTOR,
|
||||
TC3_VECTOR,
|
||||
TC2_VECTOR,
|
||||
TC1_VECTOR,
|
||||
TC0_VECTOR,
|
||||
RTI_VECTOR,
|
||||
IRQ_VECTOR,
|
||||
XIRQ_VECTOR,
|
||||
SWI_VECTOR,
|
||||
ILLEGAL_OPCODE_VECTOR,
|
||||
COP_FAIL_VECTOR,
|
||||
COP_CLOCK_VECTOR,
|
||||
RESET_VECTOR,
|
||||
MAX_VECTORS
|
||||
};
|
||||
typedef enum interrupt_vector_id interrupt_vector_id;
|
||||
|
||||
/** some backwards-compatible equivalents from HC11 */
|
||||
#define SCI_VECTOR SCI0_VECTOR
|
||||
#define SPI_VECTOR SPI0_VECTOR
|
||||
#define ACC_INPUT_VECTOR ACCA_INPUT_VECTOR
|
||||
#define ACC_OVERFLOW_VECTOR ACCA_OVERFLOW_VECTOR
|
||||
|
||||
#endif /* _M68HC12_ASM_INTERRUPTS_DP256_H */
|
54
Demo/HCS12_GCC_banked/asm-m68hcs12/interrupts.h
Normal file
54
Demo/HCS12_GCC_banked/asm-m68hcs12/interrupts.h
Normal file
@ -0,0 +1,54 @@
|
||||
/* Interrupt Vectors
|
||||
Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
Written by Stephane Carrez (stcarrez@worldnet.fr)
|
||||
Modified; Jefferson Smith, Robotronics; for HC12/9S12
|
||||
|
||||
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 _M68HC12_INTERRUPTS_H
|
||||
#define _M68HC12_INTERRUPTS_H
|
||||
|
||||
/*! @defgroup interrupts Interrupts.
|
||||
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/*! Interrupt handler prototype. */
|
||||
typedef void (* interrupt_t) (void);
|
||||
|
||||
#ifdef mc68hcs12
|
||||
# include "interrupts-dp256.h"
|
||||
#endif
|
||||
|
||||
/*! Interrupt vector table.
|
||||
|
||||
The interrupt vector table is in general located at `0xff80'
|
||||
in memory. It is at the same address as the interrupt
|
||||
vectors structure (alias). */
|
||||
extern interrupt_t _vectors_addr[MAX_VECTORS];
|
||||
|
||||
extern interrupt_vectors_t _vectors __asm__("_vectors_addr");
|
||||
|
||||
/*@}*/
|
||||
#endif /* _M68HC12_INTERRUPTS_H */
|
99
Demo/HCS12_GCC_banked/asm-m68hcs12/param.h
Normal file
99
Demo/HCS12_GCC_banked/asm-m68hcs12/param.h
Normal file
@ -0,0 +1,99 @@
|
||||
/* param.h - Board specific parameters
|
||||
Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
Written by Stephane Carrez (stcarrez@worldnet.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 _M68HC11_PARAM_H
|
||||
#define _M68HC11_PARAM_H
|
||||
|
||||
/**@name M68HC12 Board Parameters.
|
||||
|
||||
This section contains several '#define' to give configuration
|
||||
characteristics of the target board. */
|
||||
/*@{*/
|
||||
|
||||
/** CPU Clock frequency.
|
||||
|
||||
Define the frequency of the oscillator plugged on the processor.
|
||||
The value is in hertz. */
|
||||
#ifndef M6811_CPU_CLOCK
|
||||
# define M6811_CPU_CLOCK (16e6L)
|
||||
#endif
|
||||
|
||||
/** CPU E clock.
|
||||
|
||||
The E clock frequency. This frequency is used as the
|
||||
basis for timer computation. The value is in hertz. */
|
||||
#ifndef M6811_CPU_E_CLOCK
|
||||
# define M6811_CPU_E_CLOCK (24e6L)
|
||||
#endif
|
||||
|
||||
#ifndef M6812_REFCLOCK
|
||||
# define M6812_REFCLOCK M6811_CPU_CLOCK
|
||||
#endif
|
||||
|
||||
#ifndef M6812_REFDVVAL
|
||||
# define M6812_REFDVVAL (M6811_CPU_CLOCK / M6812_REFCLOCK) - 1
|
||||
#endif
|
||||
|
||||
#ifndef M6812_SYNRVAL
|
||||
#define M6812_SYNRVAL (M6811_CPU_E_CLOCK / M6812_REFCLOCK) - 1
|
||||
#endif
|
||||
|
||||
/** SIO default baud rate.
|
||||
|
||||
Defines the default baud rate of the SIO. This value
|
||||
is used to configure the BAUD register.
|
||||
*/
|
||||
#ifndef M6811_DEF_BAUD
|
||||
# define M6811_DEF_BAUD (unsigned short)(M6811_CPU_E_CLOCK / 16 / 9600)
|
||||
#endif
|
||||
|
||||
/** Use the COP.
|
||||
|
||||
Define this if you are using the COP timer.
|
||||
This activate the COP reset while polling and writing on
|
||||
the serial line. */
|
||||
#ifndef M6811_USE_COP
|
||||
# define M6811_USE_COP 0
|
||||
#endif
|
||||
|
||||
/** Timer prescaler value. */
|
||||
#ifndef M6811_DEF_TPR
|
||||
# define M6811_DEF_TPR 0
|
||||
#endif
|
||||
|
||||
#ifndef M6811_DEF_RTR
|
||||
# define M6811_DEF_RTR 0
|
||||
#endif
|
||||
|
||||
/** SCI default port. */
|
||||
#ifndef M6812_DEF_SCI
|
||||
# define M6812_DEF_SCI 0
|
||||
#endif
|
||||
|
||||
/*@}*/
|
||||
|
||||
#endif
|
192
Demo/HCS12_GCC_banked/asm-m68hcs12/ports.h
Normal file
192
Demo/HCS12_GCC_banked/asm-m68hcs12/ports.h
Normal file
@ -0,0 +1,192 @@
|
||||
/* m68hc11/ports.h -- Definition of 68HC11 ports
|
||||
Copyright 1999, 2000, 2003 Free Software Foundation, Inc.
|
||||
Written by Stephane Carrez (stcarrez@nerim.fr)
|
||||
|
||||
Modified by Jefferson L Smith, Robotronics Inc.
|
||||
|
||||
This file is part of GDB, GAS, and the GNU binutils.
|
||||
|
||||
GDB, GAS, and the GNU binutils are free software; you can redistribute
|
||||
them and/or modify them under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either version
|
||||
1, or (at your option) any later version.
|
||||
|
||||
GDB, GAS, and the GNU binutils are distributed in the hope that they
|
||||
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 file; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _M68HC11_PORTS_H
|
||||
#define _M68HC11_PORTS_H
|
||||
|
||||
#include "ports_def.h"
|
||||
|
||||
/** Define default SCI port registers */
|
||||
#if defined(M6812_DEF_SCI)
|
||||
|
||||
#if M6812_DEF_SCI==2
|
||||
# define SCI_BASE SCI2_BASE
|
||||
#elif M6812_DEF_SCI==1
|
||||
# define SCI_BASE SCI1_BASE
|
||||
#else /* default M6812_DEF_SCI==0 */
|
||||
# define SCI_BASE SCI0_BASE
|
||||
#endif /* default M6812_DEF_SCI==0 */
|
||||
|
||||
#else /* M6812_DEF_SCI not defined */
|
||||
# define SCI_BASE SCI0_BASE
|
||||
#endif /* M6812_DEF_SCI */
|
||||
|
||||
# define SCIBD PORTIO_16(SCI_BASE + _SCIBD)
|
||||
# define SCICR1 PORTIO_8(SCI_BASE + _SCICR1)
|
||||
# define SCICR2 PORTIO_8(SCI_BASE + _SCICR2)
|
||||
# define SCISR1 PORTIO_8(SCI_BASE + _SCISR1)
|
||||
# define SCISR2 PORTIO_8(SCI_BASE + _SCISR2)
|
||||
# define SCIDRL PORTIO_8(SCI_BASE + _SCIDRL)
|
||||
|
||||
extern inline unsigned short
|
||||
get_timer_counter (void)
|
||||
{
|
||||
return TCNT;
|
||||
}
|
||||
|
||||
extern inline void
|
||||
set_timer_counter (unsigned short value)
|
||||
{
|
||||
TCNT = value;
|
||||
}
|
||||
#if 0
|
||||
extern inline unsigned short
|
||||
get_input_capture_1 (void)
|
||||
{
|
||||
return ((unsigned volatile short*) &_io_ports[M6811_TIC1_H])[0];
|
||||
}
|
||||
|
||||
extern inline void
|
||||
set_input_capture_1 (unsigned short value)
|
||||
{
|
||||
((unsigned volatile short*) &_io_ports[M6811_TIC1_H])[0] = value;
|
||||
}
|
||||
|
||||
extern inline unsigned short
|
||||
get_input_capture_2 (void)
|
||||
{
|
||||
return ((unsigned volatile short*) &_io_ports[M6811_TIC2_H])[0];
|
||||
}
|
||||
|
||||
extern inline void
|
||||
set_input_capture_2 (unsigned short value)
|
||||
{
|
||||
((unsigned volatile short*) &_io_ports[M6811_TIC2_H])[0] = value;
|
||||
}
|
||||
|
||||
extern inline unsigned short
|
||||
get_input_capture_3 (void)
|
||||
{
|
||||
return ((unsigned volatile short*) &_io_ports[M6811_TIC3_H])[0];
|
||||
}
|
||||
|
||||
extern inline void
|
||||
set_input_capture_3 (unsigned short value)
|
||||
{
|
||||
((unsigned volatile short*) &_io_ports[M6811_TIC3_H])[0] = value;
|
||||
}
|
||||
|
||||
/* Get output compare 16-bit register. */
|
||||
extern inline unsigned short
|
||||
get_output_compare_1 (void)
|
||||
{
|
||||
return ((unsigned volatile short*) &_io_ports[M6811_TOC1_H])[0];
|
||||
}
|
||||
|
||||
extern inline void
|
||||
set_output_compare_1 (unsigned short value)
|
||||
{
|
||||
((unsigned volatile short*) &_io_ports[M6811_TOC1_H])[0] = value;
|
||||
}
|
||||
|
||||
extern inline unsigned short
|
||||
get_output_compare_2 (void)
|
||||
{
|
||||
return ((unsigned volatile short*) &_io_ports[M6811_TOC2_H])[0];
|
||||
}
|
||||
|
||||
extern inline void
|
||||
set_output_compare_2 (unsigned short value)
|
||||
{
|
||||
((unsigned volatile short*) &_io_ports[M6811_TOC2_H])[0] = value;
|
||||
}
|
||||
|
||||
extern inline unsigned short
|
||||
get_output_compare_3 (void)
|
||||
{
|
||||
return ((unsigned volatile short*) &_io_ports[M6811_TOC3_H])[0];
|
||||
}
|
||||
|
||||
extern inline void
|
||||
set_output_compare_3 (unsigned short value)
|
||||
{
|
||||
((unsigned volatile short*) &_io_ports[M6811_TOC3_H])[0] = value;
|
||||
}
|
||||
|
||||
extern inline unsigned short
|
||||
get_output_compare_4 (void)
|
||||
{
|
||||
return ((unsigned volatile short*) &_io_ports[M6811_TOC4_H])[0];
|
||||
}
|
||||
|
||||
extern inline void
|
||||
set_output_compare_4 (unsigned short value)
|
||||
{
|
||||
((unsigned volatile short*) &_io_ports[M6811_TOC4_H])[0] = value;
|
||||
}
|
||||
|
||||
extern inline unsigned short
|
||||
get_output_compare_5 (void)
|
||||
{
|
||||
return ((unsigned volatile short*) &_io_ports[M6811_TOC5_H])[0];
|
||||
}
|
||||
|
||||
extern inline void
|
||||
set_output_compare_5 (unsigned short value)
|
||||
{
|
||||
((unsigned volatile short*) &_io_ports[M6811_TOC5_H])[0] = value;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Reset the COP. */
|
||||
extern inline void
|
||||
cop_reset (void)
|
||||
{
|
||||
ARMCOP = 0x55;
|
||||
ARMCOP = 0xAA;
|
||||
}
|
||||
|
||||
extern inline void
|
||||
cop_optional_reset (void)
|
||||
{
|
||||
#if defined(M6811_USE_COP) && M6811_USE_COP == 1
|
||||
cop_reset ();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Acknowledge the timer interrupt. */
|
||||
extern inline void
|
||||
timer_acknowledge (void)
|
||||
{
|
||||
CRGFLG = RTIF;
|
||||
}
|
||||
|
||||
/* Initialize the timer. */
|
||||
extern inline void
|
||||
timer_initialize_rate (unsigned char divisor)
|
||||
{
|
||||
RTICTL = divisor;
|
||||
}
|
||||
|
||||
#endif /* _M68HC11_PORTS_H */
|
||||
|
666
Demo/HCS12_GCC_banked/asm-m68hcs12/ports_def.h
Normal file
666
Demo/HCS12_GCC_banked/asm-m68hcs12/ports_def.h
Normal file
File diff suppressed because it is too large
Load Diff
81
Demo/HCS12_GCC_banked/asm-m68hcs12/sio.h
Normal file
81
Demo/HCS12_GCC_banked/asm-m68hcs12/sio.h
Normal file
@ -0,0 +1,81 @@
|
||||
/* m68hc11/sio.h -- Utility methods to read/write the SIO
|
||||
Copyright 1999, 2000, 2003 Free Software Foundation, Inc.
|
||||
Written by Stephane Carrez (stcarrez@nerim.fr)
|
||||
|
||||
This file is part of GDB, GAS, and the GNU binutils.
|
||||
|
||||
GDB, GAS, and the GNU binutils are free software; you can redistribute
|
||||
them and/or modify them under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either version
|
||||
1, or (at your option) any later version.
|
||||
|
||||
GDB, GAS, and the GNU binutils are distributed in the hope that they
|
||||
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 file; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _M68HC12_SIO_H
|
||||
#define _M68HC12_SIO_H
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/ports.h>
|
||||
|
||||
/* 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 */
|
||||
|
39
Demo/HCS12_GCC_banked/cpu.h
Normal file
39
Demo/HCS12_GCC_banked/cpu.h
Normal file
@ -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 <sys/param.h>
|
||||
#include <sys/ports.h>
|
||||
|
||||
#endif /* ifndef __Cpu */
|
25
Demo/HCS12_GCC_banked/gelfunc.c
Normal file
25
Demo/HCS12_GCC_banked/gelfunc.c
Normal file
@ -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
|
||||
}
|
||||
|
266
Demo/HCS12_GCC_banked/ldscript-rtos.x
Normal file
266
Demo/HCS12_GCC_banked/ldscript-rtos.x
Normal file
@ -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<dir>). 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) }
|
||||
}
|
291
Demo/HCS12_GCC_banked/main.c
Normal file
291
Demo/HCS12_GCC_banked/main.c
Normal file
@ -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
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
63
Demo/HCS12_GCC_banked/memory.x
Normal file
63
Demo/HCS12_GCC_banked/memory.x
Normal file
@ -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
|
||||
|
||||
}
|
||||
|
75
Demo/HCS12_GCC_banked/sci.c
Normal file
75
Demo/HCS12_GCC_banked/sci.c
Normal file
@ -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 <sys/ports.h>
|
||||
|
||||
//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
|
||||
|
34
Demo/HCS12_GCC_banked/sci.h
Normal file
34
Demo/HCS12_GCC_banked/sci.h
Normal file
@ -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 */
|
150
Demo/HCS12_GCC_banked/serial.c
Normal file
150
Demo/HCS12_GCC_banked/serial.c
Normal file
@ -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 <sys/sio.h>
|
||||
|
||||
/* 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
86
Demo/HCS12_GCC_banked/startup.c
Normal file
86
Demo/HCS12_GCC_banked/startup.c
Normal file
@ -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 <sys/ports.h>
|
||||
#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
|
||||
|
||||
}
|
||||
|
73
Demo/HCS12_GCC_banked/sys/interrupts.h
Normal file
73
Demo/HCS12_GCC_banked/sys/interrupts.h
Normal file
@ -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 <sys/param.h>
|
||||
|
||||
#ifdef mc6811
|
||||
//# include <asm-m68hc11/interrupts.h>
|
||||
#endif
|
||||
|
||||
#ifdef mc68hcs12
|
||||
# include <asm-m68hcs12/interrupts.h>
|
||||
#elif defined(mc6812)
|
||||
//# include <asm-m68hc12/interrupts.h>
|
||||
#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 <arch/interrupts.h>
|
||||
|
||||
/*! 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
|
56
Demo/HCS12_GCC_banked/sys/param.h
Normal file
56
Demo/HCS12_GCC_banked/sys/param.h
Normal file
@ -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 <asm-m68hc11/param.h>
|
||||
#endif
|
||||
|
||||
#ifdef mc68hcs12
|
||||
# include <asm-m68hcs12/param.h>
|
||||
#elif defined(mc6812)
|
||||
//# include <asm-m68hc12/param.h>
|
||||
#endif
|
||||
|
||||
#include <arch/param.h>
|
||||
|
||||
#define GNU_LINKER_WARNING(SYMBOL, MSG) \
|
||||
asm (".section .gnu.warning." SYMBOL "\n\t.string \"" MSG "\"\n\t.previous");
|
||||
|
||||
#endif
|
69
Demo/HCS12_GCC_banked/sys/ports.h
Normal file
69
Demo/HCS12_GCC_banked/sys/ports.h
Normal file
@ -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 <asm-m68hc11/ports.h>
|
||||
#endif
|
||||
|
||||
#ifdef mc68hcs12
|
||||
# include <asm-m68hcs12/ports.h>
|
||||
#elif defined(mc6812)
|
||||
//# include <asm-m68hc12/ports.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_PORTS_H */
|
||||
|
36
Demo/HCS12_GCC_banked/sys/ports_def.h
Normal file
36
Demo/HCS12_GCC_banked/sys/ports_def.h
Normal file
@ -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 <asm-m68hc11/ports_def.h>
|
||||
#endif
|
||||
|
||||
#ifdef mc68hcs12
|
||||
# include <asm-m68hcs12/ports_def.h>
|
||||
#elif defined(mc6812)
|
||||
//# include <asm-m68hc12/ports_def.h>
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_PORTS_DEF_H */
|
||||
|
80
Demo/HCS12_GCC_banked/sys/sio.h
Normal file
80
Demo/HCS12_GCC_banked/sys/sio.h
Normal file
@ -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 <sys/param.h>
|
||||
#include <sys/ports.h>
|
||||
|
||||
#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 <asm-m68hc11/sio.h>
|
||||
#endif
|
||||
|
||||
#ifdef mc68hcs12
|
||||
# include <asm-m68hcs12/sio.h>
|
||||
#elif defined(mc6812)
|
||||
//# include <asm-m68hc12/sio.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
#endif /* _SYS_SIO_H */
|
||||
|
115
Demo/HCS12_GCC_banked/vectors.c
Normal file
115
Demo/HCS12_GCC_banked/vectors.c
Normal file
@ -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 <sys/ports.h>
|
||||
#include <sys/interrupts.h>
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user