mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-19 09:38:32 -04:00
Add FreeRTOS-Plus directory.
This commit is contained in:
parent
7bd5f21ad5
commit
f508a5f653
6798 changed files with 134949 additions and 19 deletions
177
FreeRTOS/Source/portable/WizC/PIC18/Drivers/Tick/Tick.c
Normal file
177
FreeRTOS/Source/portable/WizC/PIC18/Drivers/Tick/Tick.c
Normal file
|
@ -0,0 +1,177 @@
|
|||
/*
|
||||
FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS tutorial books are available in pdf and paperback. *
|
||||
* Complete, revised, and edited pdf reference manuals are also *
|
||||
* available. *
|
||||
* *
|
||||
* Purchasing FreeRTOS documentation will not only help you, by *
|
||||
* ensuring you get running as quickly as possible and with an *
|
||||
* in-depth knowledge of how to use FreeRTOS, it will also help *
|
||||
* the FreeRTOS project to continue with its mission of providing *
|
||||
* professional grade, cross platform, de facto standard solutions *
|
||||
* for microcontrollers - completely free of charge! *
|
||||
* *
|
||||
* >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
|
||||
* *
|
||||
* Thank you for using FreeRTOS, and thank you for your support! *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||
>>>NOTE<<< The modification to the GPL is included to allow you to
|
||||
distribute a combined work that includes FreeRTOS without being obliged to
|
||||
provide the source code for proprietary components outside of the FreeRTOS
|
||||
kernel. FreeRTOS is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details. You should have received a copy of the GNU General Public
|
||||
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
||||
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
||||
by writing to Richard Barry, contact details for whom are available on the
|
||||
FreeRTOS WEB site.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Having a problem? Start by reading the FAQ "My application does *
|
||||
* not run, what could be wrong? *
|
||||
* *
|
||||
* http://www.FreeRTOS.org/FAQHelp.html *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, training, latest information,
|
||||
license and contact details.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool.
|
||||
|
||||
Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
|
||||
the code with commercial support, indemnification, and middleware, under
|
||||
the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
|
||||
provide a safety engineered and independently SIL3 certified version under
|
||||
the SafeRTOS brand: http://www.SafeRTOS.com.
|
||||
*/
|
||||
|
||||
/*
|
||||
Changes from V3.0.0
|
||||
+ ISRcode is pulled inline and portTICKisr() is therefore
|
||||
deleted from this file.
|
||||
|
||||
+ Prescaler logic for Timer1 added to allow for a wider
|
||||
range of TickRates.
|
||||
|
||||
Changes from V3.0.1
|
||||
*/
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
|
||||
/* IO port constants. */
|
||||
#define portBIT_SET (1)
|
||||
#define portBIT_CLEAR (0)
|
||||
|
||||
/*
|
||||
* Hardware setup for the tick.
|
||||
* We use a compare match on timer1. Depending on MPU-frequency
|
||||
* and requested tickrate, a prescaled value with a matching
|
||||
* prescaler are determined.
|
||||
*/
|
||||
#define portTIMER_COMPARE_BASE ((APROCFREQ/4)/configTICK_RATE_HZ)
|
||||
|
||||
#if portTIMER_COMPARE_BASE < 0x10000
|
||||
#define portTIMER_COMPARE_VALUE (portTIMER_COMPARE_BASE)
|
||||
#define portTIMER_COMPARE_PS1 (portBIT_CLEAR)
|
||||
#define portTIMER_COMPARE_PS0 (portBIT_CLEAR)
|
||||
#elif portTIMER_COMPARE_BASE < 0x20000
|
||||
#define portTIMER_COMPARE_VALUE (portTIMER_COMPARE_BASE / 2)
|
||||
#define portTIMER_COMPARE_PS1 (portBIT_CLEAR)
|
||||
#define portTIMER_COMPARE_PS0 (portBIT_SET)
|
||||
#elif portTIMER_COMPARE_BASE < 0x40000
|
||||
#define portTIMER_COMPARE_VALUE (portTIMER_COMPARE_BASE / 4)
|
||||
#define portTIMER_COMPARE_PS1 (portBIT_SET)
|
||||
#define portTIMER_COMPARE_PS0 (portBIT_CLEAR)
|
||||
#elif portTIMER_COMPARE_BASE < 0x80000
|
||||
#define portTIMER_COMPARE_VALUE (portTIMER_COMPARE_BASE / 8)
|
||||
#define portTIMER_COMPARE_PS1 (portBIT_SET)
|
||||
#define portTIMER_COMPARE_PS0 (portBIT_SET)
|
||||
#else
|
||||
#error "TickRate out of range"
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Setup a timer for a regular tick.
|
||||
*/
|
||||
void portSetupTick( void )
|
||||
{
|
||||
/*
|
||||
* Interrupts are disabled when this function is called.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Setup CCP1
|
||||
* Provide the tick interrupt using a compare match on timer1.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Set the compare match value.
|
||||
*/
|
||||
CCPR1H = ( unsigned char ) ( ( portTIMER_COMPARE_VALUE >> 8 ) & 0xff );
|
||||
CCPR1L = ( unsigned char ) ( portTIMER_COMPARE_VALUE & 0xff );
|
||||
|
||||
/*
|
||||
* Set Compare Special Event Trigger Mode
|
||||
*/
|
||||
bCCP1M3 = portBIT_SET;
|
||||
bCCP1M2 = portBIT_CLEAR;
|
||||
bCCP1M1 = portBIT_SET;
|
||||
bCCP1M0 = portBIT_SET;
|
||||
|
||||
/*
|
||||
* Enable CCP1 interrupt
|
||||
*/
|
||||
bCCP1IE = portBIT_SET;
|
||||
|
||||
/*
|
||||
* We are only going to use the global interrupt bit, so disable
|
||||
* interruptpriorities and enable peripheral interrupts.
|
||||
*/
|
||||
bIPEN = portBIT_CLEAR;
|
||||
bPEIE = portBIT_SET;
|
||||
|
||||
/*
|
||||
* Set up timer1
|
||||
* It will produce the system tick.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Clear the time count
|
||||
*/
|
||||
TMR1H = ( unsigned char ) 0x00;
|
||||
TMR1L = ( unsigned char ) 0x00;
|
||||
|
||||
/*
|
||||
* Setup the timer
|
||||
*/
|
||||
bRD16 = portBIT_SET; // 16-bit
|
||||
bT1CKPS1 = portTIMER_COMPARE_PS1; // prescaler
|
||||
bT1CKPS0 = portTIMER_COMPARE_PS0; // prescaler
|
||||
bT1OSCEN = portBIT_SET; // Oscillator enable
|
||||
bT1SYNC = portBIT_SET; // No external clock sync
|
||||
bTMR1CS = portBIT_CLEAR; // Internal clock
|
||||
|
||||
bTMR1ON = portBIT_SET; // Start timer1
|
||||
}
|
120
FreeRTOS/Source/portable/WizC/PIC18/Drivers/Tick/isrTick.c
Normal file
120
FreeRTOS/Source/portable/WizC/PIC18/Drivers/Tick/isrTick.c
Normal file
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS tutorial books are available in pdf and paperback. *
|
||||
* Complete, revised, and edited pdf reference manuals are also *
|
||||
* available. *
|
||||
* *
|
||||
* Purchasing FreeRTOS documentation will not only help you, by *
|
||||
* ensuring you get running as quickly as possible and with an *
|
||||
* in-depth knowledge of how to use FreeRTOS, it will also help *
|
||||
* the FreeRTOS project to continue with its mission of providing *
|
||||
* professional grade, cross platform, de facto standard solutions *
|
||||
* for microcontrollers - completely free of charge! *
|
||||
* *
|
||||
* >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
|
||||
* *
|
||||
* Thank you for using FreeRTOS, and thank you for your support! *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||
>>>NOTE<<< The modification to the GPL is included to allow you to
|
||||
distribute a combined work that includes FreeRTOS without being obliged to
|
||||
provide the source code for proprietary components outside of the FreeRTOS
|
||||
kernel. FreeRTOS is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details. You should have received a copy of the GNU General Public
|
||||
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
||||
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
||||
by writing to Richard Barry, contact details for whom are available on the
|
||||
FreeRTOS WEB site.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Having a problem? Start by reading the FAQ "My application does *
|
||||
* not run, what could be wrong? *
|
||||
* *
|
||||
* http://www.FreeRTOS.org/FAQHelp.html *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, training, latest information,
|
||||
license and contact details.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool.
|
||||
|
||||
Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
|
||||
the code with commercial support, indemnification, and middleware, under
|
||||
the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
|
||||
provide a safety engineered and independently SIL3 certified version under
|
||||
the SafeRTOS brand: http://www.SafeRTOS.com.
|
||||
*/
|
||||
|
||||
/*
|
||||
Changes from V3.0.0
|
||||
+ ISRcode pulled inline to reduce stack-usage.
|
||||
|
||||
+ Added functionality to only call vTaskSwitchContext() once
|
||||
when handling multiple interruptsources in a single interruptcall.
|
||||
|
||||
+ Filename changed to a .c extension to allow stepping through code
|
||||
using F7.
|
||||
|
||||
Changes from V3.0.1
|
||||
*/
|
||||
|
||||
/*
|
||||
* ISR for the tick.
|
||||
* This increments the tick count and, if using the preemptive scheduler,
|
||||
* performs a context switch. This must be identical to the manual
|
||||
* context switch in how it stores the context of a task.
|
||||
*/
|
||||
|
||||
#ifndef _FREERTOS_DRIVERS_TICK_ISRTICK_C
|
||||
#define _FREERTOS_DRIVERS_TICK_ISRTICK_C
|
||||
|
||||
{
|
||||
/*
|
||||
* Was the interrupt the SystemClock?
|
||||
*/
|
||||
if( bCCP1IF && bCCP1IE )
|
||||
{
|
||||
/*
|
||||
* Reset the interrupt flag
|
||||
*/
|
||||
bCCP1IF = 0;
|
||||
|
||||
/*
|
||||
* Maintain the tick count.
|
||||
*/
|
||||
vTaskIncrementTick();
|
||||
|
||||
#if configUSE_PREEMPTION == 1
|
||||
{
|
||||
/*
|
||||
* Ask for a switch to the highest priority task
|
||||
* that is ready to run.
|
||||
*/
|
||||
uxSwitchRequested = pdTRUE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#pragma wizcpp uselib "$__PATHNAME__/Tick.c"
|
||||
|
||||
#endif /* _FREERTOS_DRIVERS_TICK_ISRTICK_C */
|
225
FreeRTOS/Source/portable/WizC/PIC18/Install.bat
Normal file
225
FreeRTOS/Source/portable/WizC/PIC18/Install.bat
Normal file
|
@ -0,0 +1,225 @@
|
|||
REM/*
|
||||
REM FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.
|
||||
REM
|
||||
REM
|
||||
REM ***************************************************************************
|
||||
REM * *
|
||||
REM * FreeRTOS tutorial books are available in pdf and paperback. *
|
||||
REM * Complete, revised, and edited pdf reference manuals are also *
|
||||
REM * available. *
|
||||
REM * *
|
||||
REM * Purchasing FreeRTOS documentation will not only help you, by *
|
||||
REM * ensuring you get running as quickly as possible and with an *
|
||||
REM * in-depth knowledge of how to use FreeRTOS, it will also help *
|
||||
REM * the FreeRTOS project to continue with its mission of providing *
|
||||
REM * professional grade, cross platform, de facto standard solutions *
|
||||
REM * for microcontrollers - completely free of charge! *
|
||||
REM * *
|
||||
REM * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
|
||||
REM * *
|
||||
REM * Thank you for using FreeRTOS, and thank you for your support! *
|
||||
REM * *
|
||||
REM ***************************************************************************
|
||||
REM
|
||||
REM
|
||||
REM This file is part of the FreeRTOS distribution.
|
||||
REM
|
||||
REM FreeRTOS is free softwareREM you can redistribute it and/or modify it under
|
||||
REM the terms of the GNU General Public License (version 2) as published by the
|
||||
REM Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||
REM >>>NOTE<<< The modification to the GPL is included to allow you to
|
||||
REM distribute a combined work that includes FreeRTOS without being obliged to
|
||||
REM provide the source code for proprietary components outside of the FreeRTOS
|
||||
REM kernel. FreeRTOS is distributed in the hope that it will be useful, but
|
||||
REM WITHOUT ANY WARRANTYREM without even the implied warranty of MERCHANTABILITY
|
||||
REM or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
REM more details. You should have received a copy of the GNU General Public
|
||||
REM License and the FreeRTOS license exception along with FreeRTOSREM if not it
|
||||
REM can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
||||
REM by writing to Richard Barry, contact details for whom are available on the
|
||||
REM FreeRTOS WEB site.
|
||||
REM
|
||||
REM 1 tab == 4 spaces!
|
||||
REM
|
||||
REM http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
REM contact details.
|
||||
REM
|
||||
REM http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||
REM critical systems.
|
||||
REM
|
||||
REM http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
REM licensing and training services.
|
||||
REM*/
|
||||
|
||||
|
||||
@echo off
|
||||
cls
|
||||
|
||||
SET PACKAGENAME=the FreeRTOS port for fedC and wizC
|
||||
|
||||
echo.
|
||||
echo Hello, I'm the installationscript for %PACKAGENAME%.
|
||||
echo.
|
||||
|
||||
:CHECKFEDC
|
||||
set FED=C:\Program Files\FED\PIC_C
|
||||
echo.
|
||||
echo I'm checking your system for fedC
|
||||
if not exist "%FED%" goto NOFEDC
|
||||
echo YES, I found a fedC-installation!
|
||||
goto FOUNDFED
|
||||
:NOFEDC
|
||||
echo I could not find a fedC-installation.
|
||||
|
||||
|
||||
:CHECKWIZC
|
||||
set FED=C:\Program Files\FED\PIXIE
|
||||
echo.
|
||||
echo I'm checking your system for wizC
|
||||
if not exist "%FED%" goto NOWIZC
|
||||
echo YES, I found a wizC-installation!
|
||||
goto FOUNDFED
|
||||
:noWIZC
|
||||
echo I could not find a wizC-installation.
|
||||
|
||||
|
||||
:ERROR
|
||||
echo.
|
||||
echo.
|
||||
echo I could not find a FED C-compiler installation on your system.
|
||||
echo.
|
||||
echo Perhaps I got confused because you installed fedC or wizC in a non-default directory.
|
||||
echo If this is the case, please change the path at the top of this install-script.
|
||||
echo After that rerun the script and I will be happy to try again.
|
||||
echo.
|
||||
goto ENDIT
|
||||
|
||||
|
||||
:FOUNDFED
|
||||
echo.
|
||||
echo.
|
||||
|
||||
set FEDLIBS=%FED%\Libs
|
||||
set FEDLIBSUSER=%FEDLIBS%\LibsUser
|
||||
|
||||
if exist "%FEDLIBS%" goto INSTALL
|
||||
echo The FED installationdirectory "%FED%"
|
||||
echo contains no Libs subdirectory. This is weird!
|
||||
echo.
|
||||
echo Installation is aborted, sorry...
|
||||
goto ENDIT
|
||||
|
||||
|
||||
:INSTALL
|
||||
echo I am about to install %PACKAGENAME%
|
||||
echo into directory %FEDLIBSUSER%
|
||||
echo.
|
||||
echo Press 'enter' to let me do my thing
|
||||
echo Press 'ctrl-c' to stop me
|
||||
pause >nul
|
||||
echo.
|
||||
echo Installing...
|
||||
|
||||
|
||||
:RESET_READONLY
|
||||
echo.
|
||||
echo Removing ReadOnly attributes
|
||||
attrib -R "%FEDLIBSUSER%\libFreeRTOS\Modules\Croutine.c" >nul
|
||||
attrib -R "%FEDLIBSUSER%\libFreeRTOS\Modules\Port.c" >nul
|
||||
attrib -R "%FEDLIBSUSER%\libFreeRTOS\Modules\List.c" >nul
|
||||
attrib -R "%FEDLIBSUSER%\libFreeRTOS\Modules\Queue.c" >nul
|
||||
attrib -R "%FEDLIBSUSER%\libFreeRTOS\Modules\Tasks.c" >nul
|
||||
attrib -R "%FEDLIBSUSER%\libFreeRTOS\Drivers\Tick\Tick.c" >nul
|
||||
attrib -R "%FEDLIBSUSER%\libFreeRTOS\Drivers\Tick\isrTick.c" >nul
|
||||
attrib -R "%FEDLIBSUSER%\libFreeRTOS\Include\Portmacro.h" >nul
|
||||
attrib -R "%FEDLIBSUSER%\libFreeRTOS\Include\Croutine.h" >nul
|
||||
attrib -R "%FEDLIBSUSER%\libFreeRTOS\Include\List.h" >nul
|
||||
attrib -R "%FEDLIBSUSER%\libFreeRTOS\Include\Portable.h" >nul
|
||||
attrib -R "%FEDLIBSUSER%\libFreeRTOS\Include\Projdefs.h" >nul
|
||||
attrib -R "%FEDLIBSUSER%\libFreeRTOS\Include\Queue.h" >nul
|
||||
attrib -R "%FEDLIBSUSER%\libFreeRTOS\Include\Semphr.h" >nul
|
||||
attrib -R "%FEDLIBSUSER%\libFreeRTOS\Include\Task.h" >nul
|
||||
attrib -R "%FEDLIBSUSER%\FreeRTOS.h" >nul
|
||||
echo Done
|
||||
|
||||
:CREATE_DIRECTORIES
|
||||
echo.
|
||||
echo Creating directories (if necessary)...
|
||||
if not exist "%FEDLIBSUSER%" mkdir "%FEDLIBSUSER%"
|
||||
if not exist "%FEDLIBSUSER%\libFreeRTOS" mkdir "%FEDLIBSUSER%\libFreeRTOS"
|
||||
if not exist "%FEDLIBSUSER%\libFreeRTOS\Drivers" mkdir "%FEDLIBSUSER%\libFreeRTOS\Drivers"
|
||||
if not exist "%FEDLIBSUSER%\libFreeRTOS\Drivers\Tick" mkdir "%FEDLIBSUSER%\libFreeRTOS\Drivers\Tick"
|
||||
if not exist "%FEDLIBSUSER%\libFreeRTOS\Include" mkdir "%FEDLIBSUSER%\libFreeRTOS\Include"
|
||||
if not exist "%FEDLIBSUSER%\libFreeRTOS\Modules" mkdir "%FEDLIBSUSER%\libFreeRTOS\Modules"
|
||||
echo Done
|
||||
|
||||
|
||||
echo.
|
||||
echo Copying Files...
|
||||
:COPY_MODULES
|
||||
echo Modules...
|
||||
copy /V /Y "Port.c" "%FEDLIBSUSER%\libFreeRTOS\Modules\Port.c" >nul
|
||||
copy /V /Y "..\..\..\Croutine.c" "%FEDLIBSUSER%\libFreeRTOS\Modules\Croutine.c" >nul
|
||||
copy /V /Y "..\..\..\List.c" "%FEDLIBSUSER%\libFreeRTOS\Modules\List.c" >nul
|
||||
copy /V /Y "..\..\..\Queue.c" "%FEDLIBSUSER%\libFreeRTOS\Modules\Queue.c" >nul
|
||||
copy /V /Y "..\..\..\Tasks.c" "%FEDLIBSUSER%\libFreeRTOS\Modules\Tasks.c" >nul
|
||||
|
||||
:COPY_DRIVERS
|
||||
echo Drivers...
|
||||
copy /V /Y "Drivers\Tick\Tick.c" "%FEDLIBSUSER%\libFreeRTOS\Drivers\Tick\Tick.c" >nul
|
||||
copy /V /Y "Drivers\Tick\isrTick.c" "%FEDLIBSUSER%\libFreeRTOS\Drivers\Tick\isrTick.c" >nul
|
||||
|
||||
:COPY_HEADERS
|
||||
echo Headers...
|
||||
copy /V /Y "portmacro.h" "%FEDLIBSUSER%\libFreeRTOS\Include\Portmacro.h" >nul
|
||||
copy /V /Y "..\..\..\include\Croutine.h" "%FEDLIBSUSER%\libFreeRTOS\Include\Croutine.h" >nul
|
||||
copy /V /Y "..\..\..\include\List.h" "%FEDLIBSUSER%\libFreeRTOS\Include\List.h" >nul
|
||||
copy /V /Y "..\..\..\include\Portable.h" "%FEDLIBSUSER%\libFreeRTOS\Include\Portable.h" >nul
|
||||
copy /V /Y "..\..\..\include\Projdefs.h" "%FEDLIBSUSER%\libFreeRTOS\Include\Projdefs.h" >nul
|
||||
copy /V /Y "..\..\..\include\Queue.h" "%FEDLIBSUSER%\libFreeRTOS\Include\Queue.h" >nul
|
||||
copy /V /Y "..\..\..\include\Semphr.h" "%FEDLIBSUSER%\libFreeRTOS\Include\Semphr.h" >nul
|
||||
copy /V /Y "..\..\..\include\Task.h" "%FEDLIBSUSER%\libFreeRTOS\Include\Task.h" >nul
|
||||
copy /V /Y "addFreeRTOS.h" + "..\..\..\include\FreeRTOS.h" "%FEDLIBSUSER%\FreeRTOS.h" >nul
|
||||
|
||||
|
||||
echo Done
|
||||
|
||||
|
||||
:SET_READONLY
|
||||
echo.
|
||||
echo Setting files to ReadOnly
|
||||
attrib +R "%FEDLIBSUSER%\libFreeRTOS\Modules\Port.c" >nul
|
||||
attrib +R "%FEDLIBSUSER%\libFreeRTOS\Modules\Croutine.c" >nul
|
||||
attrib +R "%FEDLIBSUSER%\libFreeRTOS\Modules\List.c" >nul
|
||||
attrib +R "%FEDLIBSUSER%\libFreeRTOS\Modules\Queue.c" >nul
|
||||
attrib +R "%FEDLIBSUSER%\libFreeRTOS\Modules\Tasks.c" >nul
|
||||
attrib +R "%FEDLIBSUSER%\libFreeRTOS\Drivers\Tick\Tick.c" >nul
|
||||
attrib +R "%FEDLIBSUSER%\libFreeRTOS\Drivers\Tick\isrTick.c" >nul
|
||||
attrib +R "%FEDLIBSUSER%\libFreeRTOS\Include\Portmacro.h" >nul
|
||||
attrib +R "%FEDLIBSUSER%\libFreeRTOS\Include\Croutine.h" >nul
|
||||
attrib +R "%FEDLIBSUSER%\libFreeRTOS\Include\List.h" >nul
|
||||
attrib +R "%FEDLIBSUSER%\libFreeRTOS\Include\Portable.h" >nul
|
||||
attrib +R "%FEDLIBSUSER%\libFreeRTOS\Include\Projdefs.h" >nul
|
||||
attrib +R "%FEDLIBSUSER%\libFreeRTOS\Include\Queue.h" >nul
|
||||
attrib +R "%FEDLIBSUSER%\libFreeRTOS\Include\Semphr.h" >nul
|
||||
attrib +R "%FEDLIBSUSER%\libFreeRTOS\Include\Task.h" >nul
|
||||
attrib +R "%FEDLIBSUSER%\FreeRTOS.h" >nul
|
||||
echo Done
|
||||
|
||||
|
||||
:FINISHED
|
||||
echo.
|
||||
echo The installation of %PACKAGENAME% is completed.
|
||||
echo.
|
||||
echo Please review the installation instructions as additional libraries
|
||||
echo and fedC/wizC configuration settings may be needed for FreeRTOS
|
||||
echo to function correctly.
|
||||
|
||||
goto ENDIT
|
||||
|
||||
|
||||
:ENDIT
|
||||
echo.
|
||||
echo.
|
||||
echo Press 'enter' to close this window
|
||||
pause >nul
|
92
FreeRTOS/Source/portable/WizC/PIC18/addFreeRTOS.h
Normal file
92
FreeRTOS/Source/portable/WizC/PIC18/addFreeRTOS.h
Normal file
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS tutorial books are available in pdf and paperback. *
|
||||
* Complete, revised, and edited pdf reference manuals are also *
|
||||
* available. *
|
||||
* *
|
||||
* Purchasing FreeRTOS documentation will not only help you, by *
|
||||
* ensuring you get running as quickly as possible and with an *
|
||||
* in-depth knowledge of how to use FreeRTOS, it will also help *
|
||||
* the FreeRTOS project to continue with its mission of providing *
|
||||
* professional grade, cross platform, de facto standard solutions *
|
||||
* for microcontrollers - completely free of charge! *
|
||||
* *
|
||||
* >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
|
||||
* *
|
||||
* Thank you for using FreeRTOS, and thank you for your support! *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||
>>>NOTE<<< The modification to the GPL is included to allow you to
|
||||
distribute a combined work that includes FreeRTOS without being obliged to
|
||||
provide the source code for proprietary components outside of the FreeRTOS
|
||||
kernel. FreeRTOS is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details. You should have received a copy of the GNU General Public
|
||||
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
||||
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
||||
by writing to Richard Barry, contact details for whom are available on the
|
||||
FreeRTOS WEB site.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Having a problem? Start by reading the FAQ "My application does *
|
||||
* not run, what could be wrong? *
|
||||
* *
|
||||
* http://www.FreeRTOS.org/FAQHelp.html *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, training, latest information,
|
||||
license and contact details.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool.
|
||||
|
||||
Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
|
||||
the code with commercial support, indemnification, and middleware, under
|
||||
the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
|
||||
provide a safety engineered and independently SIL3 certified version under
|
||||
the SafeRTOS brand: http://www.SafeRTOS.com.
|
||||
*/
|
||||
|
||||
/*
|
||||
Changes from V3.0.0
|
||||
|
||||
Changes from V3.0.1
|
||||
|
||||
Changes from V4.0.1
|
||||
Uselib pragma added for Croutine.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* The installation script will automatically prepend this file to the default FreeRTOS.h.
|
||||
*/
|
||||
|
||||
#ifndef WIZC_FREERTOS_H
|
||||
#define WIZC_FREERTOS_H
|
||||
|
||||
#pragma noheap
|
||||
#pragma wizcpp expandnl on
|
||||
#pragma wizcpp searchpath "$__PATHNAME__/libFreeRTOS/Include/"
|
||||
#pragma wizcpp uselib "$__PATHNAME__/libFreeRTOS/Modules/Croutine.c"
|
||||
#pragma wizcpp uselib "$__PATHNAME__/libFreeRTOS/Modules/Tasks.c"
|
||||
#pragma wizcpp uselib "$__PATHNAME__/libFreeRTOS/Modules/Queue.c"
|
||||
#pragma wizcpp uselib "$__PATHNAME__/libFreeRTOS/Modules/List.c"
|
||||
#pragma wizcpp uselib "$__PATHNAME__/libFreeRTOS/Modules/Port.c"
|
||||
|
||||
#endif /* WIZC_FREERTOS_H */
|
347
FreeRTOS/Source/portable/WizC/PIC18/port.c
Normal file
347
FreeRTOS/Source/portable/WizC/PIC18/port.c
Normal file
|
@ -0,0 +1,347 @@
|
|||
/*
|
||||
FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS tutorial books are available in pdf and paperback. *
|
||||
* Complete, revised, and edited pdf reference manuals are also *
|
||||
* available. *
|
||||
* *
|
||||
* Purchasing FreeRTOS documentation will not only help you, by *
|
||||
* ensuring you get running as quickly as possible and with an *
|
||||
* in-depth knowledge of how to use FreeRTOS, it will also help *
|
||||
* the FreeRTOS project to continue with its mission of providing *
|
||||
* professional grade, cross platform, de facto standard solutions *
|
||||
* for microcontrollers - completely free of charge! *
|
||||
* *
|
||||
* >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
|
||||
* *
|
||||
* Thank you for using FreeRTOS, and thank you for your support! *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||
>>>NOTE<<< The modification to the GPL is included to allow you to
|
||||
distribute a combined work that includes FreeRTOS without being obliged to
|
||||
provide the source code for proprietary components outside of the FreeRTOS
|
||||
kernel. FreeRTOS is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details. You should have received a copy of the GNU General Public
|
||||
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
||||
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
||||
by writing to Richard Barry, contact details for whom are available on the
|
||||
FreeRTOS WEB site.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Having a problem? Start by reading the FAQ "My application does *
|
||||
* not run, what could be wrong? *
|
||||
* *
|
||||
* http://www.FreeRTOS.org/FAQHelp.html *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, training, latest information,
|
||||
license and contact details.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool.
|
||||
|
||||
Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
|
||||
the code with commercial support, indemnification, and middleware, under
|
||||
the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
|
||||
provide a safety engineered and independently SIL3 certified version under
|
||||
the SafeRTOS brand: http://www.SafeRTOS.com.
|
||||
*/
|
||||
|
||||
/*
|
||||
Changes from V3.2.1
|
||||
+ CallReturn Depth increased from 8 to 10 levels to accomodate wizC/fedC V12.
|
||||
|
||||
Changes from V3.2.0
|
||||
+ TBLPTRU is now initialised to zero during the initial stack creation of a new task. This solves
|
||||
an error on devices with more than 64kB ROM.
|
||||
|
||||
Changes from V3.0.0
|
||||
+ ucCriticalNesting is now initialised to 0x7F to prevent interrupts from being
|
||||
handled before the scheduler is started.
|
||||
|
||||
Changes from V3.0.1
|
||||
*/
|
||||
|
||||
/* Scheduler include files. */
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Implementation of functions defined in portable.h for the WizC PIC18 port.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* We require the address of the pxCurrentTCB variable, but don't want to
|
||||
* know any details of its type.
|
||||
*/
|
||||
typedef void tskTCB;
|
||||
extern volatile tskTCB * volatile pxCurrentTCB;
|
||||
|
||||
/*
|
||||
* Define minimal-stack constants
|
||||
* -----
|
||||
* FSR's:
|
||||
* STATUS, WREG, BSR, PRODH, PRODL, FSR0H, FSR0L,
|
||||
* FSR1H, FSR1L,TABLAT, (TBLPTRU), TBLPTRH, TBLPTRL,
|
||||
* (PCLATU), PCLATH
|
||||
* sfr's within parenthesis only on devices > 64kB
|
||||
* -----
|
||||
* Call/Return stack:
|
||||
* 2 bytes per entry on devices <= 64kB
|
||||
* 3 bytes per entry on devices > 64kB
|
||||
* -----
|
||||
* Other bytes:
|
||||
* 2 bytes: FunctionParameter for initial taskcode
|
||||
* 1 byte : Number of entries on call/return stack
|
||||
* 1 byte : ucCriticalNesting
|
||||
* 16 bytes: Free space on stack
|
||||
*/
|
||||
#if _ROMSIZE > 0x8000
|
||||
#define portSTACK_FSR_BYTES ( 15 )
|
||||
#define portSTACK_CALLRETURN_ENTRY_SIZE ( 3 )
|
||||
#else
|
||||
#define portSTACK_FSR_BYTES ( 13 )
|
||||
#define portSTACK_CALLRETURN_ENTRY_SIZE ( 2 )
|
||||
#endif
|
||||
|
||||
#define portSTACK_MINIMAL_CALLRETURN_DEPTH ( 10 )
|
||||
#define portSTACK_OTHER_BYTES ( 20 )
|
||||
|
||||
unsigned short usCalcMinStackSize = 0;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* We initialise ucCriticalNesting to the middle value an
|
||||
* unsigned char can contain. This way portENTER_CRITICAL()
|
||||
* and portEXIT_CRITICAL() can be called without interrupts
|
||||
* being enabled before the scheduler starts.
|
||||
*/
|
||||
register unsigned char ucCriticalNesting = 0x7F;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Initialise the stack of a new task.
|
||||
* See portSAVE_CONTEXT macro for description.
|
||||
*/
|
||||
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
|
||||
{
|
||||
unsigned char ucScratch;
|
||||
/*
|
||||
* Get the size of the RAMarea in page 0 used by the compiler
|
||||
* We do this here already to avoid W-register conflicts.
|
||||
*/
|
||||
_Pragma("asm")
|
||||
movlw OVERHEADPAGE0-LOCOPTSIZE+MAXLOCOPTSIZE
|
||||
movwf PRODL,ACCESS ; PRODL is used as temp register
|
||||
_Pragma("asmend")
|
||||
ucScratch = PRODL;
|
||||
|
||||
/*
|
||||
* Place a few bytes of known values on the bottom of the stack.
|
||||
* This is just useful for debugging.
|
||||
*/
|
||||
// *pxTopOfStack-- = 0x11;
|
||||
// *pxTopOfStack-- = 0x22;
|
||||
// *pxTopOfStack-- = 0x33;
|
||||
|
||||
/*
|
||||
* Simulate how the stack would look after a call to vPortYield()
|
||||
* generated by the compiler.
|
||||
*/
|
||||
|
||||
/*
|
||||
* First store the function parameters. This is where the task expects
|
||||
* to find them when it starts running.
|
||||
*/
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) ( (( unsigned short ) pvParameters >> 8) & 0x00ff );
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) ( ( unsigned short ) pvParameters & 0x00ff );
|
||||
|
||||
/*
|
||||
* Next are all the registers that form part of the task context.
|
||||
*/
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 0x11; /* STATUS. */
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 0x22; /* WREG. */
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 0x33; /* BSR. */
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 0x44; /* PRODH. */
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 0x55; /* PRODL. */
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 0x66; /* FSR0H. */
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 0x77; /* FSR0L. */
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 0x88; /* FSR1H. */
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 0x99; /* FSR1L. */
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 0xAA; /* TABLAT. */
|
||||
#if _ROMSIZE > 0x8000
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 0x00; /* TBLPTRU. */
|
||||
#endif
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 0xCC; /* TBLPTRH. */
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 0xDD; /* TBLPTRL. */
|
||||
#if _ROMSIZE > 0x8000
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 0xEE; /* PCLATU. */
|
||||
#endif
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 0xFF; /* PCLATH. */
|
||||
|
||||
/*
|
||||
* Next the compiler's scratchspace.
|
||||
*/
|
||||
while(ucScratch-- > 0)
|
||||
{
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* The only function return address so far is the address of the task entry.
|
||||
* The order is TOSU/TOSH/TOSL. For devices > 64kB, TOSU is put on the
|
||||
* stack, too. TOSU is always written as zero here because wizC does not allow
|
||||
* functionpointers to point above 64kB in ROM.
|
||||
*/
|
||||
#if _ROMSIZE > 0x8000
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 0;
|
||||
#endif
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) ( ( ( unsigned short ) pxCode >> 8 ) & 0x00ff );
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) ( ( unsigned short ) pxCode & 0x00ff );
|
||||
|
||||
/*
|
||||
* Store the number of return addresses on the hardware stack.
|
||||
* So far only the address of the task entry point.
|
||||
*/
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) 1;
|
||||
|
||||
/*
|
||||
* The code generated by wizC does not maintain separate
|
||||
* stack and frame pointers. Therefore the portENTER_CRITICAL macro cannot
|
||||
* use the stack as per other ports. Instead a variable is used to keep
|
||||
* track of the critical section nesting. This variable has to be stored
|
||||
* as part of the task context and is initially set to zero.
|
||||
*/
|
||||
*pxTopOfStack-- = ( portSTACK_TYPE ) portNO_CRITICAL_SECTION_NESTING;
|
||||
|
||||
return pxTopOfStack;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
unsigned short usPortCALCULATE_MINIMAL_STACK_SIZE( void )
|
||||
{
|
||||
/*
|
||||
* Fetch the size of compiler's scratchspace.
|
||||
*/
|
||||
_Pragma("asm")
|
||||
movlw OVERHEADPAGE0-LOCOPTSIZE+MAXLOCOPTSIZE
|
||||
movlb usCalcMinStackSize>>8
|
||||
movwf usCalcMinStackSize,BANKED
|
||||
_Pragma("asmend")
|
||||
|
||||
/*
|
||||
* Add minimum needed stackspace
|
||||
*/
|
||||
usCalcMinStackSize += ( portSTACK_FSR_BYTES )
|
||||
+ ( portSTACK_MINIMAL_CALLRETURN_DEPTH * portSTACK_CALLRETURN_ENTRY_SIZE )
|
||||
+ ( portSTACK_OTHER_BYTES );
|
||||
|
||||
return(usCalcMinStackSize);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
portBASE_TYPE xPortStartScheduler( void )
|
||||
{
|
||||
extern void portSetupTick( void );
|
||||
|
||||
/*
|
||||
* Setup a timer for the tick ISR for the preemptive scheduler.
|
||||
*/
|
||||
portSetupTick();
|
||||
|
||||
/*
|
||||
* Restore the context of the first task to run.
|
||||
*/
|
||||
portRESTORE_CONTEXT();
|
||||
|
||||
/*
|
||||
* This point should never be reached during execution.
|
||||
*/
|
||||
return pdTRUE;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vPortEndScheduler( void )
|
||||
{
|
||||
/*
|
||||
* It is unlikely that the scheduler for the PIC port will get stopped
|
||||
* once running. When called a reset is done which is probably the
|
||||
* most valid action.
|
||||
*/
|
||||
_Pragma(asmline reset);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Manual context switch. This is similar to the tick context switch,
|
||||
* but does not increment the tick count. It must be identical to the
|
||||
* tick context switch in how it stores the stack of a task.
|
||||
*/
|
||||
void vPortYield( void )
|
||||
{
|
||||
/*
|
||||
* Save the context of the current task.
|
||||
*/
|
||||
portSAVE_CONTEXT( portINTERRUPTS_UNCHANGED );
|
||||
|
||||
/*
|
||||
* Switch to the highest priority task that is ready to run.
|
||||
*/
|
||||
vTaskSwitchContext();
|
||||
|
||||
/*
|
||||
* Start executing the task we have just switched to.
|
||||
*/
|
||||
portRESTORE_CONTEXT();
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void *pvPortMalloc( unsigned short usWantedSize )
|
||||
{
|
||||
void *pvReturn;
|
||||
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
pvReturn = malloc( ( malloc_t ) usWantedSize );
|
||||
}
|
||||
xTaskResumeAll();
|
||||
|
||||
return pvReturn;
|
||||
}
|
||||
|
||||
void vPortFree( void *pv )
|
||||
{
|
||||
if( pv )
|
||||
{
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
free( pv );
|
||||
}
|
||||
xTaskResumeAll();
|
||||
}
|
||||
}
|
457
FreeRTOS/Source/portable/WizC/PIC18/portmacro.h
Normal file
457
FreeRTOS/Source/portable/WizC/PIC18/portmacro.h
Normal file
|
@ -0,0 +1,457 @@
|
|||
/*
|
||||
FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS tutorial books are available in pdf and paperback. *
|
||||
* Complete, revised, and edited pdf reference manuals are also *
|
||||
* available. *
|
||||
* *
|
||||
* Purchasing FreeRTOS documentation will not only help you, by *
|
||||
* ensuring you get running as quickly as possible and with an *
|
||||
* in-depth knowledge of how to use FreeRTOS, it will also help *
|
||||
* the FreeRTOS project to continue with its mission of providing *
|
||||
* professional grade, cross platform, de facto standard solutions *
|
||||
* for microcontrollers - completely free of charge! *
|
||||
* *
|
||||
* >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
|
||||
* *
|
||||
* Thank you for using FreeRTOS, and thank you for your support! *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
||||
>>>NOTE<<< The modification to the GPL is included to allow you to
|
||||
distribute a combined work that includes FreeRTOS without being obliged to
|
||||
provide the source code for proprietary components outside of the FreeRTOS
|
||||
kernel. FreeRTOS is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details. You should have received a copy of the GNU General Public
|
||||
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
||||
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
||||
by writing to Richard Barry, contact details for whom are available on the
|
||||
FreeRTOS WEB site.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Having a problem? Start by reading the FAQ "My application does *
|
||||
* not run, what could be wrong? *
|
||||
* *
|
||||
* http://www.FreeRTOS.org/FAQHelp.html *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, training, latest information,
|
||||
license and contact details.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool.
|
||||
|
||||
Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
|
||||
the code with commercial support, indemnification, and middleware, under
|
||||
the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
|
||||
provide a safety engineered and independently SIL3 certified version under
|
||||
the SafeRTOS brand: http://www.SafeRTOS.com.
|
||||
*/
|
||||
|
||||
/*
|
||||
Changes from V3.0.0
|
||||
|
||||
Changes from V3.0.1
|
||||
*/
|
||||
#ifndef PORTMACRO_H
|
||||
#define PORTMACRO_H
|
||||
|
||||
#if !defined(_SERIES) || _SERIES != 18
|
||||
#error "WizC supports FreeRTOS on the Microchip PIC18-series only"
|
||||
#endif
|
||||
|
||||
#if !defined(QUICKCALL) || QUICKCALL != 1
|
||||
#error "QuickCall must be enabled (see ProjectOptions/Optimisations)"
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <pic.h>
|
||||
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE portFLOAT
|
||||
#define portLONG long
|
||||
#define portSHORT short
|
||||
#define portSTACK_TYPE unsigned char
|
||||
#define portBASE_TYPE char
|
||||
|
||||
#if( configUSE_16_BIT_TICKS == 1 )
|
||||
typedef unsigned portSHORT portTickType;
|
||||
#define portMAX_DELAY ( portTickType ) ( 0xFFFF )
|
||||
#else
|
||||
typedef unsigned portLONG portTickType;
|
||||
#define portMAX_DELAY ( portTickType ) ( 0xFFFFFFFF )
|
||||
#endif
|
||||
|
||||
#define portBYTE_ALIGNMENT 1
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Constant used for context switch macro when we require the interrupt
|
||||
* enable state to be forced when the interrupted task is switched back in.
|
||||
*/
|
||||
#define portINTERRUPTS_FORCED (0x01)
|
||||
|
||||
/*
|
||||
* Constant used for context switch macro when we require the interrupt
|
||||
* enable state to be unchanged when the interrupted task is switched back in.
|
||||
*/
|
||||
#define portINTERRUPTS_UNCHANGED (0x00)
|
||||
|
||||
/* Initial interrupt enable state for newly created tasks. This value is
|
||||
* used when a task switches in for the first time.
|
||||
*/
|
||||
#define portINTERRUPTS_INITIAL_STATE (portINTERRUPTS_FORCED)
|
||||
|
||||
/*
|
||||
* Macros to modify the global interrupt enable bit in INTCON.
|
||||
*/
|
||||
#define portDISABLE_INTERRUPTS() \
|
||||
do \
|
||||
{ \
|
||||
bGIE=0; \
|
||||
} while(bGIE) // MicroChip recommends this check!
|
||||
|
||||
#define portENABLE_INTERRUPTS() \
|
||||
do \
|
||||
{ \
|
||||
bGIE=1; \
|
||||
} while(0)
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Critical section macros.
|
||||
*/
|
||||
extern unsigned portCHAR ucCriticalNesting;
|
||||
|
||||
#define portNO_CRITICAL_SECTION_NESTING ( ( unsigned portCHAR ) 0 )
|
||||
|
||||
#define portENTER_CRITICAL() \
|
||||
do \
|
||||
{ \
|
||||
portDISABLE_INTERRUPTS(); \
|
||||
\
|
||||
/* \
|
||||
* Now interrupts are disabled ucCriticalNesting \
|
||||
* can be accessed directly. Increment \
|
||||
* ucCriticalNesting to keep a count of how \
|
||||
* many times portENTER_CRITICAL() has been called. \
|
||||
*/ \
|
||||
ucCriticalNesting++; \
|
||||
} while(0)
|
||||
|
||||
#define portEXIT_CRITICAL() \
|
||||
do \
|
||||
{ \
|
||||
if(ucCriticalNesting > portNO_CRITICAL_SECTION_NESTING) \
|
||||
{ \
|
||||
/* \
|
||||
* Decrement the nesting count as we are leaving a \
|
||||
* critical section. \
|
||||
*/ \
|
||||
ucCriticalNesting--; \
|
||||
} \
|
||||
\
|
||||
/* \
|
||||
* If the nesting level has reached zero then \
|
||||
* interrupts should be re-enabled. \
|
||||
*/ \
|
||||
if( ucCriticalNesting == portNO_CRITICAL_SECTION_NESTING ) \
|
||||
{ \
|
||||
portENABLE_INTERRUPTS(); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* The minimal stacksize is calculated on the first reference of
|
||||
* portMINIMAL_STACK_SIZE. Some input to this calculation is
|
||||
* compiletime determined, other input is port-defined (see port.c)
|
||||
*/
|
||||
extern unsigned portSHORT usPortCALCULATE_MINIMAL_STACK_SIZE( void );
|
||||
extern unsigned portSHORT usCalcMinStackSize;
|
||||
|
||||
#define portMINIMAL_STACK_SIZE \
|
||||
((usCalcMinStackSize == 0) \
|
||||
? usPortCALCULATE_MINIMAL_STACK_SIZE() \
|
||||
: usCalcMinStackSize )
|
||||
|
||||
/*
|
||||
* WizC uses a downgrowing stack
|
||||
*/
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Macro's that pushes all the registers that make up the context of a task onto
|
||||
* the stack, then saves the new top of stack into the TCB. TOSU and TBLPTRU
|
||||
* are only saved/restored on devices with more than 64kB (32k Words) ROM.
|
||||
*
|
||||
* The stackpointer is helt by WizC in FSR2 and points to the first free byte.
|
||||
* WizC uses a "downgrowing" stack. There is no framepointer.
|
||||
*
|
||||
* We keep track of the interruptstatus using ucCriticalNesting. When this
|
||||
* value equals zero, interrupts have to be enabled upon exit from the
|
||||
* portRESTORE_CONTEXT macro.
|
||||
*
|
||||
* If this is called from an ISR then the interrupt enable bits must have been
|
||||
* set for the ISR to ever get called. Therefore we want to save
|
||||
* ucCriticalNesting with value zero. This means the interrupts will again be
|
||||
* re-enabled when the interrupted task is switched back in.
|
||||
*
|
||||
* If this is called from a manual context switch (i.e. from a call to yield),
|
||||
* then we want to keep the current value of ucCritialNesting so it is restored
|
||||
* with its current value. This allows a yield from within a critical section.
|
||||
*
|
||||
* The compiler uses some locations at the bottom of RAM for temporary
|
||||
* storage. The compiler may also have been instructed to optimize
|
||||
* function-parameters and local variables to global storage. The compiler
|
||||
* uses an area called LocOpt for this wizC feature.
|
||||
* The total overheadstorage has to be saved in it's entirety as part of
|
||||
* a task context. These macro's store/restore from data address 0x0000 to
|
||||
* (OVERHEADPAGE0-LOCOPTSIZE+MAXLOCOPTSIZE - 1).
|
||||
* OVERHEADPAGE0, LOCOPTSIZE and MAXLOCOPTSIZE are compiler-generated
|
||||
* assembler definitions.
|
||||
*/
|
||||
|
||||
#define portSAVE_CONTEXT( ucInterruptForced ) \
|
||||
do \
|
||||
{ \
|
||||
portDISABLE_INTERRUPTS(); \
|
||||
\
|
||||
_Pragma("asm") \
|
||||
; \
|
||||
; Push the relevant SFR's onto the task's stack \
|
||||
; \
|
||||
movff STATUS,POSTDEC2 \
|
||||
movff WREG,POSTDEC2 \
|
||||
movff BSR,POSTDEC2 \
|
||||
movff PRODH,POSTDEC2 \
|
||||
movff PRODL,POSTDEC2 \
|
||||
movff FSR0H,POSTDEC2 \
|
||||
movff FSR0L,POSTDEC2 \
|
||||
movff FSR1H,POSTDEC2 \
|
||||
movff FSR1L,POSTDEC2 \
|
||||
movff TABLAT,POSTDEC2 \
|
||||
if __ROMSIZE > 0x8000 \
|
||||
movff TBLPTRU,POSTDEC2 \
|
||||
endif \
|
||||
movff TBLPTRH,POSTDEC2 \
|
||||
movff TBLPTRL,POSTDEC2 \
|
||||
if __ROMSIZE > 0x8000 \
|
||||
movff PCLATU,POSTDEC2 \
|
||||
endif \
|
||||
movff PCLATH,POSTDEC2 \
|
||||
; \
|
||||
; Store the compiler-scratch-area as described above. \
|
||||
; \
|
||||
movlw OVERHEADPAGE0-LOCOPTSIZE+MAXLOCOPTSIZE \
|
||||
clrf FSR0L,ACCESS \
|
||||
clrf FSR0H,ACCESS \
|
||||
_rtos_S1: \
|
||||
movff POSTINC0,POSTDEC2 \
|
||||
decfsz WREG,W,ACCESS \
|
||||
SMARTJUMP _rtos_S1 \
|
||||
; \
|
||||
; Save the pic call/return-stack belonging to the \
|
||||
; current task by copying it to the task's software- \
|
||||
; stack. We save the hardware stack pointer (which \
|
||||
; is the number of addresses on the stack) in the \
|
||||
; W-register first because we need it later and it \
|
||||
; is modified in the save-loop by executing pop's. \
|
||||
; After the loop the W-register is stored on the \
|
||||
; stack, too. \
|
||||
; \
|
||||
movf STKPTR,W,ACCESS \
|
||||
bz _rtos_s3 \
|
||||
_rtos_S2: \
|
||||
if __ROMSIZE > 0x8000 \
|
||||
movff TOSU,POSTDEC2 \
|
||||
endif \
|
||||
movff TOSH,POSTDEC2 \
|
||||
movff TOSL,POSTDEC2 \
|
||||
pop \
|
||||
tstfsz STKPTR,ACCESS \
|
||||
SMARTJUMP _rtos_S2 \
|
||||
_rtos_s3: \
|
||||
movwf POSTDEC2,ACCESS \
|
||||
; \
|
||||
; Next the value for ucCriticalNesting used by the \
|
||||
; task is stored on the stack. When \
|
||||
; (ucInterruptForced == portINTERRUPTS_FORCED), we save \
|
||||
; it as 0 (portNO_CRITICAL_SECTION_NESTING). \
|
||||
; \
|
||||
if ucInterruptForced == portINTERRUPTS_FORCED \
|
||||
clrf POSTDEC2,ACCESS \
|
||||
else \
|
||||
movff ucCriticalNesting,POSTDEC2 \
|
||||
endif \
|
||||
; \
|
||||
; Save the new top of the software stack in the TCB. \
|
||||
; \
|
||||
movff pxCurrentTCB,FSR0L \
|
||||
movff pxCurrentTCB+1,FSR0H \
|
||||
movff FSR2L,POSTINC0 \
|
||||
movff FSR2H,POSTINC0 \
|
||||
_Pragma("asmend") \
|
||||
} while(0)
|
||||
|
||||
/************************************************************/
|
||||
|
||||
/*
|
||||
* This is the reverse of portSAVE_CONTEXT.
|
||||
*/
|
||||
#define portRESTORE_CONTEXT() \
|
||||
do \
|
||||
{ \
|
||||
_Pragma("asm") \
|
||||
; \
|
||||
; Set FSR0 to point to pxCurrentTCB->pxTopOfStack. \
|
||||
; \
|
||||
movff pxCurrentTCB,FSR0L \
|
||||
movff pxCurrentTCB+1,FSR0H \
|
||||
; \
|
||||
; De-reference FSR0 to set the address it holds into \
|
||||
; FSR2 (i.e. *( pxCurrentTCB->pxTopOfStack ) ). FSR2 \
|
||||
; is used by wizC as stackpointer. \
|
||||
; \
|
||||
movff POSTINC0,FSR2L \
|
||||
movff POSTINC0,FSR2H \
|
||||
; \
|
||||
; Next, the value for ucCriticalNesting used by the \
|
||||
; task is retrieved from the stack. \
|
||||
; \
|
||||
movff PREINC2,ucCriticalNesting \
|
||||
; \
|
||||
; Rebuild the pic call/return-stack. The number of \
|
||||
; return addresses is the next item on the task stack. \
|
||||
; Save this number in PRODL. Then fetch the addresses \
|
||||
; and store them on the hardwarestack. \
|
||||
; The datasheets say we can't use movff here... \
|
||||
; \
|
||||
movff PREINC2,PRODL // Use PRODL as tempregister \
|
||||
clrf STKPTR,ACCESS \
|
||||
_rtos_R1: \
|
||||
push \
|
||||
movf PREINC2,W,ACCESS \
|
||||
movwf TOSL,ACCESS \
|
||||
movf PREINC2,W,ACCESS \
|
||||
movwf TOSH,ACCESS \
|
||||
if __ROMSIZE > 0x8000 \
|
||||
movf PREINC2,W,ACCESS \
|
||||
movwf TOSU,ACCESS \
|
||||
else \
|
||||
clrf TOSU,ACCESS \
|
||||
endif \
|
||||
decfsz PRODL,F,ACCESS \
|
||||
SMARTJUMP _rtos_R1 \
|
||||
; \
|
||||
; Restore the compiler's working storage area to page 0 \
|
||||
; \
|
||||
movlw OVERHEADPAGE0-LOCOPTSIZE+MAXLOCOPTSIZE \
|
||||
movwf FSR0L,ACCESS \
|
||||
clrf FSR0H,ACCESS \
|
||||
_rtos_R2: \
|
||||
decf FSR0L,F,ACCESS \
|
||||
movff PREINC2,INDF0 \
|
||||
tstfsz FSR0L,ACCESS \
|
||||
SMARTJUMP _rtos_R2 \
|
||||
; \
|
||||
; Restore the sfr's forming the tasks context. \
|
||||
; We cannot yet restore bsr, w and status because \
|
||||
; we need these registers for a final test. \
|
||||
; \
|
||||
movff PREINC2,PCLATH \
|
||||
if __ROMSIZE > 0x8000 \
|
||||
movff PREINC2,PCLATU \
|
||||
else \
|
||||
clrf PCLATU,ACCESS \
|
||||
endif \
|
||||
movff PREINC2,TBLPTRL \
|
||||
movff PREINC2,TBLPTRH \
|
||||
if __ROMSIZE > 0x8000 \
|
||||
movff PREINC2,TBLPTRU \
|
||||
else \
|
||||
clrf TBLPTRU,ACCESS \
|
||||
endif \
|
||||
movff PREINC2,TABLAT \
|
||||
movff PREINC2,FSR1L \
|
||||
movff PREINC2,FSR1H \
|
||||
movff PREINC2,FSR0L \
|
||||
movff PREINC2,FSR0H \
|
||||
movff PREINC2,PRODL \
|
||||
movff PREINC2,PRODH \
|
||||
; \
|
||||
; The return from portRESTORE_CONTEXT() depends on \
|
||||
; the value of ucCriticalNesting. When it is zero, \
|
||||
; interrupts need to be enabled. This is done via a \
|
||||
; retfie instruction because we need the \
|
||||
; interrupt-enabling and the return to the restored \
|
||||
; task to be uninterruptable. \
|
||||
; Because bsr, status and W are affected by the test \
|
||||
; they are restored after the test. \
|
||||
; \
|
||||
movlb ucCriticalNesting>>8 \
|
||||
tstfsz ucCriticalNesting,BANKED \
|
||||
SMARTJUMP _rtos_R4 \
|
||||
_rtos_R3: \
|
||||
movff PREINC2,BSR \
|
||||
movff PREINC2,WREG \
|
||||
movff PREINC2,STATUS \
|
||||
retfie 0 ; Return enabling interrupts \
|
||||
_rtos_R4: \
|
||||
movff PREINC2,BSR \
|
||||
movff PREINC2,WREG \
|
||||
movff PREINC2,STATUS \
|
||||
return 0 ; Return without affecting interrupts \
|
||||
_Pragma("asmend") \
|
||||
} while(0)
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
extern void vPortYield( void );
|
||||
#define portYIELD() vPortYield()
|
||||
|
||||
#define portNOP() _Pragma("asm") \
|
||||
nop \
|
||||
_Pragma("asmend")
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#define portTASK_FUNCTION( xFunction, pvParameters ) \
|
||||
void pointed xFunction( void *pvParameters ) \
|
||||
_Pragma(asmfunc xFunction)
|
||||
|
||||
#define portTASK_FUNCTION_PROTO portTASK_FUNCTION
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
||||
#define volatile
|
||||
#define register
|
||||
|
||||
#endif /* PORTMACRO_H */
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue