mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-20 10:08:33 -04:00
made a copy
This commit is contained in:
parent
bb7dc7c37f
commit
e20f132f48
2632 changed files with 751681 additions and 0 deletions
24
20080212/Demo/PIC18_MPLAB/18f452.lkr
Normal file
24
20080212/Demo/PIC18_MPLAB/18f452.lkr
Normal file
|
@ -0,0 +1,24 @@
|
|||
// $Id: 18f452.lkr,v 1.4 2003/03/13 05:02:23 sealep Exp $
|
||||
// File: 18f452.lkr
|
||||
// Sample linker script for the PIC18F452 processor
|
||||
|
||||
LIBPATH .
|
||||
|
||||
FILES c018i.o
|
||||
FILES clib.lib
|
||||
FILES p18f452.lib
|
||||
|
||||
CODEPAGE NAME=vectors START=0x0 END=0x39 PROTECTED
|
||||
CODEPAGE NAME=page START=0x3A END=0x7FFF
|
||||
CODEPAGE NAME=idlocs START=0x200000 END=0x200007 PROTECTED
|
||||
CODEPAGE NAME=config START=0x300000 END=0x30000D PROTECTED
|
||||
CODEPAGE NAME=devid START=0x3FFFFE END=0x3FFFFF PROTECTED
|
||||
CODEPAGE NAME=eedata START=0xF00000 END=0xF000FF PROTECTED
|
||||
|
||||
ACCESSBANK NAME=accessram START=0x0 END=0x7F
|
||||
DATABANK NAME=BIG_BLOCK START=0x80 END=0x5FF
|
||||
ACCESSBANK NAME=accesssfr START=0xF80 END=0xFFF PROTECTED
|
||||
|
||||
SECTION NAME=CONFIG ROM=config
|
||||
|
||||
STACK SIZE=0x60 RAM=BIG_BLOCK
|
87
20080212/Demo/PIC18_MPLAB/FreeRTOSConfig.h
Normal file
87
20080212/Demo/PIC18_MPLAB/FreeRTOSConfig.h
Normal file
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org 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.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
|
||||
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 <p18cxxx.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 ) 20000000 )
|
||||
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 4 )
|
||||
#define configMINIMAL_STACK_SIZE ( 105 )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) 1024 )
|
||||
#define configMAX_TASK_NAME_LEN ( 4 )
|
||||
#define configUSE_TRACE_FACILITY 0
|
||||
#define configUSE_16_BIT_TICKS 1
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
|
||||
/* 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 0
|
||||
#define INCLUDE_uxTaskPriorityGet 0
|
||||
#define INCLUDE_vTaskDelete 1
|
||||
#define INCLUDE_vTaskCleanUpResources 0
|
||||
#define INCLUDE_vTaskSuspend 0
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
133
20080212/Demo/PIC18_MPLAB/ParTest/ParTest.c
Normal file
133
20080212/Demo/PIC18_MPLAB/ParTest/ParTest.c
Normal file
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org 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.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
|
||||
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.
|
||||
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
Changes from V2.0.0
|
||||
|
||||
+ Use scheduler suspends in place of critical sections.
|
||||
*/
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "partest.h"
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Simple parallel port IO routines for the FED 40pin demo board.
|
||||
* The four LED's are connected to D4 to D7.
|
||||
*-----------------------------------------------------------*/
|
||||
|
||||
#define partstBIT_AS_OUTPUT ( ( unsigned portSHORT ) 0 )
|
||||
#define partstSET_OUTPUT ( ( unsigned portSHORT ) 1 )
|
||||
#define partstCLEAR_OUTPUT ( ( unsigned portSHORT ) 0 )
|
||||
|
||||
#define partstENABLE_GENERAL_IO ( ( unsigned portCHAR ) 7 )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestInitialise( void )
|
||||
{
|
||||
/* Set the top four bits of port D to output. */
|
||||
TRISDbits.TRISD7 = partstBIT_AS_OUTPUT;
|
||||
TRISDbits.TRISD6 = partstBIT_AS_OUTPUT;
|
||||
TRISDbits.TRISD5 = partstBIT_AS_OUTPUT;
|
||||
TRISDbits.TRISD4 = partstBIT_AS_OUTPUT;
|
||||
|
||||
/* Start with all bits off. */
|
||||
PORTDbits.RD7 = partstCLEAR_OUTPUT;
|
||||
PORTDbits.RD6 = partstCLEAR_OUTPUT;
|
||||
PORTDbits.RD5 = partstCLEAR_OUTPUT;
|
||||
PORTDbits.RD4 = partstCLEAR_OUTPUT;
|
||||
|
||||
/* Enable the driver. */
|
||||
ADCON1 = partstENABLE_GENERAL_IO;
|
||||
TRISEbits.TRISE2 = partstBIT_AS_OUTPUT;
|
||||
PORTEbits.RE2 = partstSET_OUTPUT;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestSetLED( unsigned portBASE_TYPE uxLED, portBASE_TYPE xValue )
|
||||
{
|
||||
/* We are only using the top nibble, so LED 0 corresponds to bit 4. */
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
switch( uxLED )
|
||||
{
|
||||
case 3 : PORTDbits.RD7 = ( portSHORT ) xValue;
|
||||
break;
|
||||
case 2 : PORTDbits.RD6 = ( portSHORT ) xValue;
|
||||
break;
|
||||
case 1 : PORTDbits.RD5 = ( portSHORT ) xValue;
|
||||
break;
|
||||
case 0 : PORTDbits.RD4 = ( portSHORT ) xValue;
|
||||
break;
|
||||
default : /* There are only 4 LED's. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
xTaskResumeAll();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
|
||||
{
|
||||
/* We are only using the top nibble, so LED 0 corresponds to bit 4. */
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
switch( uxLED )
|
||||
{
|
||||
case 3 : PORTDbits.RD7 = !( PORTDbits.RD7 );
|
||||
break;
|
||||
case 2 : PORTDbits.RD6 = !( PORTDbits.RD6 );
|
||||
break;
|
||||
case 1 : PORTDbits.RD5 = !( PORTDbits.RD5 );
|
||||
break;
|
||||
case 0 : PORTDbits.RD4 = !( PORTDbits.RD4 );
|
||||
break;
|
||||
default : /* There are only 4 LED's. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
xTaskResumeAll();
|
||||
}
|
||||
|
||||
|
||||
|
196
20080212/Demo/PIC18_MPLAB/main1.c
Normal file
196
20080212/Demo/PIC18_MPLAB/main1.c
Normal file
|
@ -0,0 +1,196 @@
|
|||
/*
|
||||
FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org 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.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
|
||||
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.
|
||||
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Instead of the normal single demo application, the PIC18F demo is split
|
||||
* into several smaller programs of which this is the first. This enables the
|
||||
* demo's to be executed on the RAM limited 40 pin devices. The 64 and 80 pin
|
||||
* devices require a more costly development platform and are not so readily
|
||||
* available.
|
||||
*
|
||||
* The RTOSDemo1 project is configured for a PIC18F452 device. Main1.c starts 5
|
||||
* tasks (including the idle task).
|
||||
*
|
||||
* The first task runs at the idle priority. It repeatedly performs a 32bit
|
||||
* calculation and checks it's result against the expected value. This checks
|
||||
* that the temporary storage utilised by the compiler to hold intermediate
|
||||
* results does not get corrupted when the task gets switched in and out. See
|
||||
* demo/common/minimal/integer.c for more information.
|
||||
*
|
||||
* The second and third tasks pass an incrementing value between each other on
|
||||
* a message queue. See demo/common/minimal/PollQ.c for more information.
|
||||
*
|
||||
* Main1.c also creates a check task. This periodically checks that all the
|
||||
* other tasks are still running and have not experienced any unexpected
|
||||
* results. If all the other tasks are executing correctly an LED is flashed
|
||||
* once every mainCHECK_PERIOD milliseconds. If any of the tasks have not
|
||||
* executed, or report and error, the frequency of the LED flash will increase
|
||||
* to mainERROR_FLASH_RATE.
|
||||
*
|
||||
* On entry to main an 'X' is transmitted. Monitoring the serial port using a
|
||||
* dumb terminal allows for verification that the device is not continuously
|
||||
* being reset (no more than one 'X' should be transmitted).
|
||||
*
|
||||
* http://www.FreeRTOS.org contains important information on the use of the
|
||||
* PIC18F port.
|
||||
*/
|
||||
|
||||
/*
|
||||
Changes from V2.0.0
|
||||
|
||||
+ Delay periods are now specified using variables and constants of
|
||||
portTickType rather than unsigned portLONG.
|
||||
*/
|
||||
|
||||
/* Scheduler include files. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Demo app include files. */
|
||||
#include "pollq.h"
|
||||
#include "integer.h"
|
||||
#include "partest.h"
|
||||
#include "serial.h"
|
||||
|
||||
/* The period between executions of the check task before and after an error
|
||||
has been discovered. If an error has been discovered the check task runs
|
||||
more frequently - increasing the LED flash rate. */
|
||||
#define mainNO_ERROR_CHECK_PERIOD ( ( portTickType ) 1000 / portTICK_RATE_MS )
|
||||
#define mainERROR_CHECK_PERIOD ( ( portTickType ) 100 / portTICK_RATE_MS )
|
||||
|
||||
/* Priority definitions for some of the tasks. Other tasks just use the idle
|
||||
priority. */
|
||||
#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
||||
|
||||
/* The LED that is flashed by the check task. */
|
||||
#define mainCHECK_TASK_LED ( 0 )
|
||||
|
||||
/* Constants required for the communications. Only one character is ever
|
||||
transmitted. */
|
||||
#define mainCOMMS_QUEUE_LENGTH ( 5 )
|
||||
#define mainNO_BLOCK ( ( portTickType ) 0 )
|
||||
#define mainBAUD_RATE ( ( unsigned portLONG ) 9600 )
|
||||
|
||||
/*
|
||||
* The task function for the "Check" task.
|
||||
*/
|
||||
static void vErrorChecks( void *pvParameters );
|
||||
|
||||
/*
|
||||
* Checks the unique counts of other tasks to ensure they are still operational.
|
||||
* Returns pdTRUE if an error is detected, otherwise pdFALSE.
|
||||
*/
|
||||
static portBASE_TYPE prvCheckOtherTasksAreStillRunning( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Creates the tasks, then starts the scheduler. */
|
||||
void main( void )
|
||||
{
|
||||
/* Initialise the required hardware. */
|
||||
vParTestInitialise();
|
||||
vPortInitialiseBlocks();
|
||||
|
||||
/* Send a character so we have some visible feedback of a reset. */
|
||||
xSerialPortInitMinimal( mainBAUD_RATE, mainCOMMS_QUEUE_LENGTH );
|
||||
xSerialPutChar( NULL, 'X', mainNO_BLOCK );
|
||||
|
||||
/* Start the standard demo tasks found in the demo\common directory. */
|
||||
vStartIntegerMathTasks( tskIDLE_PRIORITY );
|
||||
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
|
||||
|
||||
/* Start the check task defined in this file. */
|
||||
xTaskCreate( vErrorChecks, ( const portCHAR * const ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
|
||||
|
||||
/* Start the scheduler. Will never return here. */
|
||||
vTaskStartScheduler();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void vErrorChecks( void *pvParameters )
|
||||
{
|
||||
portTickType xDelayTime = mainNO_ERROR_CHECK_PERIOD;
|
||||
portBASE_TYPE xErrorOccurred;
|
||||
|
||||
/* Cycle for ever, delaying then checking all the other tasks are still
|
||||
operating without error. */
|
||||
for( ;; )
|
||||
{
|
||||
/* Wait until it is time to check the other tasks. */
|
||||
vTaskDelay( xDelayTime );
|
||||
|
||||
/* Check all the other tasks are running, and running without ever
|
||||
having an error. */
|
||||
xErrorOccurred = prvCheckOtherTasksAreStillRunning();
|
||||
|
||||
/* If an error was detected increase the frequency of the LED flash. */
|
||||
if( xErrorOccurred == pdTRUE )
|
||||
{
|
||||
xDelayTime = mainERROR_CHECK_PERIOD;
|
||||
}
|
||||
|
||||
/* Flash the LED for visual feedback. */
|
||||
vParTestToggleLED( mainCHECK_TASK_LED );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static portBASE_TYPE prvCheckOtherTasksAreStillRunning( void )
|
||||
{
|
||||
portBASE_TYPE xErrorHasOccurred = pdFALSE;
|
||||
|
||||
if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
|
||||
{
|
||||
xErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
if( xArePollingQueuesStillRunning() != pdTRUE )
|
||||
{
|
||||
xErrorHasOccurred = pdTRUE;
|
||||
}
|
||||
|
||||
return xErrorHasOccurred;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
171
20080212/Demo/PIC18_MPLAB/main2.c
Normal file
171
20080212/Demo/PIC18_MPLAB/main2.c
Normal file
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org 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.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
|
||||
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.
|
||||
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Instead of the normal single demo application, the PIC18F demo is split
|
||||
* into several smaller programs of which this is the second. This enables the
|
||||
* demo's to be executed on the RAM limited 40 pin devices. The 64 and 80 pin
|
||||
* devices require a more costly development platform and are not so readily
|
||||
* available.
|
||||
*
|
||||
* The RTOSDemo2 project is configured for a PIC18F452 device. Main2.c starts
|
||||
* 5 tasks (including the idle task).
|
||||
*
|
||||
* The first, second and third tasks do nothing but flash an LED. This gives
|
||||
* visual feedback that everything is executing as expected. One task flashes
|
||||
* an LED every 333ms (i.e. on and off every 333/2 ms), then next every 666ms
|
||||
* and the last every 999ms.
|
||||
*
|
||||
* The last task runs at the idle priority. It repeatedly performs a 32bit
|
||||
* calculation and checks it's result against the expected value. This checks
|
||||
* that the temporary storage utilised by the compiler to hold intermediate
|
||||
* results does not get corrupted when the task gets switched in and out.
|
||||
* should the calculation ever provide an incorrect result the final LED is
|
||||
* turned on.
|
||||
*
|
||||
* On entry to main() an 'X' is transmitted. Monitoring the serial port using a
|
||||
* dumb terminal allows for verification that the device is not continuously
|
||||
* being reset (no more than one 'X' should be transmitted).
|
||||
*
|
||||
* http://www.FreeRTOS.org contains important information on the use of the
|
||||
* PIC18F port.
|
||||
*/
|
||||
|
||||
/*
|
||||
Changes from V2.0.0
|
||||
|
||||
+ Delay periods are now specified using variables and constants of
|
||||
portTickType rather than unsigned portLONG.
|
||||
*/
|
||||
|
||||
/* Scheduler include files. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Demo app include files. */
|
||||
#include "flash.h"
|
||||
#include "partest.h"
|
||||
#include "serial.h"
|
||||
|
||||
/* Priority definitions for the LED tasks. Other tasks just use the idle
|
||||
priority. */
|
||||
#define mainLED_FLASH_PRIORITY ( tskIDLE_PRIORITY + ( unsigned portBASE_TYPE ) 1 )
|
||||
|
||||
/* The LED that is lit when should the calculation fail. */
|
||||
#define mainCHECK_TASK_LED ( ( unsigned portBASE_TYPE ) 3 )
|
||||
|
||||
/* Constants required for the communications. Only one character is ever
|
||||
transmitted. */
|
||||
#define mainCOMMS_QUEUE_LENGTH ( ( unsigned portBASE_TYPE ) 5 )
|
||||
#define mainNO_BLOCK ( ( portTickType ) 0 )
|
||||
#define mainBAUD_RATE ( ( unsigned portLONG ) 9600 )
|
||||
|
||||
/*
|
||||
* The task that performs the 32 bit calculation at the idle priority.
|
||||
*/
|
||||
static void vCalculationTask( void *pvParameters );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Creates the tasks, then starts the scheduler. */
|
||||
void main( void )
|
||||
{
|
||||
/* Initialise the required hardware. */
|
||||
vParTestInitialise();
|
||||
vPortInitialiseBlocks();
|
||||
|
||||
/* Send a character so we have some visible feedback of a reset. */
|
||||
xSerialPortInitMinimal( mainBAUD_RATE, mainCOMMS_QUEUE_LENGTH );
|
||||
xSerialPutChar( NULL, 'X', mainNO_BLOCK );
|
||||
|
||||
/* Start the standard LED flash tasks as defined in demo/common/minimal. */
|
||||
vStartLEDFlashTasks( mainLED_FLASH_PRIORITY );
|
||||
|
||||
/* Start the check task defined in this file. */
|
||||
xTaskCreate( vCalculationTask, ( const portCHAR * const ) "Check", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||
|
||||
/* Start the scheduler. */
|
||||
vTaskStartScheduler();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void vCalculationTask( void *pvParameters )
|
||||
{
|
||||
volatile unsigned long ulCalculatedValue; /* Volatile to ensure optimisation is minimal. */
|
||||
|
||||
/* Continuously perform a calculation. If the calculation result is ever
|
||||
incorrect turn the LED on. */
|
||||
for( ;; )
|
||||
{
|
||||
/* A good optimising compiler would just remove all this! */
|
||||
ulCalculatedValue = 1234UL;
|
||||
ulCalculatedValue *= 99UL;
|
||||
|
||||
if( ulCalculatedValue != 122166UL )
|
||||
{
|
||||
vParTestSetLED( mainCHECK_TASK_LED, pdTRUE );
|
||||
}
|
||||
|
||||
ulCalculatedValue *= 9876UL;
|
||||
|
||||
if( ulCalculatedValue != 1206511416UL )
|
||||
{
|
||||
vParTestSetLED( mainCHECK_TASK_LED, pdTRUE );
|
||||
}
|
||||
|
||||
ulCalculatedValue /= 15UL;
|
||||
|
||||
if( ulCalculatedValue != 80434094UL )
|
||||
{
|
||||
vParTestSetLED( mainCHECK_TASK_LED, pdTRUE );
|
||||
}
|
||||
|
||||
ulCalculatedValue += 918273UL;
|
||||
|
||||
if( ulCalculatedValue != 81352367UL )
|
||||
{
|
||||
vParTestSetLED( mainCHECK_TASK_LED, pdTRUE );
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
200
20080212/Demo/PIC18_MPLAB/main3.c
Normal file
200
20080212/Demo/PIC18_MPLAB/main3.c
Normal file
|
@ -0,0 +1,200 @@
|
|||
/*
|
||||
FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org 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.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
|
||||
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.
|
||||
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* THIS DEMO APPLICATION REQUIRES A LOOPBACK CONNECTOR TO BE FITTED TO THE PIC
|
||||
* USART PORT - connect pin 2 to pin 3 on J2.
|
||||
*
|
||||
* Instead of the normal single demo application, the PIC18F demo is split
|
||||
* into several smaller programs of which this is the third. This enables the
|
||||
* demo's to be executed on the RAM limited 40 pin devices. The 64 and 80 pin
|
||||
* devices require a more costly development platform and are not so readily
|
||||
* available.
|
||||
*
|
||||
* The RTOSDemo3 project is configured for a PIC18F452 device. Main3.c starts
|
||||
* 5 tasks (including the idle task).
|
||||
*
|
||||
* The first task repeatedly transmits a string of characters on the PIC USART
|
||||
* port. The second task receives the characters, checking that the correct
|
||||
* sequence is maintained (i.e. what is transmitted is identical to that
|
||||
* received). Each transmitted and each received character causes an LED to
|
||||
* flash. See demo/common/minimal/comtest. c for more information.
|
||||
*
|
||||
* The third task continuously performs a 32 bit calculation. This is a good
|
||||
* test of the context switch mechanism as the 8 bit architecture requires
|
||||
* the use of several file registers to perform the 32 bit operations. See
|
||||
* demo/common/minimal/integer. c for more information.
|
||||
*
|
||||
* The third task is the check task. This periodically checks that the other
|
||||
* tasks are still running and have not experienced any errors. If no errors
|
||||
* have been reported by either the comms or integer tasks an LED is flashed
|
||||
* with a frequency mainNO_ERROR_CHECK_PERIOD. If an error is discovered the
|
||||
* frequency is increased to mainERROR_FLASH_RATE.
|
||||
*
|
||||
* The check task also provides a visual indication of a system reset by
|
||||
* flashing the one remaining LED (mainRESET_LED) when it starts. After
|
||||
* this initial flash mainRESET_LED should remain off.
|
||||
*
|
||||
* http://www.FreeRTOS.org contains important information on the use of the
|
||||
* PIC18F port.
|
||||
*/
|
||||
|
||||
/*
|
||||
Changes from V2.0.0
|
||||
|
||||
+ Delay periods are now specified using variables and constants of
|
||||
portTickType rather than unsigned portLONG.
|
||||
*/
|
||||
|
||||
/* Scheduler include files. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Demo app include files. */
|
||||
#include "partest.h"
|
||||
#include "serial.h"
|
||||
#include "comtest.h"
|
||||
#include "integer.h"
|
||||
|
||||
/* Priority definitions for the LED tasks. Other tasks just use the idle
|
||||
priority. */
|
||||
#define mainCOMM_TEST_PRIORITY ( tskIDLE_PRIORITY + ( unsigned portBASE_TYPE ) 2 )
|
||||
#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + ( unsigned portBASE_TYPE ) 3 )
|
||||
|
||||
/* The period between executions of the check task before and after an error
|
||||
has been discovered. If an error has been discovered the check task runs
|
||||
more frequently - increasing the LED flash rate. */
|
||||
#define mainNO_ERROR_CHECK_PERIOD ( ( portTickType ) 1000 / portTICK_RATE_MS )
|
||||
#define mainERROR_CHECK_PERIOD ( ( portTickType ) 100 / portTICK_RATE_MS )
|
||||
|
||||
/* The period for which mainRESET_LED remain on every reset. */
|
||||
#define mainRESET_LED_PERIOD ( ( portTickType ) 500 / portTICK_RATE_MS )
|
||||
|
||||
/* The LED that is toggled whenever a character is transmitted.
|
||||
mainCOMM_TX_RX_LED + 1 will be toggled every time a character is received. */
|
||||
#define mainCOMM_TX_RX_LED ( ( unsigned portBASE_TYPE ) 2 )
|
||||
|
||||
/* The LED that is flashed by the check task at a rate that indicates the
|
||||
error status. */
|
||||
#define mainCHECK_TASK_LED ( ( unsigned portBASE_TYPE ) 1 )
|
||||
|
||||
/* The LED that is flashed once upon every reset. */
|
||||
#define mainRESET_LED ( ( unsigned portBASE_TYPE ) 0 )
|
||||
|
||||
/* Constants required for the communications. */
|
||||
#define mainCOMMS_QUEUE_LENGTH ( ( unsigned portBASE_TYPE ) 5 )
|
||||
#define mainBAUD_RATE ( ( unsigned portLONG ) 57600 )
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Task function which periodically checks the other tasks for errors. Flashes
|
||||
* an LED at a rate that indicates whether an error has ever been detected.
|
||||
*/
|
||||
static void vErrorChecks( void *pvParameters );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Creates the tasks, then starts the scheduler. */
|
||||
void main( void )
|
||||
{
|
||||
/* Initialise the required hardware. */
|
||||
vParTestInitialise();
|
||||
|
||||
/* Initialise the block memory allocator. */
|
||||
vPortInitialiseBlocks();
|
||||
|
||||
/* Start the standard comtest tasks as defined in demo/common/minimal. */
|
||||
vAltStartComTestTasks( mainCOMM_TEST_PRIORITY, mainBAUD_RATE, mainCOMM_TX_RX_LED );
|
||||
|
||||
/* Start the standard 32bit calculation task as defined in
|
||||
demo/common/minimal. */
|
||||
vStartIntegerMathTasks( tskIDLE_PRIORITY );
|
||||
|
||||
/* Start the check task defined in this file. */
|
||||
xTaskCreate( vErrorChecks, ( const portCHAR * const ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
|
||||
|
||||
/* Start the scheduler. This will never return. */
|
||||
vTaskStartScheduler();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void vErrorChecks( void *pvParameters )
|
||||
{
|
||||
portTickType xDelayTime = mainNO_ERROR_CHECK_PERIOD;
|
||||
volatile unsigned portLONG ulDummy = 3UL;
|
||||
|
||||
/* Toggle the LED so we can see when a reset occurs. */
|
||||
vParTestSetLED( mainRESET_LED, pdTRUE );
|
||||
vTaskDelay( mainRESET_LED_PERIOD );
|
||||
vParTestSetLED( mainRESET_LED, pdFALSE );
|
||||
|
||||
/* Cycle for ever, delaying then checking all the other tasks are still
|
||||
operating without error. */
|
||||
for( ;; )
|
||||
{
|
||||
/* Wait until it is time to check the other tasks. */
|
||||
vTaskDelay( xDelayTime );
|
||||
|
||||
/* Perform an integer calculation - just to ensure the registers
|
||||
get used. The result is not important. */
|
||||
ulDummy *= 3UL;
|
||||
|
||||
/* Check all the other tasks are running, and running without ever
|
||||
having an error. The delay period is lowered if an error is reported,
|
||||
causing the LED to flash at a higher rate. */
|
||||
if( xAreIntegerMathsTaskStillRunning() == pdFALSE )
|
||||
{
|
||||
xDelayTime = mainERROR_CHECK_PERIOD;
|
||||
}
|
||||
|
||||
if( xAreComTestTasksStillRunning() == pdFALSE )
|
||||
{
|
||||
xDelayTime = mainERROR_CHECK_PERIOD;
|
||||
}
|
||||
|
||||
/* Flash the LED for visual feedback. The rate of the flash will
|
||||
indicate the health of the system. */
|
||||
vParTestToggleLED( mainCHECK_TASK_LED );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
3
20080212/Demo/PIC18_MPLAB/makebin1.bat
Normal file
3
20080212/Demo/PIC18_MPLAB/makebin1.bat
Normal file
|
@ -0,0 +1,3 @@
|
|||
del rtosdemo.hex
|
||||
copy rtosdemo1.hex rtosdemo.hex
|
||||
hex2bin rtosdemo.hex
|
3
20080212/Demo/PIC18_MPLAB/makebin2.bat
Normal file
3
20080212/Demo/PIC18_MPLAB/makebin2.bat
Normal file
|
@ -0,0 +1,3 @@
|
|||
del rtosdemo.hex
|
||||
copy rtosdemo2.hex rtosdemo.hex
|
||||
hex2bin rtosdemo.hex
|
3
20080212/Demo/PIC18_MPLAB/makebin3.bat
Normal file
3
20080212/Demo/PIC18_MPLAB/makebin3.bat
Normal file
|
@ -0,0 +1,3 @@
|
|||
del rtosdemo.hex
|
||||
copy rtosdemo3.hex rtosdemo.hex
|
||||
hex2bin rtosdemo.hex
|
12
20080212/Demo/PIC18_MPLAB/readme.txt
Normal file
12
20080212/Demo/PIC18_MPLAB/readme.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
Unfortunately the project files:
|
||||
|
||||
RTOSDemo1.mcp
|
||||
RTOSDemo2.mcp
|
||||
and RTOSDemo3.mcp
|
||||
|
||||
contain absolute paths. I don't know how to get around this, so if somebody knows, let me know!
|
||||
|
||||
Edit the paths in a text editor before use.
|
||||
|
||||
See the PIC port section of www.FreeRTOS.org for more information.
|
||||
|
BIN
20080212/Demo/PIC18_MPLAB/rtosdemo.mcw
Normal file
BIN
20080212/Demo/PIC18_MPLAB/rtosdemo.mcw
Normal file
Binary file not shown.
74
20080212/Demo/PIC18_MPLAB/rtosdemo1.mcp
Normal file
74
20080212/Demo/PIC18_MPLAB/rtosdemo1.mcp
Normal file
|
@ -0,0 +1,74 @@
|
|||
[HEADER]
|
||||
magic_cookie={66E99B07-E706-4689-9E80-9B2582898A13}
|
||||
file_version=1.0
|
||||
[PATH_INFO]
|
||||
BuildDirPolicy=BuildDirIsSourceDir
|
||||
dir_src=
|
||||
dir_bin=
|
||||
dir_tmp=
|
||||
dir_sin=
|
||||
dir_inc=.;.\include;..\include;..\..\include;..\..\..\include;..\..\Source\include;..\..\..\Source\include;..\Demo\PIC18_MPLAB;..\..\..\Demo\PIC18_MPLAB;..\..\..\..\Demo\PIC18_MPLAB;C:\Devtools\Microchip\MCC18\h;..\Common\include;..\..\Common\include
|
||||
dir_lib=C:\Devtools\Microchip\MCC18\lib
|
||||
dir_lkr=
|
||||
[CAT_FILTERS]
|
||||
filter_src=*.asm;*.c
|
||||
filter_inc=*.h;*.inc
|
||||
filter_obj=*.o
|
||||
filter_lib=*.lib
|
||||
filter_lkr=*.lkr
|
||||
[OTHER_FILES]
|
||||
file_000=no
|
||||
file_001=no
|
||||
file_002=no
|
||||
file_003=no
|
||||
file_004=no
|
||||
file_005=no
|
||||
file_006=no
|
||||
file_007=no
|
||||
file_008=no
|
||||
file_009=no
|
||||
file_010=no
|
||||
file_011=no
|
||||
file_012=no
|
||||
file_013=no
|
||||
file_014=no
|
||||
file_015=no
|
||||
file_016=no
|
||||
file_017=no
|
||||
file_018=no
|
||||
file_019=no
|
||||
file_020=no
|
||||
[FILE_INFO]
|
||||
file_000=..\..\Source\tasks.c
|
||||
file_001=..\..\Source\queue.c
|
||||
file_002=..\..\Source\list.c
|
||||
file_003=..\..\Source\portable\MPLAB\PIC18F\port.c
|
||||
file_004=..\Common\Minimal\PollQ.c
|
||||
file_005=main1.c
|
||||
file_006=ParTest\ParTest.c
|
||||
file_007=serial\serial.c
|
||||
file_008=..\Common\Minimal\integer.c
|
||||
file_009=..\..\Source\portable\MemMang\heap_1.c
|
||||
file_010=..\..\Source\portable\MPLAB\PIC18F\portmacro.h
|
||||
file_011=..\..\Source\include\task.h
|
||||
file_012=..\..\Source\include\list.h
|
||||
file_013=..\..\Source\include\portable.h
|
||||
file_014=..\..\Source\include\projdefs.h
|
||||
file_015=..\..\Source\include\queue.h
|
||||
file_016=..\Common\include\integer.h
|
||||
file_017=..\Common\include\PollQ.h
|
||||
file_018=..\Common\include\serial.h
|
||||
file_019=FreeRTOSConfig.h
|
||||
file_020=18f452.lkr
|
||||
[SUITE_INFO]
|
||||
suite_guid={5B7D72DD-9861-47BD-9F60-2BE967BF8416}
|
||||
suite_state=
|
||||
[TOOL_SETTINGS]
|
||||
TS{DD2213A8-6310-47B1-8376-9430CDFC013F}=/aINHX8M
|
||||
TS{BFD27FBA-4A02-4C0E-A5E5-B812F3E7707C}=/m"$(BINDIR_)$(TARGETBASE).map" /aINHX8M /o"$(TARGETBASE).cof"
|
||||
TS{C2AF05E7-1416-4625-923D-E114DB6E2B96}=-w3 -DMPLAB_PIC18F_PORT -Ls -Opa- -nw 2074 -nw 2066
|
||||
TS{ADE93A55-C7C7-4D4D-A4BA-59305F7D0391}=
|
||||
[INSTRUMENTED_TRACE]
|
||||
enable=0
|
||||
transport=0
|
||||
format=0
|
68
20080212/Demo/PIC18_MPLAB/rtosdemo2.mcp
Normal file
68
20080212/Demo/PIC18_MPLAB/rtosdemo2.mcp
Normal file
|
@ -0,0 +1,68 @@
|
|||
[HEADER]
|
||||
magic_cookie={66E99B07-E706-4689-9E80-9B2582898A13}
|
||||
file_version=1.0
|
||||
[PATH_INFO]
|
||||
dir_src=
|
||||
dir_bin=
|
||||
dir_tmp=
|
||||
dir_sin=
|
||||
dir_inc=.;.\include;..\include;..\..\include;..\..\..\include;..\..\Source\include;..\..\..\Source\include;..\Demo\PIC18_MPLAB;..\..\..\Demo\PIC18_MPLAB;..\..\..\..\Demo\PIC18_MPLAB;C:\Devtools\Microchip\MCC18\h;..\Common\include;..\..\Common\include
|
||||
dir_lib=C:\Devtools\Microchip\MCC18\lib
|
||||
dir_lkr=
|
||||
[CAT_FILTERS]
|
||||
filter_src=*.asm;*.c
|
||||
filter_inc=*.h;*.inc
|
||||
filter_obj=*.o
|
||||
filter_lib=*.lib
|
||||
filter_lkr=*.lkr
|
||||
[OTHER_FILES]
|
||||
file_000=no
|
||||
file_001=no
|
||||
file_002=no
|
||||
file_003=no
|
||||
file_004=no
|
||||
file_005=no
|
||||
file_006=no
|
||||
file_007=no
|
||||
file_008=no
|
||||
file_009=no
|
||||
file_010=no
|
||||
file_011=no
|
||||
file_012=no
|
||||
file_013=no
|
||||
file_014=no
|
||||
file_015=no
|
||||
file_016=no
|
||||
file_017=no
|
||||
file_018=no
|
||||
[FILE_INFO]
|
||||
file_000=main2.c
|
||||
file_001=serial\serial.c
|
||||
file_002=ParTest\ParTest.c
|
||||
file_003=..\..\Source\tasks.c
|
||||
file_004=..\..\Source\queue.c
|
||||
file_005=..\..\Source\list.c
|
||||
file_006=..\..\Source\portable\MemMang\heap_1.c
|
||||
file_007=..\Common\Minimal\flash.c
|
||||
file_008=..\..\Source\portable\MPLAB\PIC18F\port.c
|
||||
file_009=..\..\Source\portable\MPLAB\PIC18F\portmacro.h
|
||||
file_010=..\..\Source\include\task.h
|
||||
file_011=..\..\Source\include\list.h
|
||||
file_012=..\..\Source\include\portable.h
|
||||
file_013=..\..\Source\include\projdefs.h
|
||||
file_014=..\..\Source\include\queue.h
|
||||
file_015=..\Common\include\serial.h
|
||||
file_016=..\Common\include\flash.h
|
||||
file_017=FreeRTOSConfig.h
|
||||
file_018=18f452.lkr
|
||||
[SUITE_INFO]
|
||||
suite_guid={5B7D72DD-9861-47BD-9F60-2BE967BF8416}
|
||||
suite_state=
|
||||
[TOOL_SETTINGS]
|
||||
TS{DD2213A8-6310-47B1-8376-9430CDFC013F}=/aINHX8M
|
||||
TS{BFD27FBA-4A02-4C0E-A5E5-B812F3E7707C}=/m"$(BINDIR_)$(TARGETBASE).map" /aINHX8M /o"$(TARGETBASE).cof"
|
||||
TS{C2AF05E7-1416-4625-923D-E114DB6E2B96}=-DMPLAB_PIC18F_PORT -Ls -Opa- -nw 2074 -nw 2066
|
||||
TS{ADE93A55-C7C7-4D4D-A4BA-59305F7D0391}=
|
||||
[TOOL_LOC_STAMPS]
|
||||
tool_loc{96C98149-AA1B-4CF9-B967-FAE79CAB663C}=D:\DevTools\mcc18\bin\mplink.exe
|
||||
tool_loc{E56A1C86-9D32-4DF6-8C34-FE0388B1B644}=D:\DevTools\mcc18\bin\mcc18.exe
|
70
20080212/Demo/PIC18_MPLAB/rtosdemo3.mcp
Normal file
70
20080212/Demo/PIC18_MPLAB/rtosdemo3.mcp
Normal file
|
@ -0,0 +1,70 @@
|
|||
[HEADER]
|
||||
magic_cookie={66E99B07-E706-4689-9E80-9B2582898A13}
|
||||
file_version=1.0
|
||||
[PATH_INFO]
|
||||
dir_src=
|
||||
dir_bin=
|
||||
dir_tmp=
|
||||
dir_sin=
|
||||
dir_inc=.;.\include;..\include;..\..\include;..\..\..\include;..\..\Source\include;..\..\..\Source\include;..\Demo\PIC18_MPLAB;..\..\..\Demo\PIC18_MPLAB;..\..\..\..\Demo\PIC18_MPLAB;C:\Devtools\Microchip\MCC18\h;..\Common\include;..\..\Common\include
|
||||
dir_lib=C:\Devtools\Microchip\MCC18\lib
|
||||
dir_lkr=
|
||||
[CAT_FILTERS]
|
||||
filter_src=*.asm;*.c
|
||||
filter_inc=*.h;*.inc
|
||||
filter_obj=*.o
|
||||
filter_lib=*.lib
|
||||
filter_lkr=*.lkr
|
||||
[OTHER_FILES]
|
||||
file_000=no
|
||||
file_001=no
|
||||
file_002=no
|
||||
file_003=no
|
||||
file_004=no
|
||||
file_005=no
|
||||
file_006=no
|
||||
file_007=no
|
||||
file_008=no
|
||||
file_009=no
|
||||
file_010=no
|
||||
file_011=no
|
||||
file_012=no
|
||||
file_013=no
|
||||
file_014=no
|
||||
file_015=no
|
||||
file_016=no
|
||||
file_017=no
|
||||
file_018=no
|
||||
file_019=no
|
||||
[FILE_INFO]
|
||||
file_000=..\..\Source\tasks.c
|
||||
file_001=..\..\Source\queue.c
|
||||
file_002=..\..\Source\list.c
|
||||
file_003=..\..\Source\portable\MPLAB\PIC18F\port.c
|
||||
file_004=serial\serial.c
|
||||
file_005=main3.c
|
||||
file_006=..\Common\Minimal\comtest.c
|
||||
file_007=..\Common\Minimal\integer.c
|
||||
file_008=..\..\Source\portable\MemMang\heap_1.c
|
||||
file_009=ParTest\ParTest.c
|
||||
file_010=..\..\Source\portable\MPLAB\PIC18F\portmacro.h
|
||||
file_011=..\..\Source\include\task.h
|
||||
file_012=..\..\Source\include\list.h
|
||||
file_013=..\..\Source\include\portable.h
|
||||
file_014=..\..\Source\include\projdefs.h
|
||||
file_015=..\..\Source\include\queue.h
|
||||
file_016=..\Common\include\serial.h
|
||||
file_017=..\Common\include\comtest.h
|
||||
file_018=FreeRTOSConfig.h
|
||||
file_019=18f452.lkr
|
||||
[SUITE_INFO]
|
||||
suite_guid={5B7D72DD-9861-47BD-9F60-2BE967BF8416}
|
||||
suite_state=
|
||||
[TOOL_SETTINGS]
|
||||
TS{DD2213A8-6310-47B1-8376-9430CDFC013F}=/aINHX8M
|
||||
TS{BFD27FBA-4A02-4C0E-A5E5-B812F3E7707C}=/m"$(BINDIR_)$(TARGETBASE).map" /aINHX8M /o"$(TARGETBASE).cof"
|
||||
TS{C2AF05E7-1416-4625-923D-E114DB6E2B96}=-DMPLAB_PIC18F_PORT -Ls -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- -nw 2074 -nw 2066
|
||||
TS{ADE93A55-C7C7-4D4D-A4BA-59305F7D0391}=
|
||||
[TOOL_LOC_STAMPS]
|
||||
tool_loc{96C98149-AA1B-4CF9-B967-FAE79CAB663C}=D:\DevTools\mcc18\bin\mplink.exe
|
||||
tool_loc{E56A1C86-9D32-4DF6-8C34-FE0388B1B644}=D:\DevTools\mcc18\bin\mcc18.exe
|
238
20080212/Demo/PIC18_MPLAB/serial/serial.c
Normal file
238
20080212/Demo/PIC18_MPLAB/serial/serial.c
Normal file
|
@ -0,0 +1,238 @@
|
|||
/*
|
||||
FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
FreeRTOS.org is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FreeRTOS.org 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.org; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||
the source code for any proprietary components. See the licensing section
|
||||
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||
can be applied.
|
||||
|
||||
***************************************************************************
|
||||
|
||||
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.
|
||||
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
Changes from V1.2.5
|
||||
|
||||
+ Clear overrun errors in the Rx ISR. Overrun errors prevent any further
|
||||
characters being received.
|
||||
|
||||
Changes from V2.0.0
|
||||
|
||||
+ Use portTickType in place of unsigned pdLONG for delay periods.
|
||||
+ cQueueReieveFromISR() used in place of xQueueReceive() in ISR.
|
||||
*/
|
||||
|
||||
/* BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER. */
|
||||
|
||||
/* Scheduler header files. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "serial.h"
|
||||
#include "queue.h"
|
||||
|
||||
/*
|
||||
* Prototypes for ISR's. The PIC architecture means that these functions
|
||||
* have to be called from port.c. The prototypes are not however included
|
||||
* in the header as the header is common to all ports.
|
||||
*/
|
||||
void vSerialTxISR( void );
|
||||
void vSerialRxISR( void );
|
||||
|
||||
/* Hardware pin definitions. */
|
||||
#define serTX_PIN TRISCbits.TRISC6
|
||||
#define serRX_PIN TRISCbits.TRISC7
|
||||
|
||||
/* Bit/register definitions. */
|
||||
#define serINPUT ( 1 )
|
||||
#define serOUTPUT ( 0 )
|
||||
#define serTX_ENABLE ( ( unsigned portSHORT ) 1 )
|
||||
#define serRX_ENABLE ( ( unsigned portSHORT ) 1 )
|
||||
#define serHIGH_SPEED ( ( unsigned portSHORT ) 1 )
|
||||
#define serCONTINUOUS_RX ( ( unsigned portSHORT ) 1 )
|
||||
#define serCLEAR_OVERRUN ( ( unsigned portSHORT ) 0 )
|
||||
#define serINTERRUPT_ENABLED ( ( unsigned portSHORT ) 1 )
|
||||
#define serINTERRUPT_DISABLED ( ( unsigned portSHORT ) 0 )
|
||||
|
||||
/* All ISR's use the PIC18 low priority interrupt. */
|
||||
#define serLOW_PRIORITY ( 0 )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Queues to interface between comms API and interrupt routines. */
|
||||
static xQueueHandle xRxedChars;
|
||||
static xQueueHandle xCharsForTx;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
xComPortHandle xSerialPortInitMinimal( unsigned portLONG ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
|
||||
{
|
||||
unsigned portLONG ulBaud;
|
||||
|
||||
/* Calculate the baud rate generator constant.
|
||||
SPBRG = ( (FOSC / Desired Baud Rate) / 16 ) - 1 */
|
||||
ulBaud = configCPU_CLOCK_HZ / ulWantedBaud;
|
||||
ulBaud /= ( unsigned portLONG ) 16;
|
||||
ulBaud -= ( unsigned portLONG ) 1;
|
||||
|
||||
/* Create the queues used by the ISR's to interface to tasks. */
|
||||
xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( portCHAR ) );
|
||||
xCharsForTx = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( portCHAR ) );
|
||||
|
||||
portENTER_CRITICAL();
|
||||
{
|
||||
/* Start with config registers cleared, so we can just set the wanted
|
||||
bits. */
|
||||
TXSTA = ( unsigned portSHORT ) 0;
|
||||
RCSTA = ( unsigned portSHORT ) 0;
|
||||
|
||||
/* Set the baud rate generator using the above calculated constant. */
|
||||
SPBRG = ( unsigned portCHAR ) ulBaud;
|
||||
|
||||
/* Setup the IO pins to enable the USART IO. */
|
||||
serTX_PIN = serOUTPUT;
|
||||
serRX_PIN = serINPUT;
|
||||
|
||||
/* Set the serial interrupts to use the same priority as the tick. */
|
||||
IPR1bits.TXIP = serLOW_PRIORITY;
|
||||
IPR1bits.RCIP = serLOW_PRIORITY;
|
||||
|
||||
/* Setup Tx configuration. */
|
||||
TXSTAbits.BRGH = serHIGH_SPEED;
|
||||
TXSTAbits.TXEN = serTX_ENABLE;
|
||||
|
||||
/* Setup Rx configuration. */
|
||||
RCSTAbits.SPEN = serRX_ENABLE;
|
||||
RCSTAbits.CREN = serCONTINUOUS_RX;
|
||||
|
||||
/* Enable the Rx interrupt now, the Tx interrupt will get enabled when
|
||||
we have data to send. */
|
||||
PIE1bits.RCIE = serINTERRUPT_ENABLED;
|
||||
}
|
||||
portEXIT_CRITICAL();
|
||||
|
||||
/* Unlike other ports, this serial code does not allow for more than one
|
||||
com port. We therefore don't return a pointer to a port structure and
|
||||
can instead just return NULL. */
|
||||
return NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
xComPortHandle xSerialPortInit( eCOMPort ePort, eBaud eWantedBaud, eParity eWantedParity, eDataBits eWantedDataBits, eStopBits eWantedStopBits, unsigned portBASE_TYPE uxBufferLength )
|
||||
{
|
||||
/* This is not implemented in this port.
|
||||
Use xSerialPortInitMinimal() instead. */
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed portCHAR *pcRxedChar, portTickType xBlockTime )
|
||||
{
|
||||
/* 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
|
||||
{
|
||||
return pdFALSE;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed portCHAR cOutChar, portTickType xBlockTime )
|
||||
{
|
||||
/* Return false if after the block time there is no room on the Tx queue. */
|
||||
if( xQueueSend( xCharsForTx, ( const void * ) &cOutChar, xBlockTime ) != pdPASS )
|
||||
{
|
||||
return pdFAIL;
|
||||
}
|
||||
|
||||
/* Turn interrupt on - ensure the compiler only generates a single
|
||||
instruction for this. */
|
||||
PIE1bits.TXIE = serINTERRUPT_ENABLED;
|
||||
|
||||
return pdPASS;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vSerialClose( xComPortHandle xPort )
|
||||
{
|
||||
/* Not implemented for this port.
|
||||
To implement, turn off the interrupts and delete the memory
|
||||
allocated to the queues. */
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#pragma interruptlow vSerialRxISR save=PRODH, PRODL, TABLAT, section(".tmpdata")
|
||||
void vSerialRxISR( void )
|
||||
{
|
||||
portCHAR cChar;
|
||||
|
||||
/* Get the character and post it on the queue of Rxed characters.
|
||||
If the post causes a task to wake force a context switch as the woken task
|
||||
may have a higher priority than the task we have interrupted. */
|
||||
cChar = RCREG;
|
||||
|
||||
/* Clear any overrun errors. */
|
||||
if( RCSTAbits.OERR )
|
||||
{
|
||||
RCSTAbits.CREN = serCLEAR_OVERRUN;
|
||||
RCSTAbits.CREN = serCONTINUOUS_RX;
|
||||
}
|
||||
|
||||
if( xQueueSendFromISR( xRxedChars, ( const void * ) &cChar, pdFALSE ) )
|
||||
{
|
||||
taskYIELD();
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#pragma interruptlow vSerialTxISR save=PRODH, PRODL, TABLAT, section(".tmpdata")
|
||||
void vSerialTxISR( void )
|
||||
{
|
||||
portCHAR cChar, cTaskWoken;
|
||||
|
||||
if( xQueueReceiveFromISR( xCharsForTx, &cChar, &cTaskWoken ) == pdTRUE )
|
||||
{
|
||||
/* Send the next character queued for Tx. */
|
||||
TXREG = cChar;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Queue empty, nothing to send. */
|
||||
PIE1bits.TXIE = serINTERRUPT_DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue