Continued work on the RX62N GCC demo - just a work in progress currently.
parent
314b692440
commit
0fcac53cf8
@ -0,0 +1,149 @@
|
||||
/*
|
||||
FreeRTOS V6.0.5 - Copyright (C) 2010 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 eBook *
|
||||
* *
|
||||
* "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.
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
/* Board specifics. */
|
||||
#include "rskrx62ndef.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.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_IDLE_HOOK 0
|
||||
#define configUSE_TICK_HOOK 0
|
||||
#define configCPU_CLOCK_HZ ( ICLK_FREQUENCY ) /* Set in rskrx62ndef.h. */
|
||||
#define configPERIPHERAL_CLOCK_HZ ( PCLK_FREQUENCY ) /* Set in rskrx62ndef.h. */
|
||||
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 140 )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 45 * 1024 ) )
|
||||
#define configMAX_TASK_NAME_LEN ( 12 )
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_CO_ROUTINES 0
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configGENERATE_RUN_TIME_STATS 0
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||
#define configUSE_RECURSIVE_MUTEXES 1
|
||||
#define configQUEUE_REGISTRY_SIZE 0
|
||||
#define configUSE_MALLOC_FAILED_HOOK 1
|
||||
#define configUSE_APPLICATION_TASK_TAG 0
|
||||
|
||||
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 )
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
/* The interrupt priority used by the kernel itself for the tick interrupt and
|
||||
the pended interrupt. This would normally be the lowest priority. */
|
||||
#define configKERNEL_INTERRUPT_PRIORITY 1
|
||||
|
||||
/* The maximum interrupt priority from which FreeRTOS API calls can be made.
|
||||
Interrupts that use a priority above this will not be effected by anything the
|
||||
kernel is doing. */
|
||||
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 4
|
||||
|
||||
/* The peripheral used to generate the tick interrupt is configured as part of
|
||||
the application code. This constant should be set to the vector number of the
|
||||
peripheral chosen. As supplied this is CMT0. */
|
||||
#define configTICK_VECTOR _CMT0_CMI0
|
||||
|
||||
/* 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
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||
#define INCLUDE_xTaskGetSchedulerState 1
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Ethernet configuration.
|
||||
*-----------------------------------------------------------*/
|
||||
|
||||
/* MAC address configuration. */
|
||||
#define configMAC_ADDR0 0x00
|
||||
#define configMAC_ADDR1 0x12
|
||||
#define configMAC_ADDR2 0x13
|
||||
#define configMAC_ADDR3 0x10
|
||||
#define configMAC_ADDR4 0x15
|
||||
#define configMAC_ADDR5 0x11
|
||||
|
||||
/* IP address configuration. */
|
||||
#define configIP_ADDR0 192
|
||||
#define configIP_ADDR1 168
|
||||
#define configIP_ADDR2 0
|
||||
#define configIP_ADDR3 201
|
||||
|
||||
/* Netmask configuration. */
|
||||
#define configNET_MASK0 255
|
||||
#define configNET_MASK1 255
|
||||
#define configNET_MASK2 255
|
||||
#define configNET_MASK3 0
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
@ -0,0 +1,209 @@
|
||||
/*
|
||||
FreeRTOS V6.0.5 - Copyright (C) 2010 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 eBook *
|
||||
* *
|
||||
* "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.
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Simple IO routines to control the LEDs.
|
||||
*-----------------------------------------------------------*/
|
||||
|
||||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Demo includes. */
|
||||
#include "partest.h"
|
||||
|
||||
/* Hardware specifics. */
|
||||
#include "iodefine.h"
|
||||
|
||||
#define partestNUM_LEDS ( 6 )
|
||||
|
||||
long lParTestGetLEDState( unsigned long ulLED );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestInitialise( void )
|
||||
{
|
||||
/* Port pin configuration is done by the low level set up prior to this
|
||||
function being called. */
|
||||
|
||||
/* Start with all LEDs off. */
|
||||
LED0 = LED_OFF;
|
||||
LED0 = LED_OFF;
|
||||
LED0 = LED_OFF;
|
||||
LED0 = LED_OFF;
|
||||
LED0 = LED_OFF;
|
||||
LED0 = LED_OFF;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestSetLED( unsigned long ulLED, signed long xValue )
|
||||
{
|
||||
if( ulLED < partestNUM_LEDS )
|
||||
{
|
||||
if( xValue != 0 )
|
||||
{
|
||||
/* Turn the LED on. */
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
switch( ulLED )
|
||||
{
|
||||
case 0: LED0 = LED_ON;
|
||||
break;
|
||||
case 1: LED1 = LED_ON;
|
||||
break;
|
||||
case 2: LED2 = LED_ON;
|
||||
break;
|
||||
case 3: LED3 = LED_ON;
|
||||
break;
|
||||
case 4: LED4 = LED_ON;
|
||||
break;
|
||||
case 5: LED5 = LED_ON;
|
||||
break;
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Turn the LED off. */
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
switch( ulLED )
|
||||
{
|
||||
case 0: LED0 = LED_OFF;
|
||||
break;
|
||||
case 1: LED1 = LED_OFF;
|
||||
break;
|
||||
case 2: LED2 = LED_OFF;
|
||||
break;
|
||||
case 3: LED3 = LED_OFF;
|
||||
break;
|
||||
case 4: LED4 = LED_OFF;
|
||||
break;
|
||||
case 5: LED5 = LED_OFF;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestToggleLED( unsigned long ulLED )
|
||||
{
|
||||
if( ulLED < partestNUM_LEDS )
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
if( lParTestGetLEDState( ulLED ) != 0x00 )
|
||||
{
|
||||
vParTestSetLED( ulLED, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
vParTestSetLED( ulLED, 0 );
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
long lParTestGetLEDState( unsigned long ulLED )
|
||||
{
|
||||
long lReturn = pdFALSE;
|
||||
|
||||
if( ulLED < partestNUM_LEDS )
|
||||
{
|
||||
switch( ulLED )
|
||||
{
|
||||
case 0 : if( LED0 != 0 )
|
||||
{
|
||||
lReturn = pdTRUE;
|
||||
}
|
||||
break;
|
||||
case 1 : if( LED1 != 0 )
|
||||
{
|
||||
lReturn = pdTRUE;
|
||||
}
|
||||
break;
|
||||
case 2 : if( LED2 != 0 )
|
||||
{
|
||||
lReturn = pdTRUE;
|
||||
}
|
||||
break;
|
||||
case 3 : if( LED3 != 0 )
|
||||
{
|
||||
lReturn = pdTRUE;
|
||||
}
|
||||
break;
|
||||
case 4 : if( LED4 != 0 )
|
||||
{
|
||||
lReturn = pdTRUE;
|
||||
}
|
||||
break;
|
||||
case 5 : if( LED5 != 0 )
|
||||
{
|
||||
lReturn = pdTRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return lReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
Binary file not shown.
@ -0,0 +1,115 @@
|
||||
/******************************************************************************
|
||||
* DISCLAIMER
|
||||
|
||||
* This software is supplied by Renesas Technology Corp. and is only
|
||||
* intended for use with Renesas products. No other uses are authorized.
|
||||
|
||||
* This software is owned by Renesas Technology Corp. and is protected under
|
||||
* all applicable laws, including copyright laws.
|
||||
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES
|
||||
* REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY
|
||||
* DISCLAIMED.
|
||||
|
||||
* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
|
||||
* TECHNOLOGY CORP. NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
* FOR ANY REASON RELATED TO THE THIS SOFTWARE, EVEN IF RENESAS OR ITS
|
||||
* AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
* Renesas reserves the right, without notice, to make changes to this
|
||||
* software and to discontinue the availability of this software.
|
||||
* By using this software, you agree to the additional terms and
|
||||
* conditions found by accessing the following link:
|
||||
* http://www.renesas.com/disclaimer
|
||||
******************************************************************************
|
||||
* Copyright (C) 2008. Renesas Technology Corp., All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* File Name : hwsetup.c
|
||||
* Version : 1.00
|
||||
* Description : Power up hardware initializations
|
||||
******************************************************************************
|
||||
* History : DD.MM.YYYY Version Description
|
||||
* : 15.02.2010 1.00 First Release
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Includes <System Includes> , "Project Includes"
|
||||
******************************************************************************/
|
||||
#include "iodefine.h"
|
||||
#include "rskrx62ndef.h"
|
||||
// #include "lcd.h" Uncomment this if an LCD is present.
|
||||
|
||||
/******************************************************************************
|
||||
Typedef definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
Macro definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
Imported global variables and functions (from other files)
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
Exported global variables and functions (to be accessed by other files)
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
Private global variables and functions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Function Name: HardwareSetup
|
||||
* Description : This function does initial setting for CPG port pins used in
|
||||
* : the Demo including the MII pins of the Ethernet PHY connection.
|
||||
* Arguments : none
|
||||
* Return Value : none
|
||||
******************************************************************************/
|
||||
void HardwareSetup(void)
|
||||
{
|
||||
|
||||
unsigned long sckcr = 0;
|
||||
|
||||
/* Configure system clocks based on header */
|
||||
sckcr += (ICLK_MUL==8) ? (0ul << 24) : (ICLK_MUL==4) ? (1ul << 24) : (ICLK_MUL==2) ? (2ul << 24) : (3ul << 24);
|
||||
sckcr += (BCLK_MUL==8) ? (0ul << 16) : (BCLK_MUL==4) ? (1ul << 16) : (BCLK_MUL==2) ? (2ul << 16) : (3ul << 16);
|
||||
sckcr += (PCLK_MUL==8) ? (0ul << 8) : (PCLK_MUL==4) ? (1ul << 8) : (PCLK_MUL==2) ? (2ul << 8) : (3ul << 8);
|
||||
SYSTEM.SCKCR.LONG = sckcr;
|
||||
|
||||
/* Configure LED 0-5 pins as outputs */
|
||||
LED0 = LED_OFF;
|
||||
LED1 = LED_OFF;
|
||||
LED2 = LED_OFF;
|
||||
LED3 = LED_OFF;
|
||||
LED4 = LED_OFF;
|
||||
LED5 = LED_OFF;
|
||||
LED0_DDR = 1;
|
||||
LED1_DDR = 1;
|
||||
LED2_DDR = 1;
|
||||
LED3_DDR = 1;
|
||||
LED4_DDR = 1;
|
||||
LED5_DDR = 1;
|
||||
|
||||
/* Configure SW 1-3 pins as inputs */
|
||||
SW1_DDR = 0;
|
||||
SW2_DDR = 0;
|
||||
SW3_DDR = 0;
|
||||
SW1_ICR = 1;
|
||||
SW2_ICR = 1;
|
||||
SW3_ICR = 1;
|
||||
|
||||
|
||||
/* Configure LCD pins as outputs - uncomment this if an LCD is present.
|
||||
LCD_RS_DDR = 1;
|
||||
LCD_EN_DDR = 1;
|
||||
LCD_DATA_DDR = 0xF0; */
|
||||
|
||||
/* Initialize display - uncomment this if an LCD is present.
|
||||
InitialiseDisplay(); */
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,98 @@
|
||||
|
||||
/******************************************************************************
|
||||
* DISCLAIMER
|
||||
* Please refer to http://www.renesas.com/disclaimer
|
||||
******************************************************************************
|
||||
Copyright (C) 2008. Renesas Technology Corp., All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* File Name : rsksh7216.h
|
||||
* Version : 1.00
|
||||
* Description : RSK 7216 board specific settings
|
||||
******************************************************************************
|
||||
* History : DD.MM.YYYY Version Description
|
||||
* : 06.10.2009 1.00 First Release
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef RSKRX62N_H
|
||||
#define RSKRX62N_H
|
||||
|
||||
/******************************************************************************
|
||||
Includes <System Includes> , "Project Includes"
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
Typedef definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
Macro definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* System Clock Settings */
|
||||
#define XTAL_FREQUENCY (12000000L)
|
||||
#define ICLK_MUL (8)
|
||||
#define PCLK_MUL (4)
|
||||
#define BCLK_MUL (4)
|
||||
#define ICLK_FREQUENCY (XTAL_FREQUENCY * ICLK_MUL)
|
||||
#define PCLK_FREQUENCY (XTAL_FREQUENCY * PCLK_MUL)
|
||||
#define BCLK_FREQUENCY (XTAL_FREQUENCY * BCLK_MUL)
|
||||
|
||||
#define CMT0_CLK_SELECT (512)
|
||||
|
||||
/* General Values */
|
||||
#define LED_ON (0)
|
||||
#define LED_OFF (1)
|
||||
#define SET_BIT_HIGH (1)
|
||||
#define SET_BIT_LOW (0)
|
||||
#define SET_BYTE_HIGH (0xFF)
|
||||
#define SET_BYTE_LOW (0x00)
|
||||
|
||||
/* Define switches to be polled if not available as interrupts */
|
||||
#define SW_ACTIVE FALSE
|
||||
#define SW1 PORT0.DR.BIT.B0
|
||||
#define SW2 PORT0.DR.BIT.B1
|
||||
#define SW3 PORT0.DR.BIT.B7
|
||||
#define SW1_DDR PORT0.DDR.BIT.B0
|
||||
#define SW2_DDR PORT0.DDR.BIT.B1
|
||||
#define SW3_DDR PORT0.DDR.BIT.B7
|
||||
#define SW1_ICR PORT0.ICR.BIT.B0
|
||||
#define SW2_ICR PORT0.ICR.BIT.B1
|
||||
#define SW3_ICR PORT0.ICR.BIT.B7
|
||||
|
||||
/* LEDs */
|
||||
#define LED0 PORT0.DR.BIT.B2
|
||||
#define LED1 PORT0.DR.BIT.B3
|
||||
#define LED2 PORT0.DR.BIT.B5
|
||||
#define LED3 PORT3.DR.BIT.B4
|
||||
#define LED4 PORT6.DR.BIT.B0
|
||||
#define LED5 PORT7.DR.BIT.B3
|
||||
#define LED0_DDR PORT0.DDR.BIT.B2
|
||||
#define LED1_DDR PORT0.DDR.BIT.B3
|
||||
#define LED2_DDR PORT0.DDR.BIT.B5
|
||||
#define LED3_DDR PORT3.DDR.BIT.B4
|
||||
#define LED4_DDR PORT6.DDR.BIT.B0
|
||||
#define LED5_DDR PORT7.DDR.BIT.B3
|
||||
|
||||
/* 2x8 segment LCD */
|
||||
#define LCD_RS PORT8.DR.BIT.B4
|
||||
#define LCD_EN PORT8.DR.BIT.B5
|
||||
#define LCD_DATA PORT9.DR.BYTE
|
||||
#define LCD_RS_DDR PORT8.DDR.BIT.B4
|
||||
#define LCD_EN_DDR PORT8.DDR.BIT.B5
|
||||
#define LCD_DATA_DDR PORT9.DDR.BYTE
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Variable Externs
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
Functions Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
||||
/* RSKRX62N_H */
|
||||
#endif
|
||||
|
@ -0,0 +1,217 @@
|
||||
/*
|
||||
FreeRTOS V6.0.5 - Copyright (C) 2010 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 eBook *
|
||||
* *
|
||||
* "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 is a very simple demo that creates two tasks and one queue. One task
|
||||
* (the queue receive task) blocks on the queue to wait for data to arrive,
|
||||
* toggling an LED each time '100' is received. The other task (the queue send
|
||||
* task) repeatedly blocks for a fixed period before sending '100' to the queue
|
||||
* (causing the first task to toggle the LED).
|
||||
*
|
||||
* For a much more complete and complex example select either the Debug or
|
||||
* Debug_with_optimisation build configurations within the HEW IDE.
|
||||
*/
|
||||
|
||||
/* Hardware specific includes. */
|
||||
#include "iodefine.h"
|
||||
|
||||
/* Kernel includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* Priorities at which the tasks are created. */
|
||||
#define configQUEUE_RECEIVE_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define configQUEUE_SEND_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
|
||||
/* The rate at which data is sent to the queue, specified in milliseconds. */
|
||||
#define mainQUEUE_SEND_FREQUENCY_MS ( 500 / portTICK_RATE_MS )
|
||||
|
||||
/* The number of items the queue can hold. This is 1 as the receive task
|
||||
will remove items as they are added so the send task should always find the
|
||||
queue empty. */
|
||||
#define mainQUEUE_LENGTH ( 1 )
|
||||
|
||||
/*
|
||||
* The tasks as defined at the top of this file.
|
||||
*/
|
||||
static void prvQueueReceiveTask( void *pvParameters );
|
||||
static void prvQueueSendTask( void *pvParameters );
|
||||
|
||||
/* The queue used by both tasks. */
|
||||
static xQueueHandle xQueue = NULL;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void main(void)
|
||||
{
|
||||
extern void HardwareSetup( void );
|
||||
|
||||
/* Renesas provided CPU configuration routine. The clocks are configured in
|
||||
here. */
|
||||
HardwareSetup();
|
||||
|
||||
/* Turn all LEDs off. */
|
||||
vParTestInitialise();
|
||||
|
||||
/* Create the queue. */
|
||||
xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) );
|
||||
|
||||
if( xQueue != NULL )
|
||||
{
|
||||
/* Start the two tasks as described at the top of this file. */
|
||||
xTaskCreate( prvQueueReceiveTask, "Rx", configMINIMAL_STACK_SIZE, NULL, configQUEUE_RECEIVE_TASK_PRIORITY, NULL );
|
||||
xTaskCreate( prvQueueSendTask, "TX", configMINIMAL_STACK_SIZE, NULL, configQUEUE_SEND_TASK_PRIORITY, NULL );
|
||||
|
||||
/* Start the tasks running. */
|
||||
vTaskStartScheduler();
|
||||
}
|
||||
|
||||
/* If all is well we will never reach here as the scheduler will now be
|
||||
running. If we do reach here then it is likely that there was insufficient
|
||||
heap available for the idle task to be created. */
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvQueueSendTask( void *pvParameters )
|
||||
{
|
||||
portTickType xNextWakeTime;
|
||||
const unsigned long ulValueToSend = 100UL;
|
||||
|
||||
/* Initialise xNextWakeTime - this only needs to be done once. */
|
||||
xNextWakeTime = xTaskGetTickCount();
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Place this task in the blocked state until it is time to run again.
|
||||
The block state is specified in ticks, the constant used converts ticks
|
||||
to ms. */
|
||||
vTaskDelayUntil( &xNextWakeTime, mainQUEUE_SEND_FREQUENCY_MS );
|
||||
|
||||
/* Send to the queue - causing the queue receive task to flash its LED. 0
|
||||
is used so the send does not block - it shouldn't need to as the queue
|
||||
should always be empty here. */
|
||||
xQueueSend( xQueue, &ulValueToSend, 0 );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvQueueReceiveTask( void *pvParameters )
|
||||
{
|
||||
unsigned long ulReceivedValue;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Wait until something arives in the queue - this will block
|
||||
indefinitely provided INCLUDE_vTaskSuspend is set to 1 in
|
||||
FreeRTOSConfig.h. */
|
||||
xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY );
|
||||
|
||||
/* To get here something must have arrived, but is it the expected
|
||||
value? If it is, toggle the LED. */
|
||||
if( ulReceivedValue == 100UL )
|
||||
{
|
||||
vParTestToggleLED( 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationSetupTimerInterrupt( void )
|
||||
{
|
||||
/* Enable compare match timer 0. */
|
||||
MSTP( CMT0 ) = 0;
|
||||
|
||||
/* Interrupt on compare match. */
|
||||
CMT0.CMCR.BIT.CMIE = 1;
|
||||
|
||||
/* Set the compare match value. */
|
||||
CMT0.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ ) -1 ) / 8 );
|
||||
|
||||
/* Divide the PCLK by 8. */
|
||||
CMT0.CMCR.BIT.CKS = 0;
|
||||
|
||||
/* Enable the interrupt... */
|
||||
_IEN( _CMT0_CMI0 ) = 1;
|
||||
|
||||
/* ...and set its priority to the application defined kernel priority. */
|
||||
_IPR( _CMT0_CMI0 ) = configKERNEL_INTERRUPT_PRIORITY;
|
||||
|
||||
/* Start the timer. */
|
||||
CMT.CMSTR0.BIT.STR0 = 1;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* This function is explained by the comments above its prototype at the top
|
||||
of this file. */
|
||||
void vApplicationMallocFailedHook( void )
|
||||
{
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* This function is explained by the comments above its prototype at the top
|
||||
of this file. */
|
||||
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )
|
||||
{
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* This function is explained by the comments above its prototype at the top
|
||||
of this file. */
|
||||
void vApplicationIdleHook( void )
|
||||
{
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
@ -0,0 +1,649 @@
|
||||
/*
|
||||
FreeRTOS V6.0.5 - Copyright (C) 2010 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 eBook *
|
||||
* *
|
||||
* "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 project includes a lot of tasks and tests and is therefore complex.
|
||||
* If you would prefer a much simpler project to get started with then select
|
||||
* the 'Blinky' build configuration within the HEW IDE.
|
||||
*
|
||||
* Creates all the demo application tasks, then starts the scheduler. The WEB
|
||||
* documentation provides more details of the standard demo application tasks,
|
||||
* which provide no particular functionality but do provide a good example of
|
||||
* how to use the FreeRTOS API. The tasks defined in flop.c are included in the
|
||||
* set of standard demo tasks to ensure the floating point unit gets some
|
||||
* exercise.
|
||||
*
|
||||
* In addition to the standard demo tasks, the following tasks and tests are
|
||||
* defined and/or created within this file:
|
||||
*
|
||||
* "Reg test" tasks - These fill the registers with known values, then check
|
||||
* that each register still contains its expected value. Each task uses
|
||||
* different values. The tasks run with very low priority so get preempted very
|
||||
* frequently. A register containing an unexpected value is indicative of an
|
||||
* error in the context switching mechanism and will result in interrupts being
|
||||
* disabled and a branch to a null loop. This has the effect of stopping
|
||||
* execution of all the tests and tasks, which in turn results in all LED
|
||||
* activity stopping too. The nature of the reg test tasks necessitates that
|
||||
* they are written in assembly code. The check task (described below) checks
|
||||
* that the reg test tasks are still executing and will indicate an error if
|
||||
* either reg test task is found to have stalled.
|
||||
*
|
||||
* "Check" task - This only executes every five seconds but has a high priority
|
||||
* to ensure it gets processor time. Its main function is to check that all the
|
||||
* standard demo tasks are still operational. While no errors have been
|
||||
* discovered the check task will toggle LED 5 every 5 seconds - the toggle
|
||||
* rate increasing to 200ms being a visual indication that at least one task has
|
||||
* reported unexpected behaviour.
|
||||
*
|
||||
* "High frequency timer test" - A high frequency periodic interrupt is
|
||||
* generated using a timer - the interrupt is assigned a priority above
|
||||
* configMAX_SYSCALL_INTERRUPT_PRIORITY so should not be effected by anything
|
||||
* the kernel is doing. The interrupt service routine measures the number of
|
||||
* counts a separate timer performs between each interrupt to determine the
|
||||
* jitter in the interrupt timing.
|
||||
*
|
||||
* *NOTE 1* If LED5 is toggling every 5 seconds then all the demo application
|
||||
* tasks are executing as expected and no errors have been reported in any
|
||||
* tasks. The toggle rate increasing to 200ms indicates that at least one task
|
||||
* has reported unexpected behaviour.
|
||||
*
|
||||
* *NOTE 2* vApplicationSetupTimerInterrupt() is called by the kernel to let
|
||||
* the application set up a timer to generate the tick interrupt. In this
|
||||
* example a compare match timer is used for this purpose.
|
||||
*
|
||||
* *NOTE 3* The CPU must be in Supervisor mode when the scheduler is started.
|
||||
* The PowerON_Reset_PC() supplied in resetprg.c with this demo has
|
||||
* Change_PSW_PM_to_UserMode() commented out to ensure this is the case.
|
||||
*
|
||||
* *NOTE 4* The IntQueue common demo tasks test interrupt nesting and make use
|
||||
* of all the 8bit timers (as two cascaded 16bit units).
|
||||
*/
|
||||
|
||||
/* Hardware specific includes. */
|
||||
#include "iodefine.h"
|
||||
|
||||
/* Kernel includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Standard demo includes. */
|
||||
#include "partest.h"
|
||||
#include "flash.h"
|
||||
#include "IntQueue.h"
|
||||
#include "BlockQ.h"
|
||||
#include "death.h"
|
||||
#include "integer.h"
|
||||
#include "blocktim.h"
|
||||
#include "semtest.h"
|
||||
#include "PollQ.h"
|
||||
#include "GenQTest.h"
|
||||
#include "QPeek.h"
|
||||
#include "recmutex.h"
|
||||
#include "flop.h"
|
||||
|
||||
/* Values that are passed into the reg test tasks using the task parameter. The
|
||||
tasks check that the values are passed in correctly. */
|
||||
#define mainREG_TEST_1_PARAMETER ( 0x12121212UL )
|
||||
#define mainREG_TEST_2_PARAMETER ( 0x12345678UL )
|
||||
|
||||
/* Priorities at which the tasks are created. */
|
||||
#define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
|
||||
#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
||||
#define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainuIP_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
#define mainFLOP_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
|
||||
/* The LED toggled by the check task. */
|
||||
#define mainCHECK_LED ( 5 )
|
||||
|
||||
/* The rate at which mainCHECK_LED will toggle when all the tasks are running
|
||||
without error. Controlled by the check task as described at the top of this
|
||||
file. */
|
||||
#define mainNO_ERROR_CYCLE_TIME ( 5000 / portTICK_RATE_MS )
|
||||
|
||||
/* The rate at which mainCHECK_LED will toggle when an error has been reported
|
||||
by at least one task. Controlled by the check task as described at the top of
|
||||
this file. */
|
||||
#define mainERROR_CYCLE_TIME ( 200 / portTICK_RATE_MS )
|
||||
|
||||
/* The period of the peripheral clock in nano seconds. This is used to calculate
|
||||
the jitter time in nano seconds as part of the high frequency timer test. The
|
||||
clock driving the timer is divided by 8. */
|
||||
#define mainNS_PER_CLOCK ( ( unsigned long ) ( ( 1.0 / ( ( double ) configPERIPHERAL_CLOCK_HZ ) / 8.0 ) * 1000000000.0 ) )
|
||||
|
||||
/*
|
||||
* vApplicationMallocFailedHook() will only be called if
|
||||
* configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
|
||||
* function that will execute if a call to pvPortMalloc() fails.
|
||||
* pvPortMalloc() is called internally by the kernel whenever a task, queue or
|
||||
* semaphore is created. It is also called by various parts of the demo
|
||||
* application.
|
||||
*/
|
||||
void vApplicationMallocFailedHook( void );
|
||||
|
||||
/*
|
||||
* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set to 1
|
||||
* in FreeRTOSConfig.h. It is a hook function that is called on each iteration
|
||||
* of the idle task. It is essential that code added to this hook function
|
||||
* never attempts to block in any way (for example, call xQueueReceive() with
|
||||
* a block time specified). If the application makes use of the vTaskDelete()
|
||||
* API function (as this demo application does) then it is also important that
|
||||
* vApplicationIdleHook() is permitted to return to its calling function because
|
||||
* it is the responsibility of the idle task to clean up memory allocated by the
|
||||
* kernel to any task that has since been deleted.
|
||||
*/
|
||||
void vApplicationIdleHook( void );
|
||||
|
||||
/*
|
||||
* vApplicationStackOverflowHook() will only be called if
|
||||
* configCHECK_FOR_STACK_OVERFLOW is set to a non-zero value. The handle and
|
||||
* name of the offending task should be passed in the function parameters, but
|
||||
* it is possible that the stack overflow will have corrupted these - in which
|
||||
* case pxCurrentTCB can be inspected to find the same information.
|
||||
*/
|
||||
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName );
|
||||
|
||||
/*
|
||||
* The reg test tasks as described at the top of this file.
|
||||
*/
|
||||
static void prvRegTest1Task( void *pvParameters );
|
||||
static void prvRegTest2Task( void *pvParameters );
|
||||
|
||||
/*
|
||||
* The actual implementation of the reg test functionality, which, because of
|
||||
* the direct register access, have to be in assembly.
|
||||
*/
|
||||
static void prvRegTest1Implementation( void );
|
||||
static void prvRegTest2Implementation( void );
|
||||
|
||||
/*
|
||||
* The check task as described at the top of this file.
|
||||
*/
|
||||
static void prvCheckTask( void *pvParameters );
|
||||
|
||||
/* Variables that are incremented on each iteration of the reg test tasks -
|
||||
provided the tasks have not reported any errors. The check task inspects these
|
||||
variables to ensure they are still incrementing as expected. If a variable
|
||||
stops incrementing then it is likely that its associate task has stalled. */
|
||||
unsigned long ulRegTest1CycleCount = 0UL, ulRegTest2CycleCount = 0UL;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void main(void)
|
||||
{
|
||||
extern void HardwareSetup( void );
|
||||
|
||||
/* Renesas provided CPU configuration routine. The clocks are configured in
|
||||
here. */
|
||||
HardwareSetup();
|
||||
|
||||
/* Turn all LEDs off. */
|
||||
vParTestInitialise();
|
||||
|
||||
/* Start the reg test tasks which test the context switching mechanism. */
|
||||
xTaskCreate( prvRegTest1Task, "RegTst1", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_1_PARAMETER, tskIDLE_PRIORITY, NULL );
|
||||
xTaskCreate( prvRegTest2Task, "RegTst2", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_2_PARAMETER, tskIDLE_PRIORITY, NULL );
|
||||
|
||||
/* Start the check task as described at the top of this file. */
|
||||
xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE * 3, NULL, mainCHECK_TASK_PRIORITY, NULL );
|
||||
|
||||
/* Create the standard demo tasks. */
|
||||
vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
|
||||
vCreateBlockTimeTasks();
|
||||
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
|
||||
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
|
||||
vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
|
||||
vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
|
||||
vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );
|
||||
vStartQueuePeekTasks();
|
||||
vStartRecursiveMutexTasks();
|
||||
vStartInterruptQueueTasks();
|
||||
vStartMathTasks( mainFLOP_TASK_PRIORITY );
|
||||
|
||||
/* The suicide tasks must be created last as they need to know how many
|
||||
tasks were running prior to their creation in order to ascertain whether
|
||||
or not the correct/expected number of tasks are running at any given time. */
|
||||
vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
|
||||
|
||||
/* Start the tasks running. */
|
||||
vTaskStartScheduler();
|
||||
|
||||
/* If all is well we will never reach here as the scheduler will now be
|
||||
running. If we do reach here then it is likely that there was insufficient
|
||||
heap available for the idle task to be created. */
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCheckTask( void *pvParameters )
|
||||
{
|
||||
static volatile unsigned long ulLastRegTest1CycleCount = 0UL, ulLastRegTest2CycleCount = 0UL;
|
||||
portTickType xNextWakeTime, xCycleFrequency = mainNO_ERROR_CYCLE_TIME;
|
||||
extern void vSetupHighFrequencyTimer( void );
|
||||
extern volatile unsigned short usMaxJitter;
|
||||
volatile unsigned long ulActualJitter = 0;
|
||||
static char cErrorText[ 100 ];
|
||||
|
||||
/* If this is being executed then the kernel has been started. Start the high
|
||||
frequency timer test as described at the top of this file. This is only
|
||||
included in the optimised build configuration - otherwise it takes up too much
|
||||
CPU time. */
|
||||
#ifdef INCLUDE_HIGH_FREQUENCY_TIMER_TEST
|
||||
vSetupHighFrequencyTimer();
|
||||
#endif
|
||||
|
||||
/* Initialise xNextWakeTime - this only needs to be done once. */
|
||||
xNextWakeTime = xTaskGetTickCount();
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Place this task in the blocked state until it is time to run again. */
|
||||
vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );
|
||||
|
||||
/* Check the standard demo tasks are running without error. */
|
||||
if( xAreGenericQueueTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
/* Increase the rate at which this task cycles, which will increase the
|
||||
rate at which mainCHECK_LED flashes to give visual feedback that an error
|
||||
has occurred. */
|
||||
xCycleFrequency = mainERROR_CYCLE_TIME;
|
||||
strncpy( cErrorText, "Error: GenQueue" );
|
||||
}
|
||||
else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
xCycleFrequency = mainERROR_CYCLE_TIME;
|
||||
strncpy( cErrorText, "Error: QueuePeek" );
|
||||
}
|
||||
else if( xAreBlockingQueuesStillRunning() != pdTRUE )
|
||||
{
|
||||
xCycleFrequency = mainERROR_CYCLE_TIME;
|
||||
strncpy( cErrorText, "Error: BlockQueue" );
|
||||
}
|
||||
else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
xCycleFrequency = mainERROR_CYCLE_TIME;
|
||||
strncpy( cErrorText, "Error: BlockTime" );
|
||||
}
|
||||
else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
xCycleFrequency = mainERROR_CYCLE_TIME;
|
||||
strncpy( cErrorText, "Error: SemTest" );
|
||||
}
|
||||
else if( xArePollingQueuesStillRunning() != pdTRUE )
|
||||
{
|
||||
xCycleFrequency = mainERROR_CYCLE_TIME;
|
||||
strncpy( cErrorText, "Error: PollQueue" );
|
||||
}
|
||||
else if( xIsCreateTaskStillRunning() != pdTRUE )
|
||||
{
|
||||
xCycleFrequency = mainERROR_CYCLE_TIME;
|
||||
strncpy( cErrorText, "Error: Death" );
|
||||
}
|
||||
else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
|
||||
{
|
||||
xCycleFrequency = mainERROR_CYCLE_TIME;
|
||||
strncpy( cErrorText, "Error: IntMath" );
|
||||
}
|
||||
else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
xCycleFrequency = mainERROR_CYCLE_TIME;
|
||||
strncpy( cErrorText, "Error: RecMutex" );
|
||||
}
|
||||
else if( xAreIntQueueTasksStillRunning() != pdPASS )
|
||||
{
|
||||
xCycleFrequency = mainERROR_CYCLE_TIME;
|
||||
strncpy( cErrorText, "Error: IntQueue" );
|
||||
}
|
||||
else if( xAreMathsTaskStillRunning() != pdPASS )
|
||||
{
|
||||
xCycleFrequency = mainERROR_CYCLE_TIME;
|
||||
strncpy( cErrorText, "Error: Flop" );
|
||||
}
|
||||
|
||||
/* Check the reg test tasks are still cycling. They will stop incrementing
|
||||
their loop counters if they encounter an error. */
|
||||
if( ulRegTest1CycleCount == ulLastRegTest1CycleCount )
|
||||
{
|
||||
xCycleFrequency = mainERROR_CYCLE_TIME;
|
||||
strncpy( cErrorText, "Error: RegTest1" );
|
||||
}
|
||||
|
||||
if( ulRegTest2CycleCount == ulLastRegTest2CycleCount )
|
||||
{
|
||||
xCycleFrequency = mainERROR_CYCLE_TIME;
|
||||
strncpy( cErrorText, "Error: RegTest2" );
|
||||
}
|
||||
|
||||
ulLastRegTest1CycleCount = ulRegTest1CycleCount;
|
||||
ulLastRegTest2CycleCount = ulRegTest2CycleCount;
|
||||
|
||||
/* Toggle the check LED to give an indication of the system status. If
|
||||
the LED toggles every 5 seconds then everything is ok. A faster toggle
|
||||
indicates an error. */
|
||||
vParTestToggleLED( mainCHECK_LED );
|
||||
|
||||
/* Calculate the maximum jitter experienced by the high frequency timer
|
||||
test and print it out. It is ok to use printf without worrying about
|
||||
mutual exclusion as it is not used anywhere else in this demo. */
|
||||
//sprintf( cTempBuf, "%s [%fns]\n", "Max Jitter = ", ( ( float ) usMaxJitter ) * mainNS_PER_CLOCK );
|
||||
ulActualJitter = ( ( unsigned long ) usMaxJitter ) * mainNS_PER_CLOCK;
|
||||
|
||||
if( xCycleFrequency == mainERROR_CYCLE_TIME )
|
||||
{
|
||||
nop();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The RX port uses this callback function to configure its tick interrupt.
|
||||
This allows the application to choose the tick interrupt source. */
|
||||
void vApplicationSetupTimerInterrupt( void )
|
||||
{
|
||||
/* Enable compare match timer 0. */
|
||||
MSTP( CMT0 ) = 0;
|
||||
|
||||
/* Interrupt on compare match. */
|
||||
CMT0.CMCR.BIT.CMIE = 1;
|
||||
|
||||
/* Set the compare match value. */
|
||||
CMT0.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ ) -1 ) / 8 );
|
||||
|
||||
/* Divide the PCLK by 8. */
|
||||
CMT0.CMCR.BIT.CKS = 0;
|
||||
|
||||
/* Enable the interrupt... */
|
||||
_IEN( _CMT0_CMI0 ) = 1;
|
||||
|
||||
/* ...and set its priority to the application defined kernel priority. */
|
||||
_IPR( _CMT0_CMI0 ) = configKERNEL_INTERRUPT_PRIORITY;
|
||||
|
||||
/* Start the timer. */
|
||||
CMT.CMSTR0.BIT.STR0 = 1;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* This function is explained by the comments above its prototype at the top
|
||||
of this file. */
|
||||
void vApplicationMallocFailedHook( void )
|
||||
{
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* This function is explained by the comments above its prototype at the top
|
||||
of this file. */
|
||||
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )
|
||||
{
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* This function is explained by the comments above its prototype at the top
|
||||
of this file. */
|
||||
void vApplicationIdleHook( void )
|
||||
{
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* This function is explained in the comments at the top of this file. */
|
||||
static void prvRegTest1Task( void *pvParameters )
|
||||
{
|
||||
if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_1_PARAMETER )
|
||||
{
|
||||
/* The parameter did not contain the expected value. */
|
||||
for( ;; )
|
||||
{
|
||||
/* Stop the tick interrupt so its obvious something has gone wrong. */
|
||||
taskDISABLE_INTERRUPTS();
|
||||
}
|
||||
}
|
||||
|
||||
/* This is an inline asm function that never returns. */
|
||||
prvRegTest1Implementation();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* This function is explained in the comments at the top of this file. */
|
||||
static void prvRegTest2Task( void *pvParameters )
|
||||
{
|
||||
if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_2_PARAMETER )
|
||||
{
|
||||
/* The parameter did not contain the expected value. */
|
||||
for( ;; )
|
||||
{
|
||||
/* Stop the tick interrupt so its obvious something has gone wrong. */
|
||||
taskDISABLE_INTERRUPTS();
|
||||
}
|
||||
}
|
||||
|
||||
/* This is an inline asm function that never returns. */
|
||||
prvRegTest2Implementation();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* This function is explained in the comments at the top of this file. */
|
||||
#pragma inline_asm prvRegTest1Implementation
|
||||
static void prvRegTest1Implementation( void )
|
||||
{
|
||||
; Put a known value in each register.
|
||||
MOV.L #1, R1
|
||||
MOV.L #2, R2
|
||||
MOV.L #3, R3
|
||||
MOV.L #4, R4
|
||||
MOV.L #5, R5
|
||||
MOV.L #6, R6
|
||||
MOV.L #7, R7
|
||||
MOV.L #8, R8
|
||||
MOV.L #9, R9
|
||||
MOV.L #10, R10
|
||||
MOV.L #11, R11
|
||||
MOV.L #12, R12
|
||||
MOV.L #13, R13
|
||||
MOV.L #14, R14
|
||||
MOV.L #15, R15
|
||||
|
||||
; Loop, checking each itteration that each register still contains the
|
||||
; expected value.
|
||||
TestLoop1:
|
||||
|
||||
; Push the registers that are going to get clobbered.
|
||||
PUSHM R14-R15
|
||||
|
||||
; Increment the loop counter to show this task is still getting CPU time.
|
||||
MOV.L #_ulRegTest1CycleCount, R14
|
||||
MOV.L [ R14 ], R15
|
||||
ADD #1, R15
|
||||
MOV.L R15, [ R14 ]
|
||||
|
||||
; Yield to extend the text coverage. Set the bit in the ITU SWINTR register.
|
||||
MOV.L #1, R14
|
||||
MOV.L #0872E0H, R15
|
||||
MOV.B R14, [R15]
|
||||
NOP
|
||||
NOP
|
||||
|
||||
; Restore the clobbered registers.
|
||||
POPM R14-R15
|
||||
|
||||
; Now compare each register to ensure it still contains the value that was
|
||||
; set before this loop was entered.
|
||||
CMP #1, R1
|
||||
BNE RegTest2Error
|
||||
CMP #2, R2
|
||||
BNE RegTest2Error
|
||||
CMP #3, R3
|
||||
BNE RegTest2Error
|
||||
CMP #4, R4
|
||||
BNE RegTest2Error
|
||||
CMP #5, R5
|
||||
BNE RegTest2Error
|
||||
CMP #6, R6
|
||||
BNE RegTest2Error
|
||||
CMP #7, R7
|
||||
BNE RegTest2Error
|
||||
CMP #8, R8
|
||||
BNE RegTest2Error
|
||||
CMP #9, R9
|
||||
BNE RegTest2Error
|
||||
CMP #10, R10
|
||||
BNE RegTest2Error
|
||||
CMP #11, R11
|
||||
BNE RegTest2Error
|
||||
CMP #12, R12
|
||||
BNE RegTest2Error
|
||||
CMP #13, R13
|
||||
BNE RegTest2Error
|
||||
CMP #14, R14
|
||||
BNE RegTest2Error
|
||||
CMP #15, R15
|
||||
BNE RegTest2Error
|
||||
|
||||
; All comparisons passed, start a new itteratio of this loop.
|
||||
BRA TestLoop1
|
||||
|
||||
RegTest1Error:
|
||||
; A compare failed, something has gone wrong. Stop the tick and any other
|
||||
; interrupts to make it obvious that things have halted.
|
||||
CLRPSW I
|
||||
BRA RegTest1Error
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* This function is explained in the comments at the top of this file. */
|
||||
#pragma inline_asm prvRegTest2Implementation
|
||||
static void prvRegTest2Implementation( void )
|
||||
{
|
||||
; Put a known value in each register.
|
||||
MOV.L #10, R1
|
||||
MOV.L #20, R2
|
||||
MOV.L #30, R3
|
||||
MOV.L #40, R4
|
||||
MOV.L #50, R5
|
||||
MOV.L #60, R6
|
||||
MOV.L #70, R7
|
||||
MOV.L #80, R8
|
||||
MOV.L #90, R9
|
||||
MOV.L #100, R10
|
||||
MOV.L #110, R11
|
||||
MOV.L #120, R12
|
||||
MOV.L #130, R13
|
||||
MOV.L #140, R14
|
||||
MOV.L #150, R15
|
||||
|
||||
; Loop, checking on each itteration that each register still contains the
|
||||
; expected value.
|
||||
TestLoop2:
|
||||
|
||||
; Push the registers that are going to get clobbered.
|
||||
PUSHM R14-R15
|
||||
|
||||
; Increment the loop counter to show this task is still getting CPU time.
|
||||
MOV.L #_ulRegTest2CycleCount, R14
|
||||
MOV.L [ R14 ], R15
|
||||
ADD #1, R15
|
||||
MOV.L R15, [ R14 ]
|
||||
|
||||
; Restore the clobbered registers.
|
||||
POPM R14-R15
|
||||
|
||||
CMP #10, R1
|
||||
BNE RegTest2Error
|
||||
CMP #20, R2
|
||||
BNE RegTest2Error
|
||||
CMP #30, R3
|
||||
BNE RegTest2Error
|
||||
CMP #40, R4
|
||||
BNE RegTest2Error
|
||||
CMP #50, R5
|
||||
BNE RegTest2Error
|
||||
CMP #60, R6
|
||||
BNE RegTest2Error
|
||||
CMP #70, R7
|
||||
BNE RegTest2Error
|
||||
CMP #80, R8
|
||||
BNE RegTest2Error
|
||||
CMP #90, R9
|
||||
BNE RegTest2Error
|
||||
CMP #100, R10
|
||||
BNE RegTest2Error
|
||||
CMP #110, R11
|
||||
BNE RegTest2Error
|
||||
CMP #120, R12
|
||||
BNE RegTest2Error
|
||||
CMP #130, R13
|
||||
BNE RegTest2Error
|
||||
CMP #140, R14
|
||||
BNE RegTest2Error
|
||||
CMP #150, R15
|
||||
BNE RegTest2Error
|
||||
|
||||
; All comparisons passed, start a new itteratio of this loop.
|
||||
BRA TestLoop2
|
||||
|
||||
RegTest2Error:
|
||||
; A compare failed, something went wrong. Stop the tick and any other
|
||||
; interrupts to make it obvious that things have halted.
|
||||
CLRPSW I
|
||||
BRA RegTest2Error
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue