From 6c5e355f16e91f0a4f9aa833ba2ccdbd49abc50a Mon Sep 17 00:00:00 2001 From: richardbarry Date: Fri, 2 Sep 2011 10:49:16 +0000 Subject: [PATCH] Start an RL78 demo project. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1579 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../FreeRTOSConfig.h | 161 ++ .../RL78_RL78G13_Promo_Board_IAR/RTOSDemo.ewd | 581 ++++++ .../RL78_RL78G13_Promo_Board_IAR/RTOSDemo.ewp | 1769 +++++++++++++++++ .../RL78_RL78G13_Promo_Board_IAR/RTOSDemo.eww | 10 + Demo/RL78_RL78G13_Promo_Board_IAR/RegTest.s87 | 213 ++ Demo/RL78_RL78G13_Promo_Board_IAR/main.c | 312 +++ .../settings/rtosdemo.cspy.bat | 15 + .../settings/rtosdemo.dbgdt | 79 + .../settings/rtosdemo.dni | 184 ++ .../settings/rtosdemo.wsdt | 49 + 10 files changed, 3373 insertions(+) create mode 100644 Demo/RL78_RL78G13_Promo_Board_IAR/FreeRTOSConfig.h create mode 100644 Demo/RL78_RL78G13_Promo_Board_IAR/RTOSDemo.ewd create mode 100644 Demo/RL78_RL78G13_Promo_Board_IAR/RTOSDemo.ewp create mode 100644 Demo/RL78_RL78G13_Promo_Board_IAR/RTOSDemo.eww create mode 100644 Demo/RL78_RL78G13_Promo_Board_IAR/RegTest.s87 create mode 100644 Demo/RL78_RL78G13_Promo_Board_IAR/main.c create mode 100644 Demo/RL78_RL78G13_Promo_Board_IAR/settings/rtosdemo.cspy.bat create mode 100644 Demo/RL78_RL78G13_Promo_Board_IAR/settings/rtosdemo.dbgdt create mode 100644 Demo/RL78_RL78G13_Promo_Board_IAR/settings/rtosdemo.dni create mode 100644 Demo/RL78_RL78G13_Promo_Board_IAR/settings/rtosdemo.wsdt diff --git a/Demo/RL78_RL78G13_Promo_Board_IAR/FreeRTOSConfig.h b/Demo/RL78_RL78G13_Promo_Board_IAR/FreeRTOSConfig.h new file mode 100644 index 000000000..67505518b --- /dev/null +++ b/Demo/RL78_RL78G13_Promo_Board_IAR/FreeRTOSConfig.h @@ -0,0 +1,161 @@ +/* + FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. + + + FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: + Atollic AB - Atollic provides professional embedded systems development + tools for C/C++ development, code analysis and test automation. + See http://www.atollic.com + + + *************************************************************************** + * * + * FreeRTOS tutorial books are available in pdf and paperback. * + * Complete, revised, and edited pdf reference manuals are also * + * available. * + * * + * Purchasing FreeRTOS documentation will not only help you, by * + * ensuring you get running as quickly as possible and with an * + * in-depth knowledge of how to use FreeRTOS, it will also help * + * the FreeRTOS project to continue with its mission of providing * + * professional grade, cross platform, de facto standard solutions * + * for microcontrollers - completely free of charge! * + * * + * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * + * * + * Thank you for using FreeRTOS, and thank you for your support! * + * * + *************************************************************************** + + + 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 (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + >>>NOTE<<< The modification to the GPL is included to allow you to + distribute a combined work that includes FreeRTOS without being obliged to + provide the source code for proprietary components outside of the FreeRTOS + kernel. 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 and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * 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. + * + * See http://www.freertos.org/a00110.html. + *----------------------------------------------------------*/ + +/* This #ifdef prevents the enclosed code being included from within an +asm file. It is valid in a C file, but not valid in an asm file. */ +#ifdef __IAR_SYSTEMS_ICC__ + + #pragma language=extended + #pragma system_include + + #include + + /* Device specific includes. */ + #include + #include + +#endif /* __IAR_SYSTEMS_ICC__ */ + +#define configUSE_PREEMPTION 1 +#define configTICK_RATE_HZ ( ( portTickType ) 1000 ) +#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 4 ) +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 100 ) +#define configMAX_TASK_NAME_LEN ( 10 ) +#define configUSE_TRACE_FACILITY 0 +#define configUSE_16_BIT_TICKS 1 +#define configIDLE_SHOULD_YIELD 1 +#define configTOTAL_HEAP_SIZE ( (size_t ) ( 2900 ) ) +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configUSE_MUTEXES 1 + +/* Hook function definitions. */ +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configUSE_MALLOC_FAILED_HOOK 1 + +/* Software timer definitions. */ +#define configUSE_TIMERS 1 +#define configTIMER_TASK_PRIORITY ( 2 ) +#define configTIMER_QUEUE_LENGTH 10 +#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 ) + +/* Co-routine definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* 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 0 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 0 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_xTaskIdleTaskHandleGet 0 +#define INCLUDE_xTimerDaemonTaskHandleGet 0 + + +/****************************************************************************** + * PORT SPECIFIC CONFIGURATION OPTIONS + ******************************************************************************/ + +/* + * RL78/G13 Clock Source Configuration + * 1 = use internal High Speed Clock Source (typically 32Mhz on the RL78/G13) + * 0 = use external Clock Source + */ +#define configCLOCK_SOURCE 1 + +/* + * RL78/G13 Memory Model + * 1 = use far memory mode + * 0 = use near memory mode + * + * This setting must match the setting in the IAR project options. + */ +#define configMEMORY_MODE 0 + +#if configCLOCK_SOURCE == 0 + #define configCPU_CLOCK_HZ ( ( unsigned long ) 20000000 ) /* using the external clock source */ +#else + #define configCPU_CLOCK_HZ ( ( unsigned long ) 32000000 ) /* using the internal high speed clock */ +#endif /* configCLOCK_SOURCE */ + +#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); } + + + +#endif /* FREERTOS_CONFIG_H */ + diff --git a/Demo/RL78_RL78G13_Promo_Board_IAR/RTOSDemo.ewd b/Demo/RL78_RL78G13_Promo_Board_IAR/RTOSDemo.ewd new file mode 100644 index 000000000..c135816da --- /dev/null +++ b/Demo/RL78_RL78G13_Promo_Board_IAR/RTOSDemo.ewd @@ -0,0 +1,581 @@ + + + + 2 + + Debug + + RL78 + + 1 + + C-SPY + 1 + + 0 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + E1RL78 + 1 + + 0 + 1 + 1 + + + + + + + + + E20RL78 + 1 + + 0 + 1 + 1 + + + + + + + + + IECRL78 + 1 + + 0 + 1 + 1 + + + + + + + + + + SIMRL78 + 1 + + 0 + 1 + 1 + + + + + TKRL78 + 1 + + 0 + 1 + 1 + + + + + + + + + + $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin + 0 + + + $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\FreeRTOS\FreeRTOSPlugin.ewplugin + 0 + + + $EW_DIR$\common\plugins\OpenRTOS\OpenRTOSPlugin.ewplugin + 0 + + + $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\Stack\Stack.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin + 1 + + + + + Release + + RL78 + + 0 + + C-SPY + 1 + + 0 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + E1RL78 + 1 + + 0 + 1 + 0 + + + + + + + + + E20RL78 + 1 + + 0 + 1 + 0 + + + + + + + + + IECRL78 + 1 + + 0 + 1 + 0 + + + + + + + + + + SIMRL78 + 1 + + 0 + 1 + 0 + + + + + TKRL78 + 1 + + 0 + 1 + 0 + + + + + + + + + + $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin + 0 + + + $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\FreeRTOS\FreeRTOSPlugin.ewplugin + 0 + + + $EW_DIR$\common\plugins\OpenRTOS\OpenRTOSPlugin.ewplugin + 0 + + + $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\Stack\Stack.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\SymList\SymList.ENU.ewplugin + 1 + + + + + + diff --git a/Demo/RL78_RL78G13_Promo_Board_IAR/RTOSDemo.ewp b/Demo/RL78_RL78G13_Promo_Board_IAR/RTOSDemo.ewp new file mode 100644 index 000000000..d7784ff74 --- /dev/null +++ b/Demo/RL78_RL78G13_Promo_Board_IAR/RTOSDemo.ewp @@ -0,0 +1,1769 @@ + + + + 2 + + Debug + + RL78 + + 1 + + General + 2 + + 0 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCRL78 + 2 + + 5 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ARL78 + 2 + + 1 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CUSTOM + 3 + + + + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + XLINK + 2 + + 13 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + XAR + 2 + + 0 + 1 + 1 + + + + + + + INTERNAL_HWSUPPORT + 2 + + + + BILINK + 0 + + + + + Release + + RL78 + + 0 + + General + 2 + + 0 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCRL78 + 2 + + 5 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ARL78 + 2 + + 1 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CUSTOM + 3 + + + + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + XLINK + 2 + + 13 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + XAR + 2 + + 0 + 1 + 0 + + + + + + + INTERNAL_HWSUPPORT + 2 + + + + BILINK + 0 + + + + + Demo Source + + StandardDemos + + $PROJ_DIR$\..\Common\Minimal\blocktim.c + + + $PROJ_DIR$\..\Common\Minimal\dynamic.c + + + $PROJ_DIR$\..\Common\Minimal\GenQTest.c + + + $PROJ_DIR$\..\Common\Minimal\PollQ.c + + + $PROJ_DIR$\..\Common\Minimal\semtest.c + + + + $PROJ_DIR$\main.c + + + $PROJ_DIR$\RegTest.s87 + + + + Kernel Source + + $PROJ_DIR$\..\..\Source\portable\MemMang\heap_1.c + + + $PROJ_DIR$\..\..\Source\list.c + + + $PROJ_DIR$\..\..\Source\portable\IAR\RL78\port.c + + + $PROJ_DIR$\..\..\Source\portable\IAR\RL78\portasm.s87 + + + $PROJ_DIR$\..\..\Source\queue.c + + + $PROJ_DIR$\..\..\Source\tasks.c + + + $PROJ_DIR$\..\..\Source\timers.c + + + + + diff --git a/Demo/RL78_RL78G13_Promo_Board_IAR/RTOSDemo.eww b/Demo/RL78_RL78G13_Promo_Board_IAR/RTOSDemo.eww new file mode 100644 index 000000000..239a9381e --- /dev/null +++ b/Demo/RL78_RL78G13_Promo_Board_IAR/RTOSDemo.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\RTOSDemo.ewp + + + + + diff --git a/Demo/RL78_RL78G13_Promo_Board_IAR/RegTest.s87 b/Demo/RL78_RL78G13_Promo_Board_IAR/RegTest.s87 new file mode 100644 index 000000000..13dc31ce5 --- /dev/null +++ b/Demo/RL78_RL78G13_Promo_Board_IAR/RegTest.s87 @@ -0,0 +1,213 @@ +;/* +; FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd. +; +; *************************************************************************** +; * * +; * If you are: * +; * * +; * + New to FreeRTOS, * +; * + Wanting to learn FreeRTOS or multitasking in general quickly * +; * + Looking for basic training, * +; * + Wanting to improve your FreeRTOS skills and productivity * +; * * +; * then take a look at the FreeRTOS books - available as PDF or paperback * +; * * +; * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * +; * http://www.FreeRTOS.org/Documentation * +; * * +; * A pdf reference manual is also available. Both are usually delivered * +; * to your inbox within 20 minutes to two hours when purchased between 8am * +; * and 8pm GMT (although please allow up to 24 hours in case of * +; * exceptional circumstances). Thank you for your support! * +; * * +; *************************************************************************** +; +; 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 (version 2) as published by the +; Free Software Foundation AND MODIFIED BY the FreeRTOS exception. +; ***NOTE*** The exception to the GPL is included to allow you to distribute +; a combined work that includes FreeRTOS without being obliged to provide the +; source code for proprietary components outside of the FreeRTOS kernel. +; 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 and the FreeRTOS license exception along with FreeRTOS; if not it +; can be viewed here: http://www.freertos.org/a00114.html and also obtained +; by writing to Richard Barry, contact details for whom are available on the +; FreeRTOS WEB site. +; +; 1 tab == 4 spaces! +; +; http://www.FreeRTOS.org - Documentation, latest information, license and +; contact details. +; +; http://www.SafeRTOS.com - A version that is certified for use in safety +; critical systems. +; +; http://www.OpenRTOS.com - Commercial support, development, porting, +; licensing and training services. +;*/ + + +; +; This file defines the RegTest tasks as described at the top of main.c +; + +;------------------------------------------------------------------------------ + +#if __CORE__ != __RL78_1__ + #error "This file is only for RL78 Devices" +#endif + +; Functions implemented in this file +;------------------------------------------------------------------------------ + + PUBLIC vRegTest1 + PUBLIC vRegTest2 + +; Functions used by this file +;------------------------------------------------------------------------------ + EXTERN vRegTestError + +;------------------------------------------------------------------------------ +; Fill all the registers with known values, then check that the registers +; contain the expected value. An incorrect value being indicative of an +; error in the context switch mechanism. +; +; Input: NONE +; +; Call: Created as a task. +; +; Output: NONE +; +;------------------------------------------------------------------------------ + RSEG CODE:CODE +vRegTest1: + + ; First fill the registers. + MOVW AX, #0x1122 + MOVW BC, #0x3344 + MOVW DE, #0x5566 + MOVW HL, #0x7788 + MOV CS, #0x01 + +#if configMEMORY_MODE == 1 + + ; ES is not saved or restored when using the near memory model so only + ; test it when using the far model. + MOV ES, #0x02 + +#endif + +loop1: + + ; Continuously check that the register values remain at their expected + ; values. The BRK is to test the yield. This task runs at low priority + ; so will also regularly get preempted. + BRK + + ; Compare with the expected value. + CMPW AX, #0x1122 + BZ +5 + + ; Jump over the branch to vRegTestError() if the register contained the + ; expected value - otherwise flag an error by executing vRegTestError(). + BR vRegTestError + + ; Repeat for all the registers. + MOVW AX, BC + CMPW AX, #0x3344 + BZ +5 + BR vRegTestError + MOVW AX, DE + CMPW AX, #0x5566 + BZ +5 + BR vRegTestError + MOVW AX, HL + CMPW AX, #0x7788 + BZ +5 + BR vRegTestError + MOV A, CS + CMP A, #0x01 + BZ +5 + BR vRegTestError + +#if configMEMORY_MODE == 1 + ; ES is not saved or restored when using the near memory model so only + ; test it when using the far model. + MOV A, ES + CMP A, #0x02 + BZ +5 + BR vRegTestError + +#endif + + MOVW AX, #0x1122 + BR loop1 + + +;------------------------------------------------------------------------------ +; Fill all the registers with known values, then check that the registers +; contain the expected value. An incorrect value being indicative of an +; error in the context switch mechanism. +; +; Input: NONE +; +; Call: Created as a task. +; +; Output: NONE +; +;------------------------------------------------------------------------------ + RSEG CODE:CODE +vRegTest2: + + MOVW AX, #0x99aa + MOVW BC, #0xbbcc + MOVW DE, #0xddee + MOVW HL, #0xff12 + MOV CS, #0x03 + +#if configMEMORY_MODE == 1 + + MOV ES, #0x04 + +#endif + +loop2: + CMPW AX, #0x99aa + BZ +5 + BR vRegTestError + MOVW AX, BC + CMPW AX, #0xbbcc + BZ +5 + BR vRegTestError + MOVW AX, DE + CMPW AX, #0xddee + BZ +5 + BR vRegTestError + MOVW AX, HL + CMPW AX, #0xff12 + BZ +5 + BR vRegTestError + MOV A, CS + CMP A, #0x03 + BZ +5 + BR vRegTestError + +#if configMEMORY_MODE == 1 + + MOV A, ES + CMP A, #0x04 + BZ +5 + BR vRegTestError + +#endif + + MOVW AX, #0x99aa + BR loop2 + + + END diff --git a/Demo/RL78_RL78G13_Promo_Board_IAR/main.c b/Demo/RL78_RL78G13_Promo_Board_IAR/main.c new file mode 100644 index 000000000..49d502d36 --- /dev/null +++ b/Demo/RL78_RL78G13_Promo_Board_IAR/main.c @@ -0,0 +1,312 @@ +/* + FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. + + + FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by: + Atollic AB - Atollic provides professional embedded systems development + tools for C/C++ development, code analysis and test automation. + See http://www.atollic.com + + + *************************************************************************** + * * + * FreeRTOS tutorial books are available in pdf and paperback. * + * Complete, revised, and edited pdf reference manuals are also * + * available. * + * * + * Purchasing FreeRTOS documentation will not only help you, by * + * ensuring you get running as quickly as possible and with an * + * in-depth knowledge of how to use FreeRTOS, it will also help * + * the FreeRTOS project to continue with its mission of providing * + * professional grade, cross platform, de facto standard solutions * + * for microcontrollers - completely free of charge! * + * * + * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * + * * + * Thank you for using FreeRTOS, and thank you for your support! * + * * + *************************************************************************** + + + 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 (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + >>>NOTE<<< The modification to the GPL is included to allow you to + distribute a combined work that includes FreeRTOS without being obliged to + provide the source code for proprietary components outside of the FreeRTOS + kernel. 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 and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +/* Standard includes. */ +#include +#include + +/* Scheduler include files. */ +#include "FreeRTOS.h" +#include "task.h" +#include "timers.h" + +/* Standard demo includes. */ +#include "dynamic.h" + +/* The period at which the check timer will expire, in ms, provided no errors +have been reported by any of the standard demo tasks. ms are converted to the +equivalent in ticks using the portTICK_RATE_MS constant. */ +#define mainCHECK_TIMER_PERIOD_MS ( 3000UL / portTICK_RATE_MS ) + +/* The period at which the check timer will expire, in ms, if an error has been +reported in one of the standard demo tasks. ms are converted to the equivalent +in ticks using the portTICK_RATE_MS constant. */ +#define mainERROR_CHECK_TIMER_PERIOD_MS ( 200UL / portTICK_RATE_MS ) + +/* The LED toggled by the check task. */ +#define mainLED_0 P7_bit.no7 + +/* A block time of zero simple means "don't block". */ +#define mainDONT_BLOCK ( 0U ) + +/*-----------------------------------------------------------*/ + +/* + * The 'check' timer callback function, as described at the top of this file. + */ +static void prvCheckTimerCallback( xTimerHandle xTimer ); + +/* + * This function is called from the C startup routine to setup the processor - + * in particular the clock source. + */ +int __low_level_init(void); + +/* + * Functions that define the RegTest tasks as described at the top of this file. + */ +extern void vRegTest1( void *pvParameters ); +extern void vRegTest2( void *pvParameters ); + + +/*-----------------------------------------------------------*/ + +/* If an error is discovered by one of the RegTest tasks then this flag is set +to pdFAIL. The 'check' task then inspects this flag to detect errors within +the RegTest tasks. */ +static short sRegTestStatus = pdPASS; + +/* The check timer. This uses prvCheckTimerCallback() as its callback +function. */ +static xTimerHandle xCheckTimer = NULL; + +/* RL78/G13 Option Byte Definition. Watchdog disabled, LVI enabled, OCD interface +enabled. */ +__root __far const unsigned char OptionByte[] @ 0x00C0 = +{ + WATCHDOG_DISABLED, LVI_ENABLED, RESERVED_FF, OCD_ENABLED +}; + +/* Security byte definition */ +__root __far const unsigned char SecuIDCode[] @ 0x00C4 = +{ + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x54 +}; + +/*-----------------------------------------------------------*/ + +short main( void ) +{ + /* Creates all the tasks and timers, then starts the scheduler. */ + + /* First create the 'standard demo' tasks. These are used to demonstrate + API functions being used and also to test the kernel port. More information + is provided on the FreeRTOS.org WEB site. */ + vStartDynamicPriorityTasks(); + + /* Create the RegTest tasks as described at the top of this file. */ + xTaskCreate( vRegTest1, "Reg1", configMINIMAL_STACK_SIZE, NULL, 0, NULL ); + xTaskCreate( vRegTest2, "Reg2", configMINIMAL_STACK_SIZE, NULL, 0, NULL ); + + /* Create the software timer that performs the 'check' functionality, + as described at the top of this file. */ + xCheckTimer = xTimerCreate( ( const signed char * ) "CheckTimer",/* A text name, purely to help debugging. */ + ( mainCHECK_TIMER_PERIOD_MS ), /* The timer period, in this case 3000ms (3s). */ + pdTRUE, /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */ + ( void * ) 0, /* The ID is not used, so can be set to anything. */ + prvCheckTimerCallback /* The callback function that inspects the status of all the other tasks. */ + ); + + + /* Send a command to start the check timer. It will not actually start + until the scheduler is running (when vTaskStartScheduler() is called). */ + xTimerStart( xCheckTimer, mainDONT_BLOCK ); + + /* Finally start the scheduler running. */ + vTaskStartScheduler(); + + /* If this line is reached then vTaskStartScheduler() returned because there + was insufficient heap memory remaining for the idle task to be created. */ + for( ;; ); +} +/*-----------------------------------------------------------*/ + +static void prvCheckTimerCallback( xTimerHandle xTimer ) +{ +static portBASE_TYPE xChangedTimerPeriodAlready = pdFALSE, xErrorStatus = pdPASS; + + if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) + { + xErrorStatus = pdFAIL; + } + + if( sRegTestStatus != pdPASS ) + { + xErrorStatus = pdFAIL; + } + + if( ( xErrorStatus == pdFAIL ) && ( xChangedTimerPeriodAlready == pdFALSE ) ) + { + /* An error has occurred, but the timer's period has not yet been changed, + change it now, and remember that it has been changed. Shortening the + timer's period means the LED will toggle at a faster rate, giving a + visible indication that something has gone wrong. */ + xChangedTimerPeriodAlready = pdTRUE; + + /* This call to xTimerChangePeriod() uses a zero block time. Functions + called from inside of a timer callback function must *never* attempt to + block. */ + xTimerChangePeriod( xCheckTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK ); + } + + /* Toggle the LED. The toggle rate will depend on whether or not an error + has been found in any tasks. */ + mainLED_0 = !mainLED_0; +} +/*-----------------------------------------------------------*/ + +int __low_level_init(void) +{ +unsigned portCHAR ucResetFlag = RESF; + + portDISABLE_INTERRUPTS(); + + /* Clock Configuration: + In this port, to use the internal high speed clock source of the + microcontroller, define the configCLOCK_SOURCE as 1 in FreeRTOSConfig.h. To + use an external clock define configCLOCK_SOURCE as 0. */ + #if configCLOCK_SOURCE == 1 + { + /* Set fMX */ + CMC = 0x00; + MSTOP = 1U; + + /* Set fMAIN */ + MCM0 = 0U; + + /* Set fSUB */ + XTSTOP = 1U; + OSMC = 0x10; + + /* Set fCLK */ + CSS = 0U; + + /* Set fIH */ + HIOSTOP = 0U; + } + #else + { + unsigned char ucTempStabset, ucTempStabWait; + + /* Set fMX */ + CMC = 0x41; + OSTS = 0x07; + MSTOP = 0U; + ucTempStabset = 0xFF; + + do + { + ucTempStabWait = OSTC; + ucTempStabWait &= ucTempStabset; + } + while( ucTempStabWait != ucTempStabset ); + + /* Set fMAIN */ + MCM0 = 1U; + + /* Set fSUB */ + XTSTOP = 1U; + OSMC = 0x10; + + /* Set fCLK */ + CSS = 0U; + + /* Set fIH */ + HIOSTOP = 0U; + } + #endif /* configCLOCK_SOURCE == 1 */ + + /* LED port initialization - set port register. */ + P7 &= 0x7F; + + /* Set port mode register. */ + PM7 &= 0x7F; + + /* Switch pin initialization - enable pull-up resistor. */ + PU12_bit.no0 = 1; + + return pdTRUE; +} +/*-----------------------------------------------------------*/ + +void vRegTestError( void ) +{ + /* Called by the RegTest tasks if an error is found. lRegTestStatus is + inspected by the check task. */ + sRegTestStatus = pdFAIL; + + /* Do not return from here as the reg test tasks clobber all registers so + function calls may not function correctly. */ + for( ;; ); +} +/*-----------------------------------------------------------*/ + +void vApplicationMallocFailedHook( void ) +{ + /* Called if a call to pvPortMalloc() fails because there is insufficient + free memory available in the FreeRTOS heap. pvPortMalloc() is called + internally by FreeRTOS API functions that create tasks, queues, software + timers, and semaphores. The size of the FreeRTOS heap is set by the + configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */ + taskDISABLE_INTERRUPTS(); + for( ;; ); +} +/*-----------------------------------------------------------*/ + +void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName ) +{ + ( void ) pcTaskName; + ( void ) pxTask; + + /* Run time stack overflow checking is performed if + configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook + function is called if a stack overflow is detected. */ + taskDISABLE_INTERRUPTS(); + for( ;; ); +} diff --git a/Demo/RL78_RL78G13_Promo_Board_IAR/settings/rtosdemo.cspy.bat b/Demo/RL78_RL78G13_Promo_Board_IAR/settings/rtosdemo.cspy.bat new file mode 100644 index 000000000..7de18dc14 --- /dev/null +++ b/Demo/RL78_RL78G13_Promo_Board_IAR/settings/rtosdemo.cspy.bat @@ -0,0 +1,15 @@ +@REM This batch file has been generated by the IAR Embedded Workbench +@REM C-SPY Debugger, as an aid to preparing a command line for running +@REM the cspybat command line utility using the appropriate settings. +@REM +@REM You can launch cspybat by typing the name of this batch file followed +@REM by the name of the debug file (usually an ELF/DWARF or UBROF file). +@REM Note that this file is generated every time a new debug session +@REM is initialized, so you may want to move or rename the file before +@REM making changes. +@REM + + +"C:\devtools\IAR Systems\Embedded Workbench 6.0\common\bin\cspybat" "C:\devtools\IAR Systems\Embedded Workbench 6.0\rl78\bin\rl78proc.dll" "C:\devtools\IAR Systems\Embedded Workbench 6.0\rl78\bin\rl78ocd.dll" %1 --plugin "C:\devtools\IAR Systems\Embedded Workbench 6.0\rl78\bin\rl78bat.dll" --backend -B "--core" "rl78_1" "--near_const_location" "rom0" "--near_const_start" "0xf2000" "--near_const_size" "51.75" "-p" "C:\devtools\IAR Systems\Embedded Workbench 6.0\rl78\CONFIG\DDF\ior5f100le.ddf" "-d" "e1" + + diff --git a/Demo/RL78_RL78G13_Promo_Board_IAR/settings/rtosdemo.dbgdt b/Demo/RL78_RL78G13_Promo_Board_IAR/settings/rtosdemo.dbgdt new file mode 100644 index 000000000..dc7c22732 --- /dev/null +++ b/Demo/RL78_RL78G13_Promo_Board_IAR/settings/rtosdemo.dbgdt @@ -0,0 +1,79 @@ + + + + + + + + + 20912 + + + + + + 2068418245 + + + + + + + 270272727 + + + + + + 111 + + + + + + + + + TabID-30626-17561 + Debug Log + Debug-Log + + + + TabID-30103-17570 + Build + Build + + + + + 0 + + + TabID-8606-17564 + Workspace + Workspace + + + RTOSDemo + + + + 0 + + + + + + TextEditor$WS_DIR$\main.c012361386138TextEditor$WS_DIR$\..\..\Source\include\portable.h04192849284TextEditor$WS_DIR$\..\..\Source\tasks.c04552020820208TextEditor$WS_DIR$\FreeRTOSConfig.h09553565356TextEditor$WS_DIR$\..\..\Source\portable\IAR\RL78\port.c0600TextEditor$WS_DIR$\..\..\Source\queue.c02028462846TextEditor$WS_DIR$\..\..\Source\portable\IAR\RL78\portasm.s8703529652965TextEditor$WS_DIR$\..\..\Source\include\FreeRTOS.h011864326476TextEditor$WS_DIR$\..\..\Source\portable\IAR\RL78\portmacro.h05137113711TextEditor$WS_DIR$\..\..\Source\list.c03003157TextEditor$WS_DIR$\RegTest.s87018300TextEditor$WS_DIR$\..\Common\Minimal\dynamic.c03441481914819110100000010000001 + + + + + + + iaridepm.enu1debuggergui.enu1rl78ocd.enu1-2-2662344-2-2346254205952258656205952676171-2-22521682-2-216842541002381258656205952258656 + + + + diff --git a/Demo/RL78_RL78G13_Promo_Board_IAR/settings/rtosdemo.dni b/Demo/RL78_RL78G13_Promo_Board_IAR/settings/rtosdemo.dni new file mode 100644 index 000000000..841fe4bee --- /dev/null +++ b/Demo/RL78_RL78G13_Promo_Board_IAR/settings/rtosdemo.dni @@ -0,0 +1,184 @@ +[InterruptLog] +LogEnabled=0 +SumEnabled=0 +GraphEnabled=0 +ShowTimeLog=1 +ShowTimeSum=1 +SumSortOrder=0 +[Interrupts] +Enabled=1 +[MemoryMap] +Enabled=0 +Base=0 +UseAuto=0 +TypeViolation=1 +UnspecRange=1 +ActionState=1 +[DebugChecksum] +Checksum=-445921582 +[DisAssemblyWindow] +NumStates=_ 1 +State 1=_ 1 +[InstructionProfiling] +Enabled=_ 0 +[CodeCoverage] +Enabled=_ 0 +[E1] +Map0=0,0,65535,65536 +Map1=1,1044224,1048319,4096 +MapEntries=2 +HWsettings=1,0,0,0,4,0,1,0,16,16 +HWsettingsCube=2,4294967295,2,4294967295,0,1,0,0 +HWsettingsRsuid=55555555555555555554 +EventEntries=0 +SeqName0= +SeqData0=0,0 +SeqEnable10=0,0,0,0,0,0,0,0,0,0 +SeqEnable20=0,0,0,0,0,0,0,0,0,0 +SeqEnable30=0,0,0,0,0,0,0,0,0,0 +SeqEnable40=0,0,0,0,0,0,0,0,0,0 +SeqDisable0=0,0,0,0,0,0,0,0,0,0 +SeqData20=0,0,0,0,0,0 +SeqName1= +SeqData1=0,0 +SeqEnable11=0,0,0,0,0,0,0,0,0,0 +SeqEnable21=0,0,0,0,0,0,0,0,0,0 +SeqEnable31=0,0,0,0,0,0,0,0,0,0 +SeqEnable41=0,0,0,0,0,0,0,0,0,0 +SeqDisable1=0,0,0,0,0,0,0,0,0,0 +SeqData21=0,0,0,0,0,0 +SeqName2= +SeqData2=0,0 +SeqEnable12=0,0,0,0,0,0,0,0,0,0 +SeqEnable22=0,0,0,0,0,0,0,0,0,0 +SeqEnable32=0,0,0,0,0,0,0,0,0,0 +SeqEnable42=0,0,0,0,0,0,0,0,0,0 +SeqDisable2=0,0,0,0,0,0,0,0,0,0 +SeqData22=0,0,0,0,0,0 +SeqName3= +SeqData3=0,0 +SeqEnable13=0,0,0,0,0,0,0,0,0,0 +SeqEnable23=0,0,0,0,0,0,0,0,0,0 +SeqEnable33=0,0,0,0,0,0,0,0,0,0 +SeqEnable43=0,0,0,0,0,0,0,0,0,0 +SeqDisable3=0,0,0,0,0,0,0,0,0,0 +SeqData23=0,0,0,0,0,0 +SeqName4= +SeqData4=0,0 +SeqEnable14=0,0,0,0,0,0,0,0,0,0 +SeqEnable24=0,0,0,0,0,0,0,0,0,0 +SeqEnable34=0,0,0,0,0,0,0,0,0,0 +SeqEnable44=0,0,0,0,0,0,0,0,0,0 +SeqDisable4=0,0,0,0,0,0,0,0,0,0 +SeqData24=0,0,0,0,0,0 +TraceSettings=64,0,0,0,0,0,8192 +TimerSettings=0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +CoverSettings=1048192,1048207,0 +Version=1,trace.txt +LastDevFile=DR5F100LE.DVF +EmulType=64 +BreakToggle=0 +EventLimits=0, 1, 1, 0, 0, 0, 2 +LastSetupFailed=0 +[StackPlugin] +Enabled=1 +OverflowWarningsEnabled=1 +WarningThreshold=90 +SpWarningsEnabled=1 +WarnHow=0 +UseTrigger=1 +TriggerName=main +LimitSize=0 +ByteLimit=50 +[TK] +LastSetupFailed=1 +Map0=0,0,65535,65536 +Map1=1,1044224,1048319,4096 +MapEntries=2 +HWsettings=1,0,0,2,4,0,1,0,16,1 +HWsettingsCube=2,4294967295,2,4294967295,0,1,0,0 +HWsettingsRsuid=AAAAAAAAAAAAAAAAAAAA +EventEntries=0 +SeqName0= +SeqData0=0,0 +SeqEnable10=0,0,0,0,0,0,0,0,0,0 +SeqEnable20=0,0,0,0,0,0,0,0,0,0 +SeqEnable30=0,0,0,0,0,0,0,0,0,0 +SeqEnable40=0,0,0,0,0,0,0,0,0,0 +SeqDisable0=0,0,0,0,0,0,0,0,0,0 +SeqData20=0,0,0,0,0,0 +SeqName1= +SeqData1=0,0 +SeqEnable11=0,0,0,0,0,0,0,0,0,0 +SeqEnable21=0,0,0,0,0,0,0,0,0,0 +SeqEnable31=0,0,0,0,0,0,0,0,0,0 +SeqEnable41=0,0,0,0,0,0,0,0,0,0 +SeqDisable1=0,0,0,0,0,0,0,0,0,0 +SeqData21=0,0,0,0,0,0 +SeqName2= +SeqData2=0,0 +SeqEnable12=0,0,0,0,0,0,0,0,0,0 +SeqEnable22=0,0,0,0,0,0,0,0,0,0 +SeqEnable32=0,0,0,0,0,0,0,0,0,0 +SeqEnable42=0,0,0,0,0,0,0,0,0,0 +SeqDisable2=0,0,0,0,0,0,0,0,0,0 +SeqData22=0,0,0,0,0,0 +SeqName3= +SeqData3=0,0 +SeqEnable13=0,0,0,0,0,0,0,0,0,0 +SeqEnable23=0,0,0,0,0,0,0,0,0,0 +SeqEnable33=0,0,0,0,0,0,0,0,0,0 +SeqEnable43=0,0,0,0,0,0,0,0,0,0 +SeqDisable3=0,0,0,0,0,0,0,0,0,0 +SeqData23=0,0,0,0,0,0 +SeqName4= +SeqData4=0,0 +SeqEnable14=0,0,0,0,0,0,0,0,0,0 +SeqEnable24=0,0,0,0,0,0,0,0,0,0 +SeqEnable34=0,0,0,0,0,0,0,0,0,0 +SeqEnable44=0,0,0,0,0,0,0,0,0,0 +SeqDisable4=0,0,0,0,0,0,0,0,0,0 +SeqData24=0,0,0,0,0,0 +TraceSettings=64,0,0,0,0,0,8192 +TimerSettings=0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +CoverSettings=1048192,1048207,0 +Version=1,xxx.txt +LastDevFile=DR5F100LE.DVF +EmulType=0 +BreakToggle=0 +EventLimits=3, 14, 8, 0, 0, 0, 9999 +[Stack] +FillEnabled=0 +OverflowWarningsEnabled=1 +WarningThreshold=90 +SpWarningsEnabled=1 +WarnLogOnly=1 +UseTrigger=1 +TriggerName=main +LimitSize=0 +ByteLimit=50 +[CallStack] +ShowArgs=0 +[Log file] +LoggingEnabled=_ 0 +LogFile=_ "" +Category=_ 0 +[TermIOLog] +LoggingEnabled=_ 0 +LogFile=_ "" +[TraceHelper] +Enabled=0 +ShowSource=1 +[CallStackLog] +Enabled=0 +[DriverProfiling] +Enabled=0 +Mode=0 +Graph=0 +Symbiont=0 +[Breakpoints] +Count=0 +[Aliases] +A0=_ "C:\Data\RL78_STICK\FreeRTOSV6.1.1\Source\portable\IAR\RL78\portasm.s87" "E:\Data\RL78_STICK\FreeRTOSV6.1.1\Source\portable\IAR\RL78\portasm.s87" +Count=1 +SuppressDialog=1 diff --git a/Demo/RL78_RL78G13_Promo_Board_IAR/settings/rtosdemo.wsdt b/Demo/RL78_RL78G13_Promo_Board_IAR/settings/rtosdemo.wsdt new file mode 100644 index 000000000..3732f78d1 --- /dev/null +++ b/Demo/RL78_RL78G13_Promo_Board_IAR/settings/rtosdemo.wsdt @@ -0,0 +1,49 @@ + + + + + + RTOSDemo/Debug + + + + + + + + + 244272727 + + 206841824520121811143962753 + + + + + + TabID-25565-17041 + Workspace + Workspace + + + RTOSDemoRTOSDemo/Demo SourceRTOSDemo/Kernel Source + + + + 0TabID-4654-17433BuildBuildTabID-14113-4559Debug LogDebug-LogTabID-7454-1824Find in FilesFind-in-Files0 + + + + + + TextEditor$WS_DIR$\main.c01236138613800100000010000001 + + + + + + + iaridepm.enu1-2-2629318-2-2263200156548203666190476642566-2-23091682-2-216843111002381316701205357258656 + + + + -- 2.39.5