diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/.cproject b/FreeRTOS/Demo/RL78_E2Studio_GCC/.cproject
index b4e3afce3..046f15423 100644
--- a/FreeRTOS/Demo/RL78_E2Studio_GCC/.cproject
+++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/.cproject
@@ -57,7 +57,9 @@
-
+
@@ -207,6 +209,212 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/.settings/Project_Generation_Prefrences.prefs b/FreeRTOS/Demo/RL78_E2Studio_GCC/.settings/Project_Generation_Prefrences.prefs
index 5df2fe290..173fe2f6d 100644
--- a/FreeRTOS/Demo/RL78_E2Studio_GCC/.settings/Project_Generation_Prefrences.prefs
+++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/.settings/Project_Generation_Prefrences.prefs
@@ -1,4 +1,4 @@
-#Fri Feb 22 15:43:45 GMT 2013
+#Mon Mar 04 17:13:11 GMT 2013
Library\ Generator\ Command=rl78-elf-libgen
com.renesas.cdt.core.Assembler.option.includeFileDirectories="${workspace_loc\:/${ProjName}}\\src";
com.renesas.cdt.core.Compiler.option.includeFileDir.1067754383="${TCINSTALL}\\rl78-elf\\optlibinc";
@@ -15,4 +15,5 @@ com.renesas.cdt.rl78.HardwareDebug.Compiler.option.cpuType.1364542281=RL78 - G1C
com.renesas.cdt.rl78.HardwareDebug.Compiler.option.mmul=None
com.renesas.cdt.rl78.HardwareDebug.Linker.option.archiveLibraryFiles=${ProjName};gcc;
com.renesas.cdt.rl78.HardwareDebug.Linker.option.archiveSearchDirectories.970009502="${CONFIGDIR}";"${TCINSTALL}\\lib\\gcc\\rl78-elf\\\\${GCC_VERSION}";
+com.renesas.cdt.rl78.HardwareDebug.Linker.option.archiveSearchDirectories.984802356="${CONFIGDIR}";"${TCINSTALL}\\lib\\gcc\\rl78-elf\\\\${GCC_VERSION}";
eclipse.preferences.version=1
diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/RTOSDemo.launch b/FreeRTOS/Demo/RL78_E2Studio_GCC/RTOSDemo.launch
index 3519abbb3..cb05de36e 100644
--- a/FreeRTOS/Demo/RL78_E2Studio_GCC/RTOSDemo.launch
+++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/RTOSDemo.launch
@@ -8,7 +8,7 @@
-
+
@@ -20,7 +20,7 @@
-
+
@@ -61,7 +61,7 @@
-
+
@@ -70,6 +70,8 @@
+
+
diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOSConfig.h b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOSConfig.h
index c2c21766e..82dff1b8e 100644
--- a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOSConfig.h
+++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOSConfig.h
@@ -91,12 +91,12 @@
#define configTICK_RATE_HZ ( ( unsigned short ) 1000 )
#define configCPU_CLOCK_HZ ( ( unsigned long ) 32000000 ) /* Using the internal high speed clock */
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 4 )
-#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 80 )
+#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 ) ( 3420 ) )
+#define configTOTAL_HEAP_SIZE ( (size_t ) ( 5000 ) )
#define configCHECK_FOR_STACK_OVERFLOW 2
#define configUSE_MUTEXES 1
@@ -127,7 +127,7 @@ to exclude the API function. */
#define INCLUDE_xTaskGetIdleTaskHandle 0
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
-#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }
+#define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled()
#define __DATA_MODEL_FAR__ 0
#define __DATA_MODEL_NEAR__ 1
diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/port.c b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/port.c
index fba4634a6..a5bb44ce6 100644
--- a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/port.c
+++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/port.c
@@ -150,9 +150,9 @@ unsigned long *pulLocal;
/* These values are just spacers. The return address of the function
would normally be written here. */
- *pxTopOfStack = ( portSTACK_TYPE ) 0xcdcd;
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x00;
pxTopOfStack--;
- *pxTopOfStack = ( portSTACK_TYPE ) 0xcdcd;
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x00;
pxTopOfStack--;
/* The start address / PSW value is also written in as a 32bit value,
@@ -186,6 +186,29 @@ unsigned long *pulLocal;
}
#endif
+#ifdef This_was_an_alternative_to_the_two_above
+ /* Parameters are passed in on the stack. */
+ *pxTopOfStack = ( portSTACK_TYPE ) pvParameters;
+ pxTopOfStack--;
+
+#warning Why is the offset necessary? Presumably because the parameter could be 20 bits.
+ pxTopOfStack--;
+ pxTopOfStack--;
+
+ /* Task function address is written to the stack first. As it is
+ written as a 32bit value a space is left on the stack for the second
+ two bytes. */
+ pxTopOfStack--;
+
+ /* Task function start address combined with the PSW. */
+ pulLocal = ( unsigned long * ) pxTopOfStack;
+ *pulLocal = ( ( ( unsigned long ) pxCode ) | ( portPSW << 24UL ) );
+ pxTopOfStack--;
+
+ /* An initial value for the AX register. */
+ *pxTopOfStack = ( portSTACK_TYPE ) 0xaaaa;
+ pxTopOfStack--;
+#endif
/* An initial value for the HL register. */
*pxTopOfStack = ( portSTACK_TYPE ) 0x2222;
pxTopOfStack--;
diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/portmacro.h b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/portmacro.h
index 3cd6e2a7c..f3d5c2184 100644
--- a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/portmacro.h
+++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/portmacro.h
@@ -99,11 +99,12 @@ extern "C" {
#define portSTACK_TYPE unsigned short
#define portBASE_TYPE short
-#if __DATA_MODEL__ == __DATA_MODEL_FAR__
- #define portPOINTER_SIZE_TYPE unsigned long
-#else
- #define portPOINTER_SIZE_TYPE unsigned short
-#endif
+//_RB_#if __DATA_MODEL__ == __DATA_MODEL_FAR__
+// #define portPOINTER_SIZE_TYPE unsigned long
+//#else
+// #define portPOINTER_SIZE_TYPE unsigned short
+//#endif
+#define portPOINTER_SIZE_TYPE unsigned short
#if ( configUSE_16_BIT_TICKS == 1 )
diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/LED.h b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/LED.h
index b51c12516..5e55bbd3a 100644
--- a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/LED.h
+++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/LED.h
@@ -85,8 +85,8 @@
#endif /* YRPBRL78G13 */
#ifdef YRDKRL78G14
- #define LED_BIT ( P1_bit.no0 )
- #define LED_INIT() P1 &= 0xFE; PM1 &= 0xFE
+ #define LED_INIT() PM4_bit.no1 = 0
+ #define LED_BIT ( P4_bit.no1 )
#endif /* YRDKRL78G14 */
#ifdef RSKRL78G1C
diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/RegTest.S b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/RegTest.S
index 0ed9d52b7..63587c62e 100644
--- a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/RegTest.S
+++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/RegTest.S
@@ -76,9 +76,10 @@
* This file defines the RegTest tasks as described at the top of main.c
*/
-
- .global vRegTest1
- .global vRegTest2
+ .global _vRegTest1Task
+ .short _vRegTest1Task
+ .global _vRegTest2Task
+ .short _vRegTest2Task
.extern _vRegTestError
.extern _usRegTest1LoopCounter
@@ -90,7 +91,7 @@
* contain the expected value. An incorrect value being indicative of an
* error in the context switch mechanism.
*/
-vRegTest1:
+_vRegTest1Task:
/* First fill the registers. */
MOVW AX, #0x1122
@@ -116,29 +117,29 @@ _loop1:
/* Compare with the expected value. */
CMPW AX, #0x1122
- BZ $5
+ BZ $.+5
/* Jump over the branch to vRegTestError() if the register contained the
expected value - otherwise flag an error by executing vRegTestError(). */
- BR !_vRegTestError
+ BR !!_vRegTestError
/* Repeat for all the registers. */
MOVW AX, BC
CMPW AX, #0x3344
- BZ $5
- BR !_vRegTestError
+ BZ $.+5
+ BR !!_vRegTestError
MOVW AX, DE
CMPW AX, #0x5566
- BZ $5
- BR !_vRegTestError
+ BZ $.+5
+ BR !!_vRegTestError
MOVW AX, HL
CMPW AX, #0x7788
- BZ $5
- BR !_vRegTestError
+ BZ $.+5
+ BR !!_vRegTestError
MOV A, CS
CMP A, #0x01
- BZ $5
- BR !_vRegTestError
+ BZ $.+5
+ BR !!_vRegTestError
#if __DATA_MODEL__ == __DATA_MODEL_FAR__
@@ -146,8 +147,8 @@ _loop1:
test it when using the far model. */
MOV A, ES
CMP A, #0x02
- BZ $5
- BR !_vRegTestError
+ BZ $.+5
+ BR !!_vRegTestError
#endif
@@ -155,7 +156,7 @@ _loop1:
INCW !_usRegTest1LoopCounter
MOVW AX, #0x1122
- BR !_loop1
+ BR !!_loop1
/*
@@ -163,7 +164,7 @@ _loop1:
* contain the expected value. An incorrect value being indicative of an
* error in the context switch mechanism.
*/
-vRegTest2:
+_vRegTest2Task:
MOVW AX, #0x99aa
MOVW BC, #0xbbcc
@@ -179,31 +180,31 @@ vRegTest2:
_loop2:
CMPW AX, #0x99aa
- BZ $5
- BR !_vRegTestError
+ BZ $.+5
+ BR !!_vRegTestError
MOVW AX, BC
CMPW AX, #0xbbcc
- BZ $5
- BR !_vRegTestError
+ BZ $.+5
+ BR !!_vRegTestError
MOVW AX, DE
CMPW AX, #0xddee
- BZ $5
- BR !_vRegTestError
+ BZ $.+5
+ BR !!_vRegTestError
MOVW AX, HL
CMPW AX, #0xff12
- BZ $5
- BR !_vRegTestError
+ BZ $.+5
+ BR !!_vRegTestError
MOV A, CS
CMP A, #0x03
- BZ $5
- BR !_vRegTestError
+ BZ $.+5
+ BR !!_vRegTestError
#if __DATA_MODEL__ == __DATA_MODEL_FAR__
MOV A, ES
CMP A, #0x04
- BZ $5
- BR !_vRegTestError
+ BZ $.+5
+ BR !!_vRegTestError
#endif
@@ -211,8 +212,7 @@ _loop2:
INCW !_usRegTest2LoopCounter
MOVW AX, #0x99aa
- BR !_loop2
-
+ BR !!_loop2
.end
diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/hardware_setup.c b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/hardware_setup.c
index 001539271..211185831 100644
--- a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/hardware_setup.c
+++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/hardware_setup.c
@@ -15,8 +15,9 @@
/* Hardware includes. */
#include "port_iodefine.h"
+#include "LED.h"
-void HardwareSetup(void)
+void HardwareSetup( void )
{
unsigned char ucResetFlag = RESF;
diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/main.c b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/main.c
index 4a6e6d1b0..0a1aaa242 100644
--- a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/main.c
+++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/main.c
@@ -159,6 +159,11 @@ its own executions. */
/* A block time of zero simple means "don't block". */
#define mainDONT_BLOCK ( 0U )
+/* Values that are passed as parameters into the reg test tasks (purely to
+ensure task parameters are passed correctly). */
+#define mainREG_TEST_1_PARAMETER ( ( void * ) 0x1234 )
+#define mainREG_TEST_2_PARAMETER ( ( void * ) 0x5678 )
+
/*-----------------------------------------------------------*/
/*
@@ -172,11 +177,22 @@ static void prvCheckTimerCallback( xTimerHandle xTimer );
static void prvDemoTimerCallback( xTimerHandle xTimer );
/*
- * Functions that define the RegTest tasks, as described at the top of this file.
+ * Functions that define the RegTest tasks, as described at the top of this
+ * file. The RegTest tasks are written (necessarily) in assembler. Their
+ * entry points are written in C to allow for easy checking of the task
+ * parameter values.
*/
-extern void vRegTest1( void *pvParameters );
-extern void vRegTest2( void *pvParameters );
+extern void vRegTest1Task( void );
+extern void vRegTest2Task( void );
+static void prvRegTest1Entry( void *pvParameters );
+static void prvRegTest2Entry( void *pvParameters );
+/*
+ * Called if a RegTest task discovers an error as a mechanism to stop the
+ * tasks loop counter incrementing (so the check task can detect that an
+ * error exists).
+ */
+void vRegTestError( void );
/*-----------------------------------------------------------*/
@@ -201,19 +217,23 @@ short main( void )
ucTemp = RESF;
ucTemp = sizeof( char* );
ucTemp = sizeof( pdTASK_CODE );
+ P1 &= 0xFE; PM1 &= 0xFE;
+ P1_bit.no0 = 1;
+
/* 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();
+// vStartDynamicPriorityTasks();
+#warning Runs if the debugger is not connected and vStartDynamicPriorityTasks() is commented out.
vStartPolledQueueTasks( tskIDLE_PRIORITY );
vCreateBlockTimeTasks();
/* 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 );
+ xTaskCreate( prvRegTest1Entry, "Reg1", configMINIMAL_STACK_SIZE, mainREG_TEST_1_PARAMETER, tskIDLE_PRIORITY, NULL );
+ xTaskCreate( prvRegTest2Entry, "Reg2", configMINIMAL_STACK_SIZE, mainREG_TEST_2_PARAMETER, tskIDLE_PRIORITY, NULL );
/* Create the software timer that performs the 'check' functionality,
as described at the top of this file. */
@@ -332,6 +352,12 @@ static unsigned short usLastRegTest1Counter = 0, usLastRegTest2Counter = 0;
/* Toggle the LED. The toggle rate will depend on whether or not an error
has been found in any tasks. */
LED_BIT = !LED_BIT;
+
+ if( xTaskGetTickCount() > ( ( portTickType ) 10000 / portTICK_RATE_MS ) )
+ {
+ /* Turn off the LED used to visualise a reset. */
+ P1_bit.no0 = 0;
+ }
}
/*-----------------------------------------------------------*/
@@ -339,7 +365,7 @@ void vRegTestError( void )
{
/* Called by both reg test tasks if an error is found. There is no way out
of this function so the loop counter of the calling task will stop
- incrementing, which will result in the check timer signialling an error. */
+ incrementing, which will result in the check timer signaling an error. */
for( ;; );
}
/*-----------------------------------------------------------*/
@@ -352,6 +378,7 @@ void vApplicationMallocFailedHook( void )
timers, and semaphores. The size of the FreeRTOS heap is set by the
configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
taskDISABLE_INTERRUPTS();
+ P1_bit.no0 = 0;
for( ;; );
}
/*-----------------------------------------------------------*/
@@ -365,6 +392,7 @@ void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
function is called if a stack overflow is detected. */
taskDISABLE_INTERRUPTS();
+ P1_bit.no0 = 0;
for( ;; );
}
/*-----------------------------------------------------------*/
@@ -384,3 +412,47 @@ volatile size_t xFreeHeapSpace;
}
/*-----------------------------------------------------------*/
+static void prvRegTest1Entry( void *pvParameters )
+{
+ /* If the parameter has its expected value then start the first reg test
+ task (this is only done to test that the RTOS port is correctly handling
+ task parameters. */
+ if( pvParameters == mainREG_TEST_1_PARAMETER )
+ {
+ vRegTest1Task();
+ }
+ else
+ {
+ vRegTestError();
+ }
+
+ /* It is not possible to get here as neither of the two functions called
+ above will ever return. */
+}
+/*-----------------------------------------------------------*/
+
+static void prvRegTest2Entry( void *pvParameters )
+{
+ /* If the parameter has its expected value then start the first reg test
+ task (this is only done to test that the RTOS port is correctly handling
+ task parameters. */
+ if( pvParameters == mainREG_TEST_2_PARAMETER )
+ {
+ vRegTest2Task();
+ }
+ else
+ {
+ vRegTestError();
+ }
+
+ /* It is not possible to get here as neither of the two functions called
+ above will ever return. */
+}
+/*-----------------------------------------------------------*/
+
+void vAssertCalled( void )
+{
+ taskDISABLE_INTERRUPTS();
+ P1_bit.no0 = 0;
+ for( ;; );
+}