mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-19 09:38:32 -04:00
Add new NiosII demo project.
This commit is contained in:
parent
5d6acacd7a
commit
523ffada03
24 changed files with 7270 additions and 0 deletions
28
Demo/NiosII_CycloneIII_DBC3C40_GCC/RTOSDemo/.cdtbuild
Normal file
28
Demo/NiosII_CycloneIII_DBC3C40_GCC/RTOSDemo/.cdtbuild
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 3.1.0?>
|
||||
|
||||
<ManagedProjectBuildInfo>
|
||||
<project id="RTOSDemo.nios2.exec.1581235184" name="Nios II Executable" projectType="nios2.exec">
|
||||
<configuration artifactExtension="elf" artifactName="RTOSDemo" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="nios2.exec.debug.1446010332" name="Debug" parent="nios2.exec.debug">
|
||||
<toolChain id="com.altera.nj.ui.exe.Debug.241068812" name="com.altera.nj.ui.exe.Debug" superClass="com.altera.nj.ui.exe.Debug">
|
||||
<tool id="com.altera.nj.ui.tool.compiler.exe.debug.238740427" name="Nios II Compiler" superClass="com.altera.nj.ui.tool.compiler.exe.debug">
|
||||
<option id="nios2.compiler.general.include.paths.1954487624" superClass="nios2.compiler.general.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/RTOSDemo/FreeRTOS/portable/GCC/Nios2}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/RTOSDemo/Common_Demo_Tasks/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/RTOSDemo/FreeRTOS/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/RTOSDemo}""/>
|
||||
</option>
|
||||
</tool>
|
||||
<tool id="com.altera.nj.ui.tool.linker.exe.debug.2054232498" name="Linker" superClass="com.altera.nj.ui.tool.linker.exe.debug"/>
|
||||
<macros expandEnvironmentMacros="true"/>
|
||||
</toolChain>
|
||||
</configuration>
|
||||
<configuration artifactExtension="elf" artifactName="RTOSDemo" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="nios2.exec.release.654306637" name="Release" parent="nios2.exec.release">
|
||||
<toolChain id="com.altera.nj.ui.exe.Release.506996366" name="com.altera.nj.ui.exe.Release" superClass="com.altera.nj.ui.exe.Release">
|
||||
<tool id="com.altera.nj.ui.tool.compiler.exe.release.1487128363" name="Nios II Compiler" superClass="com.altera.nj.ui.tool.compiler.exe.release"/>
|
||||
<tool id="com.altera.nj.ui.tool.linker.exe.release.733767895" name="Linker" superClass="com.altera.nj.ui.tool.linker.exe.release"/>
|
||||
</toolChain>
|
||||
</configuration>
|
||||
<macros/>
|
||||
</project>
|
||||
</ManagedProjectBuildInfo>
|
65
Demo/NiosII_CycloneIII_DBC3C40_GCC/RTOSDemo/.cdtproject
Normal file
65
Demo/NiosII_CycloneIII_DBC3C40_GCC/RTOSDemo/.cdtproject
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?eclipse-cdt version="2.0"?>
|
||||
|
||||
<cdtproject id="org.eclipse.cdt.managedbuilder.core.managedMake">
|
||||
<extension id="org.eclipse.cdt.managedbuilder.core.ManagedBuildManager" point="org.eclipse.cdt.core.ScannerInfoProvider"/>
|
||||
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser">
|
||||
<attribute key="addr2line" value="addr2line"/>
|
||||
<attribute key="c++filt" value="c++filt"/>
|
||||
</extension>
|
||||
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser">
|
||||
<attribute key="addr2line" value="addr2line"/>
|
||||
<attribute key="c++filt" value="c++filt"/>
|
||||
</extension>
|
||||
<data>
|
||||
<item id="org.eclipse.cdt.core.pathentry">
|
||||
<pathentry kind="src" path=""/>
|
||||
<pathentry kind="out" path=""/>
|
||||
<pathentry kind="con" path="org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER"/>
|
||||
<pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>
|
||||
</item>
|
||||
<item id="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="false" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="makefileGenerator">
|
||||
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
|
||||
<parser enabled="false"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="false" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="false"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="false" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="false"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
</item>
|
||||
</data>
|
||||
</cdtproject>
|
90
Demo/NiosII_CycloneIII_DBC3C40_GCC/RTOSDemo/.project
Normal file
90
Demo/NiosII_CycloneIII_DBC3C40_GCC/RTOSDemo/.project
Normal file
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>RTOSDemo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
<project>RTOSDemo_syslib</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.make.core.makeBuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.append_environment</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.stopOnError</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.build.command</key>
|
||||
<value>make</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.build.target.inc</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.build.arguments</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.environment</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.build.target.auto</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.build.target.clean</key>
|
||||
<value>clean</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.core.errorOutputParser</key>
|
||||
<value>org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser;</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.altera.ide.core.alterabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.make.core.ScannerConfigBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>com.altera.ide.core.AlteraNios2Nature</nature>
|
||||
<nature>com.altera.ide.core.AlteraApplicationNature</nature>
|
||||
<nature>org.eclipse.cdt.make.core.makeNature</nature>
|
||||
<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,3 @@
|
|||
#Tue Aug 04 21:28:00 BST 2009
|
||||
eclipse.preferences.version=1
|
||||
indexerId=org.eclipse.cdt.core.fastIndexer
|
|
@ -0,0 +1,6 @@
|
|||
#Tue Aug 04 21:27:58 BST 2009
|
||||
eclipse.preferences.version=1
|
||||
nios2.exec.debug.746546544/internalBuilder/enabled=false
|
||||
nios2.exec.debug.746546544/internalBuilder/ignoreErr=true
|
||||
nios2.exec.release.1419815778/internalBuilder/enabled=false
|
||||
nios2.exec.release.1419815778/internalBuilder/ignoreErr=true
|
|
@ -0,0 +1,3 @@
|
|||
#Tue Aug 04 21:40:26 BST 2009
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
|
107
Demo/NiosII_CycloneIII_DBC3C40_GCC/RTOSDemo/FreeRTOSConfig.h
Normal file
107
Demo/NiosII_CycloneIII_DBC3C40_GCC/RTOSDemo/FreeRTOSConfig.h
Normal file
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
FreeRTOS V5.4.1 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
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.
|
||||
Alternative commercial license and support terms are also available upon
|
||||
request. See the licensing section of http://www.FreeRTOS.org for full
|
||||
license details.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Looking for a quick start? Then check out the FreeRTOS eBook! *
|
||||
* See http://www.FreeRTOS.org/Documentation for details *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
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
|
||||
|
||||
#include "system.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.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_IDLE_HOOK 0
|
||||
#define configUSE_TICK_HOOK 0
|
||||
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
|
||||
#define configCPU_CLOCK_HZ ( ( unsigned portLONG ) SYS_CLK_FREQ )
|
||||
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 )
|
||||
#define configMINIMAL_STACK_SIZE ( 1024 )
|
||||
#define configISR_STACK_SIZE configMINIMAL_STACK_SIZE
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) 8388608 )
|
||||
#define configMAX_TASK_NAME_LEN ( 8 )
|
||||
#define configUSE_TRACE_FACILITY 0
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 0
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configUSE_RECURSIVE_MUTEXES 1
|
||||
#define configUSE_COUNTING_SEMAPHORES 1
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||
#define configQUEUE_REGISTRY_SIZE 0
|
||||
|
||||
/* 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 1
|
||||
#define INCLUDE_vTaskCleanUpResources 0
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||
|
||||
/* The priority at which the tick interrupt runs. This should probably be
|
||||
kept at 1. */
|
||||
#define configKERNEL_INTERRUPT_PRIORITY 0x01
|
||||
|
||||
/* The maximum interrupt priority from which FreeRTOS.org API functions can
|
||||
be called. Only API functions that end in ...FromISR() can be used within
|
||||
interrupts. */
|
||||
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 0x03
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
110
Demo/NiosII_CycloneIII_DBC3C40_GCC/RTOSDemo/ParTest/ParTest.c
Normal file
110
Demo/NiosII_CycloneIII_DBC3C40_GCC/RTOSDemo/ParTest/ParTest.c
Normal file
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
FreeRTOS V5.4.1 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
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.
|
||||
Alternative commercial license and support terms are also available upon
|
||||
request. See the licensing section of http://www.FreeRTOS.org for full
|
||||
license details.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Looking for a quick start? Then check out the FreeRTOS eBook! *
|
||||
* See http://www.FreeRTOS.org/Documentation for details *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
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 parallel port IO routines.
|
||||
*-----------------------------------------------------------*/
|
||||
|
||||
|
||||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
/* Demo app includes. */
|
||||
#include "system.h"
|
||||
#include "altera_avalon_pio_regs.h"
|
||||
#include "partest.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#define partstNUM_LEDS ( 8 )
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static unsigned portLONG ulLedStates;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void vParTestInitialise( void )
|
||||
{
|
||||
IOWR_ALTERA_AVALON_PIO_DIRECTION( LED_PIO_BASE, ALTERA_AVALON_PIO_DIRECTION_OUTPUT );
|
||||
ulLedStates = 0;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
|
||||
{
|
||||
if( uxLED < partstNUM_LEDS )
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
if ( xValue > 0 )
|
||||
{
|
||||
ulLedStates |= 1 << uxLED;
|
||||
}
|
||||
else
|
||||
{
|
||||
ulLedStates &= ~( 1 << uxLED );
|
||||
}
|
||||
IOWR_ALTERA_AVALON_PIO_DATA( LED_PIO_BASE, ulLedStates );
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
|
||||
{
|
||||
if( uxLED < partstNUM_LEDS )
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
vParTestSetLED( uxLED, !( ulLedStates & ( 1 << uxLED ) ) );
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<stf>
|
||||
<project sdk="RTOSDemo_syslib" target="Nios II Application">
|
||||
</project>
|
||||
</stf>
|
552
Demo/NiosII_CycloneIII_DBC3C40_GCC/RTOSDemo/main.c
Normal file
552
Demo/NiosII_CycloneIII_DBC3C40_GCC/RTOSDemo/main.c
Normal file
|
@ -0,0 +1,552 @@
|
|||
/*
|
||||
FreeRTOS V5.4.1 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
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.
|
||||
Alternative commercial license and support terms are also available upon
|
||||
request. See the licensing section of http://www.FreeRTOS.org for full
|
||||
license details.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Looking for a quick start? Then check out the FreeRTOS eBook! *
|
||||
* See http://www.FreeRTOS.org/Documentation for details *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Creates all the demo application tasks, then starts the scheduler.
|
||||
* In addition to the standard demo tasks, the following tasks and tests are
|
||||
* defined and/or created within this file:
|
||||
*
|
||||
* "Check" task - This only executes every five seconds but has the highest
|
||||
* priority so is guaranteed to get processor time. Its main function is to
|
||||
* check that all the standard demo tasks are still operational. The check
|
||||
* task will write an error message to the console should an error be detected
|
||||
* within any of the demo tasks. The check task also toggles the LED defined
|
||||
* by mainCHECK_LED every 5 seconds while the system is error free, with the
|
||||
* toggle rate increasing to every 500ms should an error occur.
|
||||
*
|
||||
* "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.
|
||||
*
|
||||
* See the online documentation for this demo for more information on interrupt
|
||||
* usage.
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* Demo application includes. */
|
||||
#include "partest.h"
|
||||
#include "flash.h"
|
||||
#include "blocktim.h"
|
||||
#include "semtest.h"
|
||||
#include "serial.h"
|
||||
#include "comtest.h"
|
||||
#include "GenQTest.h"
|
||||
#include "QPeek.h"
|
||||
#include "integer.h"
|
||||
#include "PollQ.h"
|
||||
#include "BlockQ.h"
|
||||
#include "dynamic.h"
|
||||
#include "countsem.h"
|
||||
#include "recmutex.h"
|
||||
#include "death.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The rate at which the LED controlled by the 'check' task will toggle when no
|
||||
errors have been detected. */
|
||||
#define mainNO_ERROR_PERIOD ( 5000 )
|
||||
|
||||
/* The rate at which the LED controlled by the 'check' task will toggle when an
|
||||
error has been detected. */
|
||||
#define mainERROR_PERIOD ( 500 )
|
||||
|
||||
/* The LED toggled by the Check task. */
|
||||
#define mainCHECK_LED ( 7 )
|
||||
|
||||
/* The first LED used by the ComTest tasks. One LED toggles each time a
|
||||
character is transmitted, and one each time a character is received and
|
||||
verified as being the expected character. */
|
||||
#define mainCOMTEST_LED ( 4 )
|
||||
|
||||
/* Priority definitions for the tasks in the demo application. */
|
||||
#define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
||||
#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
|
||||
#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainQUEUE_BLOCK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
||||
#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainSEMAPHORE_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainGENERIC_QUEUE_PRIORITY ( tskIDLE_PRIORITY )
|
||||
#define mainREG_TEST_PRIORITY ( tskIDLE_PRIORITY )
|
||||
|
||||
/* Misc. */
|
||||
#define mainDONT_WAIT ( 0 )
|
||||
|
||||
/* The parameters passed to the reg test tasks. This is just done to check
|
||||
the parameter passing mechanism is working correctly. */
|
||||
#define mainREG_TEST_1_PARAMETER ( ( void * ) 0x12345678 )
|
||||
#define mainREG_TEST_2_PARAMETER ( ( void * ) 0x87654321 )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Setup the processor ready for the demo.
|
||||
*/
|
||||
static void prvSetupHardware( void );
|
||||
|
||||
/*
|
||||
* Execute all of the check functions to ensure the tests haven't failed.
|
||||
*/
|
||||
static void prvCheckTask( void *pvParameters );
|
||||
|
||||
/*
|
||||
* The register test (or RegTest) tasks as described at the top of this file.
|
||||
*/
|
||||
static void prvFirstRegTestTask( void *pvParameters );
|
||||
static void prvSecondRegTestTask( void *pvParameters );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Counters that are incremented on each iteration of the RegTest tasks
|
||||
so long as no errors have been detected. */
|
||||
volatile unsigned long ulRegTest1Counter = 0UL, ulRegTest2Counter = 0UL;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Create the demo tasks then start the scheduler.
|
||||
*/
|
||||
int main( void )
|
||||
{
|
||||
/* Configure any hardware required for this demo. */
|
||||
prvSetupHardware();
|
||||
|
||||
/* Create all the other standard demo tasks. These serve no purpose other
|
||||
than to test the port and demonstrate the use of the FreeRTOS API. */
|
||||
vStartLEDFlashTasks( tskIDLE_PRIORITY );
|
||||
vStartIntegerMathTasks( mainGENERIC_QUEUE_PRIORITY );
|
||||
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
|
||||
vStartBlockingQueueTasks( mainQUEUE_BLOCK_PRIORITY );
|
||||
vCreateBlockTimeTasks();
|
||||
vStartSemaphoreTasks( mainSEMAPHORE_TASK_PRIORITY );
|
||||
vStartDynamicPriorityTasks();
|
||||
vStartQueuePeekTasks();
|
||||
vStartGenericQueueTasks( mainGENERIC_QUEUE_PRIORITY );
|
||||
vStartCountingSemaphoreTasks();
|
||||
vStartRecursiveMutexTasks();
|
||||
vAltStartComTestTasks( mainCOM_TEST_PRIORITY, 0, mainCOMTEST_LED );
|
||||
|
||||
/* prvCheckTask uses sprintf so requires more stack. */
|
||||
xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
|
||||
|
||||
/* The RegTest tasks as described at the top of this file. */
|
||||
xTaskCreate( prvFirstRegTestTask, "Rreg1", configMINIMAL_STACK_SIZE, mainREG_TEST_1_PARAMETER, mainREG_TEST_PRIORITY, NULL );
|
||||
xTaskCreate( prvSecondRegTestTask, "Rreg2", configMINIMAL_STACK_SIZE, mainREG_TEST_2_PARAMETER, mainREG_TEST_PRIORITY, NULL );
|
||||
|
||||
/* This task has to be created last as it keeps account of the number of tasks
|
||||
it expects to see running. */
|
||||
vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
|
||||
|
||||
/* Finally start the scheduler. */
|
||||
vTaskStartScheduler();
|
||||
|
||||
/* Will only reach here if there is insufficient heap available to start
|
||||
the scheduler. */
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSetupHardware( void )
|
||||
{
|
||||
/* Setup the digital IO for the LED's. */
|
||||
vParTestInitialise();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationStackOverflowHook( void )
|
||||
{
|
||||
/* Look at pxCurrentTCB to see which task overflowed its stack. */
|
||||
for( ;; )
|
||||
{
|
||||
asm( "break" );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void _general_exception_handler( unsigned portLONG ulCause, unsigned portLONG ulStatus )
|
||||
{
|
||||
/* This overrides the definition provided by the kernel. Other exceptions
|
||||
should be handled here. */
|
||||
for( ;; )
|
||||
{
|
||||
asm( "break" );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCheckTask( void *pvParameters )
|
||||
{
|
||||
portTickType xLastExecutionTime, ulTicksToWait = mainNO_ERROR_PERIOD;
|
||||
unsigned long ulLastRegTest1 = 0UL, ulLastRegTest2 = 0UL;
|
||||
const portCHAR * pcMessage;
|
||||
|
||||
/* Initialise the variable used to control our iteration rate prior to
|
||||
its first use. */
|
||||
xLastExecutionTime = xTaskGetTickCount();
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Wait until it is time to run the tests again. */
|
||||
vTaskDelayUntil( &xLastExecutionTime, ulTicksToWait );
|
||||
|
||||
/* Have any of the standard demo tasks detected an error in their
|
||||
operation? */
|
||||
if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
pcMessage = "Error: Integer Maths.\n";
|
||||
}
|
||||
else if( xAreGenericQueueTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
pcMessage = "Error: GenQ.\n";
|
||||
}
|
||||
else if( xAreBlockingQueuesStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
pcMessage = "Error: BlockQ.\n";
|
||||
}
|
||||
else if( xArePollingQueuesStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
pcMessage = "Error: PollQ.\n";
|
||||
}
|
||||
else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
pcMessage = "Error: PeekQ.\n";
|
||||
}
|
||||
else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
pcMessage = "Error: Block Time.\n";
|
||||
}
|
||||
else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
pcMessage = "Error: Semaphore Test.\n";
|
||||
}
|
||||
else if( xAreComTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
pcMessage = "Error: Comm Test.\n";
|
||||
}
|
||||
else if( xIsCreateTaskStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
pcMessage = "Error: Suicidal Tasks.\n";
|
||||
}
|
||||
else if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
pcMessage = "Error: Dynamic Priority.\n";
|
||||
}
|
||||
else if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
pcMessage = "Error: Count Semaphore.\n";
|
||||
}
|
||||
else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
pcMessage = "Error: Recursive Mutex.\n";
|
||||
}
|
||||
else if( ulLastRegTest1 == ulRegTest1Counter )
|
||||
{
|
||||
/* ulRegTest1Counter is no longer being incremented, indicating
|
||||
that an error has been discovered in prvFirstRegTestTask(). */
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
pcMessage = "Error: Reg Test1.\n";
|
||||
}
|
||||
else if( ulLastRegTest2 == ulRegTest2Counter )
|
||||
{
|
||||
/* ulRegTest2Counter is no longer being incremented, indicating
|
||||
that an error has been discovered in prvSecondRegTestTask(). */
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
pcMessage = "Error: Reg Test2.\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
pcMessage = NULL;
|
||||
}
|
||||
|
||||
/* Remember the counter values this time around so a counter failing
|
||||
to be incremented correctly can be spotted. */
|
||||
ulLastRegTest1 = ulRegTest1Counter;
|
||||
ulLastRegTest2 = ulRegTest2Counter;
|
||||
|
||||
/* Print out an error message if there is one. Mutual exclusion is
|
||||
not used as this is the only task accessing stdout. */
|
||||
if( pcMessage != NULL )
|
||||
{
|
||||
printf( pcMessage );
|
||||
}
|
||||
|
||||
/* Provide visual feedback of the system status. If the LED is toggled
|
||||
every 5 seconds then no errors have been found. If the LED is toggled
|
||||
every 500ms then at least one error has been found. */
|
||||
vParTestToggleLED( mainCHECK_LED );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvFirstRegTestTask( void *pvParameters )
|
||||
{
|
||||
/* Check the parameters are passed in as expected. */
|
||||
if( pvParameters != mainREG_TEST_1_PARAMETER )
|
||||
{
|
||||
/* Don't execute any further so an error is recognised by the check
|
||||
task. */
|
||||
vTaskDelete( NULL );
|
||||
}
|
||||
|
||||
/* Fill registers with known values, then check that each register still
|
||||
contains its expected value. An incorrect value is indicative of an error
|
||||
in the context switching process.
|
||||
|
||||
If no errors are found ulRegTest1Counter is incremented. The check task
|
||||
will recognise an error if ulRegTest1Counter stops being incremented.
|
||||
This task also performs a manual yield in the middle of its execution, just
|
||||
to increase the test coverage. */
|
||||
asm volatile (
|
||||
" .extern ulRegTest1Counter \n" \
|
||||
" \n" \
|
||||
" addi r3, r0, 3 \n" \
|
||||
" addi r4, r0, 4 \n" \
|
||||
" addi r5, r0, 5 \n" \
|
||||
" addi r6, r0, 6 \n" \
|
||||
" addi r7, r0, 7 \n" \
|
||||
" addi r8, r0, 8 \n" \
|
||||
" addi r9, r0, 9 \n" \
|
||||
" addi r10, r0, 10 \n" \
|
||||
" addi r11, r0, 11 \n" \
|
||||
" addi r12, r0, 12 \n" \
|
||||
" addi r13, r0, 13 \n" \
|
||||
" addi r14, r0, 14 \n" \
|
||||
" addi r15, r0, 15 \n" \
|
||||
" addi r16, r0, 16 \n" \
|
||||
" addi r17, r0, 17 \n" \
|
||||
" addi r18, r0, 18 \n" \
|
||||
" addi r19, r0, 19 \n" \
|
||||
" addi r20, r0, 20 \n" \
|
||||
" addi r21, r0, 21 \n" \
|
||||
" addi r22, r0, 22 \n" \
|
||||
" addi r23, r0, 23 \n" \
|
||||
" addi r28, r0, 28 \n" \
|
||||
" addi r31, r0, 31 \n" \
|
||||
"RegTest1: \n" \
|
||||
" addi r2, r0, 0 \n" \
|
||||
" trap \n" \
|
||||
" bne r2, r0, RegTest1Error \n" \
|
||||
" addi r2, r0, 3 \n" \
|
||||
" bne r2, r3, RegTest1Error \n" \
|
||||
" addi r2, r0, 4 \n" \
|
||||
" bne r2, r4, RegTest1Error \n" \
|
||||
" addi r2, r0, 5 \n" \
|
||||
" bne r2, r5, RegTest1Error \n" \
|
||||
" addi r2, r0, 6 \n" \
|
||||
" bne r2, r6, RegTest1Error \n" \
|
||||
" addi r2, r0, 7 \n" \
|
||||
" bne r2, r7, RegTest1Error \n" \
|
||||
" addi r2, r0, 8 \n" \
|
||||
" bne r2, r8, RegTest1Error \n" \
|
||||
" addi r2, r0, 9 \n" \
|
||||
" bne r2, r9, RegTest1Error \n" \
|
||||
" addi r2, r0, 10 \n" \
|
||||
" bne r2, r10, RegTest1Error \n" \
|
||||
" addi r2, r0, 11 \n" \
|
||||
" bne r2, r11, RegTest1Error \n" \
|
||||
" addi r2, r0, 12 \n" \
|
||||
" bne r2, r12, RegTest1Error \n" \
|
||||
" addi r2, r0, 13 \n" \
|
||||
" bne r2, r13, RegTest1Error \n" \
|
||||
" addi r2, r0, 14 \n" \
|
||||
" bne r2, r14, RegTest1Error \n" \
|
||||
" addi r2, r0, 15 \n" \
|
||||
" bne r2, r15, RegTest1Error \n" \
|
||||
" addi r2, r0, 16 \n" \
|
||||
" bne r2, r16, RegTest1Error \n" \
|
||||
" addi r2, r0, 17 \n" \
|
||||
" bne r2, r17, RegTest1Error \n" \
|
||||
" addi r2, r0, 18 \n" \
|
||||
" bne r2, r18, RegTest1Error \n" \
|
||||
" addi r2, r0, 19 \n" \
|
||||
" bne r2, r19, RegTest1Error \n" \
|
||||
" addi r2, r0, 20 \n" \
|
||||
" bne r2, r20, RegTest1Error \n" \
|
||||
" addi r2, r0, 21 \n" \
|
||||
" bne r2, r21, RegTest1Error \n" \
|
||||
" addi r2, r0, 22 \n" \
|
||||
" bne r2, r22, RegTest1Error \n" \
|
||||
" addi r2, r0, 23 \n" \
|
||||
" bne r2, r23, RegTest1Error \n" \
|
||||
" addi r2, r0, 28 \n" \
|
||||
" bne r2, r28, RegTest1Error \n" \
|
||||
" addi r2, r0, 31 \n" \
|
||||
" bne r2, r31, RegTest1Error \n" \
|
||||
" ldw r2, %gprel(ulRegTest1Counter)(gp) \n" \
|
||||
" addi r2, r2, 1 \n" \
|
||||
" stw r2, %gprel(ulRegTest1Counter)(gp) \n" \
|
||||
" br RegTest1 \n" \
|
||||
"RegTest1Error: \n" \
|
||||
" br RegTest1Error \n"
|
||||
);
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSecondRegTestTask( void *pvParameters )
|
||||
{
|
||||
/* Check the parameters are passed in as expected. */
|
||||
if( pvParameters != mainREG_TEST_2_PARAMETER )
|
||||
{
|
||||
/* Don't execute any further so an error is recognised by the check
|
||||
task. */
|
||||
vTaskDelete( NULL );
|
||||
}
|
||||
|
||||
/* Fill registers with known values, then check that each register still
|
||||
contains its expected value. An incorrect value is indicative of an error
|
||||
in the context switching process.
|
||||
|
||||
If no errors are found ulRegTest2Counter is incremented. The check task
|
||||
will recognise an error if ulRegTest2Counter stops being incremented. */
|
||||
asm volatile (
|
||||
" .extern ulRegTest2Counter \n" \
|
||||
" \n" \
|
||||
" addi r3, r0, 3 \n" \
|
||||
" addi r4, r0, 4 \n" \
|
||||
" addi r5, r0, 5 \n" \
|
||||
" addi r6, r0, 6 \n" \
|
||||
" addi r7, r0, 7 \n" \
|
||||
" addi r8, r0, 8 \n" \
|
||||
" addi r9, r0, 9 \n" \
|
||||
" addi r10, r0, 10 \n" \
|
||||
" addi r11, r0, 11 \n" \
|
||||
" addi r12, r0, 12 \n" \
|
||||
" addi r13, r0, 13 \n" \
|
||||
" addi r14, r0, 14 \n" \
|
||||
" addi r15, r0, 15 \n" \
|
||||
" addi r16, r0, 16 \n" \
|
||||
" addi r17, r0, 17 \n" \
|
||||
" addi r18, r0, 18 \n" \
|
||||
" addi r19, r0, 19 \n" \
|
||||
" addi r20, r0, 20 \n" \
|
||||
" addi r21, r0, 21 \n" \
|
||||
" addi r22, r0, 22 \n" \
|
||||
" addi r23, r0, 23 \n" \
|
||||
" addi r28, r0, 28 \n" \
|
||||
" addi r31, r0, 31 \n" \
|
||||
"RegTest2: \n" \
|
||||
" addi r2, r0, 0 \n" \
|
||||
" bne r2, r0, RegTest2Error \n" \
|
||||
" addi r2, r0, 3 \n" \
|
||||
" bne r2, r3, RegTest2Error \n" \
|
||||
" addi r2, r0, 4 \n" \
|
||||
" bne r2, r4, RegTest2Error \n" \
|
||||
" addi r2, r0, 5 \n" \
|
||||
" bne r2, r5, RegTest2Error \n" \
|
||||
" addi r2, r0, 6 \n" \
|
||||
" bne r2, r6, RegTest2Error \n" \
|
||||
" addi r2, r0, 7 \n" \
|
||||
" bne r2, r7, RegTest2Error \n" \
|
||||
" addi r2, r0, 8 \n" \
|
||||
" bne r2, r8, RegTest2Error \n" \
|
||||
" addi r2, r0, 9 \n" \
|
||||
" bne r2, r9, RegTest2Error \n" \
|
||||
" addi r2, r0, 10 \n" \
|
||||
" bne r2, r10, RegTest2Error \n" \
|
||||
" addi r2, r0, 11 \n" \
|
||||
" bne r2, r11, RegTest2Error \n" \
|
||||
" addi r2, r0, 12 \n" \
|
||||
" bne r2, r12, RegTest2Error \n" \
|
||||
" addi r2, r0, 13 \n" \
|
||||
" bne r2, r13, RegTest2Error \n" \
|
||||
" addi r2, r0, 14 \n" \
|
||||
" bne r2, r14, RegTest2Error \n" \
|
||||
" addi r2, r0, 15 \n" \
|
||||
" bne r2, r15, RegTest2Error \n" \
|
||||
" addi r2, r0, 16 \n" \
|
||||
" bne r2, r16, RegTest2Error \n" \
|
||||
" addi r2, r0, 17 \n" \
|
||||
" bne r2, r17, RegTest2Error \n" \
|
||||
" addi r2, r0, 18 \n" \
|
||||
" bne r2, r18, RegTest2Error \n" \
|
||||
" addi r2, r0, 19 \n" \
|
||||
" bne r2, r19, RegTest2Error \n" \
|
||||
" addi r2, r0, 20 \n" \
|
||||
" bne r2, r20, RegTest2Error \n" \
|
||||
" addi r2, r0, 21 \n" \
|
||||
" bne r2, r21, RegTest2Error \n" \
|
||||
" addi r2, r0, 22 \n" \
|
||||
" bne r2, r22, RegTest2Error \n" \
|
||||
" addi r2, r0, 23 \n" \
|
||||
" bne r2, r23, RegTest2Error \n" \
|
||||
" addi r2, r0, 28 \n" \
|
||||
" bne r2, r28, RegTest2Error \n" \
|
||||
" addi r2, r0, 31 \n" \
|
||||
" bne r2, r31, RegTest2Error \n" \
|
||||
" ldw r2, %gprel(ulRegTest2Counter)(gp) \n" \
|
||||
" addi r2, r2, 1 \n" \
|
||||
" stw r2, %gprel(ulRegTest2Counter)(gp) \n" \
|
||||
" br RegTest2 \n" \
|
||||
"RegTest2Error: \n" \
|
||||
" br RegTest2Error \n"
|
||||
);
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
241
Demo/NiosII_CycloneIII_DBC3C40_GCC/RTOSDemo/serial.c
Normal file
241
Demo/NiosII_CycloneIII_DBC3C40_GCC/RTOSDemo/serial.c
Normal file
|
@ -0,0 +1,241 @@
|
|||
/*
|
||||
FreeRTOS V5.4.1 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
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.
|
||||
Alternative commercial license and support terms are also available upon
|
||||
request. See the licensing section of http://www.FreeRTOS.org for full
|
||||
license details.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Looking for a quick start? Then check out the FreeRTOS eBook! *
|
||||
* See http://www.FreeRTOS.org/Documentation for details *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/* NOTE: This is just a test file and not intended to be a generic
|
||||
COM driver. */
|
||||
|
||||
#include "altera_avalon_uart.h"
|
||||
#include "altera_avalon_uart_regs.h"
|
||||
#include "sys/alt_irq.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
#include "system.h"
|
||||
#include "Serial.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#define serINVALID_QUEUE ( ( xQueueHandle ) 0 )
|
||||
#define serNO_BLOCK ( ( portTickType ) 0 )
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static xQueueHandle xRxedChars;
|
||||
static xQueueHandle xCharsForTx;
|
||||
|
||||
alt_u32 uartControl;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static void vUARTInterruptHandler( void* context, alt_u32 id );
|
||||
static void vUARTReceiveHandler( alt_u32 status );
|
||||
static void vUARTTransmitHandler( alt_u32 status );
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
xComPortHandle xSerialPortInitMinimal( unsigned portLONG ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
|
||||
{
|
||||
/* Create the queues used to hold Rx and Tx characters. */
|
||||
xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) );
|
||||
xCharsForTx = xQueueCreate( uxQueueLength + 1, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) );
|
||||
|
||||
/* If the queues were created correctly then setup the serial port hardware. */
|
||||
if( ( xRxedChars != serINVALID_QUEUE ) && ( xCharsForTx != serINVALID_QUEUE ) )
|
||||
{
|
||||
portENTER_CRITICAL();
|
||||
{
|
||||
uartControl = ALTERA_AVALON_UART_CONTROL_RTS_MSK | ALTERA_AVALON_UART_CONTROL_RRDY_MSK | ALTERA_AVALON_UART_CONTROL_DCTS_MSK;
|
||||
IOWR_ALTERA_AVALON_UART_CONTROL( UART_BASE, uartControl );
|
||||
|
||||
/* register the interrupt handler */
|
||||
alt_irq_register ( UART_IRQ, NULL, vUARTInterruptHandler );
|
||||
}
|
||||
portEXIT_CRITICAL();
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( xComPortHandle ) 0;
|
||||
}
|
||||
return ( xComPortHandle ) 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void vSerialClose( xComPortHandle xPort )
|
||||
{
|
||||
/* Never used. */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed portCHAR *pcRxedChar, portTickType xBlockTime )
|
||||
{
|
||||
/* The port handle is not required as this driver only supports one port. */
|
||||
( void ) pxPort;
|
||||
|
||||
|
||||
/* Get the next character from the buffer. Return false if no characters
|
||||
are available, or arrive before xBlockTime expires. */
|
||||
if( xQueueReceive( xRxedChars, pcRxedChar, xBlockTime ) )
|
||||
{
|
||||
return pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
uartControl |= ALTERA_AVALON_UART_CONTROL_RRDY_MSK;
|
||||
IOWR_ALTERA_AVALON_UART_CONTROL( UART_BASE, uartControl );
|
||||
return pdFALSE;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed portCHAR cOutChar, portTickType xBlockTime )
|
||||
{
|
||||
signed portBASE_TYPE lReturn = pdPASS;
|
||||
|
||||
/* Place the character in the queue of characters to be transmitted. */
|
||||
if( xQueueSend( xCharsForTx, &cOutChar, xBlockTime ) == pdPASS )
|
||||
{
|
||||
/*Triggers an interrupt on every character or (down) when queue is full. */
|
||||
uartControl |= ALTERA_AVALON_UART_CONTROL_TRDY_MSK;
|
||||
IOWR_ALTERA_AVALON_UART_CONTROL( UART_BASE, uartControl );
|
||||
lReturn = pdPASS;
|
||||
}
|
||||
else
|
||||
{
|
||||
lReturn = pdFAIL;
|
||||
}
|
||||
return lReturn;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void vSerialPutString( xComPortHandle pxPort, const signed portCHAR * const pcString, unsigned portSHORT usStringLength )
|
||||
{
|
||||
signed portCHAR *pxNext;
|
||||
|
||||
/* A couple of parameters that this port does not use. */
|
||||
( void ) usStringLength;
|
||||
( void ) pxPort;
|
||||
|
||||
/* NOTE: This implementation does not handle the queue being full as no block time is used! */
|
||||
|
||||
/* The port handle is not required as this driver only supports UART0. */
|
||||
( void ) pxPort;
|
||||
|
||||
/* Send each character in the string, one at a time. */
|
||||
pxNext = ( signed portCHAR * ) pcString;
|
||||
while( *pxNext )
|
||||
{
|
||||
xSerialPutChar( pxPort, *pxNext, serNO_BLOCK );
|
||||
pxNext++;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void vUARTInterruptHandler( void* context, alt_u32 id )
|
||||
{
|
||||
alt_u32 status;
|
||||
|
||||
/* Read the status register in order to determine the cause of the
|
||||
interrupt. */
|
||||
status = IORD_ALTERA_AVALON_UART_STATUS( UART_BASE );
|
||||
|
||||
/* Clear any error flags set at the device */
|
||||
IOWR_ALTERA_AVALON_UART_STATUS( UART_BASE, 0 );
|
||||
|
||||
/* process a read irq */
|
||||
if ( status & ALTERA_AVALON_UART_STATUS_RRDY_MSK )
|
||||
{
|
||||
vUARTReceiveHandler( status );
|
||||
}
|
||||
|
||||
/* process a write irq */
|
||||
if ( status & ( ALTERA_AVALON_UART_STATUS_TRDY_MSK ) )
|
||||
{
|
||||
vUARTTransmitHandler( status );
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static void vUARTReceiveHandler( alt_u32 status )
|
||||
{
|
||||
signed portCHAR cChar;
|
||||
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
/* If there was an error, discard the data */
|
||||
if ( status & ( ALTERA_AVALON_UART_STATUS_PE_MSK | ALTERA_AVALON_UART_STATUS_FE_MSK ) )
|
||||
{
|
||||
asm("break");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Transfer data from the device to the circular buffer */
|
||||
cChar = IORD_ALTERA_AVALON_UART_RXDATA( UART_BASE );
|
||||
if ( pdTRUE != xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken ) )
|
||||
{
|
||||
/* If the circular buffer was full, disable interrupts. Interrupts will
|
||||
be re-enabled when data is removed from the buffer. */
|
||||
uartControl &= ~ALTERA_AVALON_UART_CONTROL_RRDY_MSK;
|
||||
IOWR_ALTERA_AVALON_UART_CONTROL( UART_BASE, uartControl );
|
||||
}
|
||||
|
||||
portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static void vUARTTransmitHandler( alt_u32 status )
|
||||
{
|
||||
signed portCHAR cChar;
|
||||
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||
/* Transfer data if there is some ready to be transferred */
|
||||
if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE )
|
||||
{
|
||||
IOWR_ALTERA_AVALON_UART_TXDATA( UART_BASE, cChar );
|
||||
}
|
||||
else
|
||||
{
|
||||
uartControl &= ~ALTERA_AVALON_UART_CONTROL_TRDY_MSK;
|
||||
}
|
||||
|
||||
IOWR_ALTERA_AVALON_UART_CONTROL( UART_BASE, uartControl );
|
||||
portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
Loading…
Add table
Add a link
Reference in a new issue