mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-01 08:54:14 -04:00
Add PIC24, dsPIC and Coldfire files.
This commit is contained in:
parent
5561c55286
commit
3878b82c9b
218 changed files with 54714 additions and 0 deletions
77
Demo/dsPIC_MPLAB/FreeRTOSConfig.h
Normal file
77
Demo/dsPIC_MPLAB/FreeRTOSConfig.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
FreeRTOS.org V4.1.0 - Copyright (C) 2003-2006 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.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
#include <p33FJ256GP710.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 1
|
||||
#define configUSE_TICK_HOOK 0
|
||||
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
|
||||
#define configCPU_CLOCK_HZ ( ( unsigned portLONG ) 25000000 ) /* Fosc / 2 */
|
||||
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 4 )
|
||||
#define configMINIMAL_STACK_SIZE ( 105 )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) 5120 )
|
||||
#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 1
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
/* Set the following definitions to 1 to include the API function, or zero
|
||||
to exclude the API function. */
|
||||
|
||||
#define INCLUDE_vTaskPrioritySet 1
|
||||
#define INCLUDE_uxTaskPriorityGet 0
|
||||
#define INCLUDE_vTaskDelete 0
|
||||
#define INCLUDE_vTaskCleanUpResources 0
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
113
Demo/dsPIC_MPLAB/ParTest/ParTest.c
Normal file
113
Demo/dsPIC_MPLAB/ParTest/ParTest.c
Normal file
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
FreeRTOS.org V4.1.0 - Copyright (C) 2003-2006 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.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
/* Demo app includes. */
|
||||
#include "partest.h"
|
||||
|
||||
#define ptOUTPUT 0
|
||||
#define ptALL_OFF 0
|
||||
|
||||
unsigned portBASE_TYPE uxOutput;
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Simple parallel port IO routines.
|
||||
*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestInitialise( void )
|
||||
{
|
||||
/* The explorer 16 board has LED's on port A. All bits are set as output
|
||||
so PORTA is read-modified-written directly. Two pins have change
|
||||
notification pullups that need disabling. */
|
||||
CNPU2bits.CN22PUE = 0;
|
||||
CNPU2bits.CN23PUE = 0;
|
||||
TRISA = ptOUTPUT;
|
||||
PORTA = ptALL_OFF;
|
||||
uxOutput = ptALL_OFF;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
|
||||
{
|
||||
unsigned portBASE_TYPE uxLEDBit;
|
||||
|
||||
/* Which port A bit is being modified? */
|
||||
uxLEDBit = 1 << uxLED;
|
||||
|
||||
if( xValue )
|
||||
{
|
||||
/* Turn the LED on. */
|
||||
portENTER_CRITICAL();
|
||||
{
|
||||
uxOutput |= uxLEDBit;
|
||||
PORTA = uxOutput;
|
||||
}
|
||||
portEXIT_CRITICAL();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Turn the LED off. */
|
||||
portENTER_CRITICAL();
|
||||
{
|
||||
uxOutput &= ~uxLEDBit;
|
||||
PORTA = uxOutput;
|
||||
}
|
||||
portEXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
|
||||
{
|
||||
unsigned portBASE_TYPE uxLEDBit;
|
||||
|
||||
uxLEDBit = 1 << uxLED;
|
||||
portENTER_CRITICAL();
|
||||
{
|
||||
/* If the LED is already on - turn it off. If the LED is already
|
||||
off, turn it on. */
|
||||
if( uxOutput & uxLEDBit )
|
||||
{
|
||||
uxOutput &= ~uxLEDBit;
|
||||
PORTA = uxOutput;
|
||||
}
|
||||
else
|
||||
{
|
||||
uxOutput |= uxLEDBit;
|
||||
PORTA = uxOutput;
|
||||
}
|
||||
}
|
||||
portEXIT_CRITICAL();
|
||||
}
|
||||
|
3
Demo/dsPIC_MPLAB/RTOSDemo.mcs
Normal file
3
Demo/dsPIC_MPLAB/RTOSDemo.mcs
Normal file
|
@ -0,0 +1,3 @@
|
|||
[Header]
|
||||
MagicCookie={0b13fe8c-dfe0-40eb-8900-6712719559a7}
|
||||
Version=1.0
|
BIN
Demo/dsPIC_MPLAB/RTOSDemo.mcw
Normal file
BIN
Demo/dsPIC_MPLAB/RTOSDemo.mcw
Normal file
Binary file not shown.
67
Demo/dsPIC_MPLAB/RTOSDemo_dsPIC.mcp
Normal file
67
Demo/dsPIC_MPLAB/RTOSDemo_dsPIC.mcp
Normal file
|
@ -0,0 +1,67 @@
|
|||
[HEADER]
|
||||
magic_cookie={66E99B07-E706-4689-9E80-9B2582898A13}
|
||||
file_version=1.0
|
||||
[PATH_INFO]
|
||||
dir_src=
|
||||
dir_bin=
|
||||
dir_tmp=
|
||||
dir_sin=
|
||||
dir_inc=.;C:\E\Dev\FreeRTOS\Demo\Common\include;C:\E\Dev\FreeRTOS\Demo\dsPIC_MPLAB;C:\E\Dev\FreeRTOS\source\include
|
||||
dir_lib=
|
||||
dir_lkr=
|
||||
[CAT_FILTERS]
|
||||
filter_src=*.s;*.c
|
||||
filter_inc=*.h;*.inc
|
||||
filter_obj=*.o
|
||||
filter_lib=*.a
|
||||
filter_lkr=*.gld
|
||||
[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=main.c
|
||||
file_001=..\..\source\list.c
|
||||
file_002=..\..\source\queue.c
|
||||
file_003=..\..\source\tasks.c
|
||||
file_004=..\..\source\portable\MPLAB\PIC24_dsPIC\port.c
|
||||
file_005=..\..\source\portable\MemMang\heap_1.c
|
||||
file_006=..\Common\Minimal\BlockQ.c
|
||||
file_007=..\..\source\croutine.c
|
||||
file_008=..\Common\Minimal\crflash.c
|
||||
file_009=ParTest\ParTest.c
|
||||
file_010=..\Common\Minimal\blocktim.c
|
||||
file_011=..\Common\Minimal\integer.c
|
||||
file_012=..\Common\Minimal\comtest.c
|
||||
file_013=serial\serial.c
|
||||
file_014=..\..\source\include\semphr.h
|
||||
file_015=..\..\source\include\task.h
|
||||
file_016=..\..\source\include\croutine.h
|
||||
file_017=..\..\source\include\queue.h
|
||||
file_018=FreeRTOSConfig.h
|
||||
file_019=p33FJ256GP710.gld
|
||||
[SUITE_INFO]
|
||||
suite_guid={479DDE59-4D56-455E-855E-FFF59A3DB57E}
|
||||
suite_state=
|
||||
[TOOL_SETTINGS]
|
||||
TS{7D9C6ECE-785D-44CB-BA22-17BF2E119622}=-g
|
||||
TS{25AC22BD-2378-4FDB-BFB6-7345A15512D3}=-g -Wall -DMPLAB_DSPIC_PORT -O2 -fomit-frame-pointer -fno-schedule-insns -fno-schedule-insns2
|
||||
TS{7DAC9A1D-4C45-45D6-B25A-D117C74E8F5A}=--defsym=__ICD2RAM=1 -Map="$(TARGETBASE).map" -o"$(TARGETBASE).$(TARGETSUFFIX)"
|
||||
TS{509E5861-1E2A-483B-8B6B-CA8DB7F2DD78}=
|
3
Demo/dsPIC_MPLAB/RTOSDemo_dsPIC.mcs
Normal file
3
Demo/dsPIC_MPLAB/RTOSDemo_dsPIC.mcs
Normal file
|
@ -0,0 +1,3 @@
|
|||
[Header]
|
||||
MagicCookie={0b13fe8c-dfe0-40eb-8900-6712719559a7}
|
||||
Version=1.0
|
420
Demo/dsPIC_MPLAB/main.c
Normal file
420
Demo/dsPIC_MPLAB/main.c
Normal file
|
@ -0,0 +1,420 @@
|
|||
/*
|
||||
FreeRTOS.org V4.1.0 - Copyright (C) 2003-2006 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.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Creates all the demo application tasks, then starts the scheduler. The WEB
|
||||
* documentation provides more details of the standard demo application tasks.
|
||||
* In addition to the standard demo tasks, the following tasks are defined
|
||||
* within this file:
|
||||
*
|
||||
* "Register test" tasks - These tasks first set all the general purpose
|
||||
* registers to a known value (with each register containing a different value)
|
||||
* then test each general purpose register to ensure it still contains the
|
||||
* set value. There are two register test tasks, with different values being
|
||||
* used by each. The register test tasks will be preempted frequently due to
|
||||
* their low priority. Setting then testing the value of each register in this
|
||||
* manner ensures the context of the tasks is being correctly saved and then
|
||||
* restored as the preemptive context switches occur. An error is flagged
|
||||
* should any register be found to contain an unexpected value. In addition
|
||||
* the register test tasks maintain a count of the number of times they cycle,
|
||||
* so an error can also be flagged should the cycle count not increment as
|
||||
* expected (indicating the the tasks are not executing at all).
|
||||
*
|
||||
* "Check" task - This only executes every three seconds but has the highest
|
||||
* priority so is guaranteed to get processor time. Its main function is to
|
||||
* check that all the other tasks are still operational. Each task maintains a
|
||||
* unique count that is incremented each time the task successfully completes
|
||||
* its function. Should any error occur within such a task the count is
|
||||
* permanently halted. The check task inspects the count of each task to
|
||||
* ensure it has changed since the last time the check task executed. If all
|
||||
* the count variables have changed all the tasks are still executing error
|
||||
* free, and the check task toggles the onboard LED. Should any task contain
|
||||
* an error at any time check task cycle frequency is increased to 500ms,
|
||||
* causing the LED toggle rate to increase from 3 seconds to 500ms and in so
|
||||
* doing providing visual feedback that an error has occurred.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "croutine.h"
|
||||
|
||||
/* Demo application includes. */
|
||||
#include "BlockQ.h"
|
||||
#include "crflash.h"
|
||||
#include "blocktim.h"
|
||||
#include "integer.h"
|
||||
#include "comtest2.h"
|
||||
#include "partest.h"
|
||||
|
||||
/* Demo task priorities. */
|
||||
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
||||
#define mainCOM_TEST_PRIORITY ( 2 )
|
||||
|
||||
/* Delay between check task cycles when an error has/has not been detected. */
|
||||
#define mainNO_ERROR_DELAY ( ( portTickType ) 3000 / portTICK_RATE_MS )
|
||||
#define mainERROR_DELAY ( ( portTickType ) 500 / portTICK_RATE_MS )
|
||||
|
||||
/* The number of flash co-routines to create. */
|
||||
#define mainNUM_FLASH_COROUTINES ( 3 )
|
||||
|
||||
/* Baud rate used by the comtest tasks. */
|
||||
#define mainCOM_TEST_BAUD_RATE ( 19200 )
|
||||
|
||||
/* The LED used by the comtest tasks. mainCOM_TEST_LED + 1 is also used.
|
||||
See the comtest.c file for more information. */
|
||||
#define mainCOM_TEST_LED ( 4 )
|
||||
|
||||
/* The LED used by the check task. */
|
||||
#define mainCHECK_LED ( 7 )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* The register test tasks as described at the top of this file.
|
||||
*/
|
||||
void xRegisterTest1( void *pvParameters );
|
||||
void xRegisterTest2( void *pvParameters );
|
||||
|
||||
/*
|
||||
* The check task as described at the top of this file.
|
||||
*/
|
||||
static void vCheckTask( void *pvParameters );
|
||||
|
||||
/*
|
||||
* Setup the processor ready for the demo.
|
||||
*/
|
||||
static void prvSetupHardware( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Variables used to detect errors within the register test tasks. */
|
||||
static volatile unsigned portSHORT usTest1CycleCounter = 0, usTest2CycleCounter = 0;
|
||||
static unsigned portSHORT usPreviousTest1Count = 0, usPreviousTest2Count = 0;
|
||||
|
||||
/* Set to pdTRUE should an error be detected in any of the standard demo tasks
|
||||
or tasks defined within this file. */
|
||||
static unsigned portSHORT usErrorDetected = pdFALSE;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Create the demo tasks then start the scheduler.
|
||||
*/
|
||||
int main( void )
|
||||
{
|
||||
/* Configure any hardware required for this demo. */
|
||||
prvSetupHardware();
|
||||
|
||||
/* Create the standard demo tasks. */
|
||||
vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
|
||||
vStartIntegerMathTasks( tskIDLE_PRIORITY );
|
||||
vStartFlashCoRoutines( mainNUM_FLASH_COROUTINES );
|
||||
vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
|
||||
vCreateBlockTimeTasks();
|
||||
|
||||
/* Create the test tasks defined within this file. */
|
||||
xTaskCreate( xRegisterTest1, "Reg1", configMINIMAL_STACK_SIZE, ( void * ) &usTest1CycleCounter, tskIDLE_PRIORITY, NULL );
|
||||
xTaskCreate( xRegisterTest2, "Reg2", configMINIMAL_STACK_SIZE, ( void * ) &usTest2CycleCounter, tskIDLE_PRIORITY, NULL );
|
||||
xTaskCreate( vCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
|
||||
|
||||
/* Finally start the scheduler. */
|
||||
vTaskStartScheduler();
|
||||
|
||||
/* Will only reach here if there is insufficient heap available to start
|
||||
the scheduler. */
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSetupHardware( void )
|
||||
{
|
||||
vParTestInitialise();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void vCheckTask( void *pvParameters )
|
||||
{
|
||||
portTickType xLastExecutionTime;
|
||||
|
||||
/* Start with the no error delay. The long delay will cause the LED to flash
|
||||
slowly. */
|
||||
portTickType xDelay = mainNO_ERROR_DELAY;
|
||||
|
||||
/* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()
|
||||
works correctly. */
|
||||
xLastExecutionTime = xTaskGetTickCount();
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Wait until it is time for the next cycle. */
|
||||
vTaskDelayUntil( &xLastExecutionTime, xDelay );
|
||||
|
||||
/* Has an error been found in any of the standard demo tasks? */
|
||||
|
||||
if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
|
||||
{
|
||||
usErrorDetected = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreComTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
usErrorDetected = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
usErrorDetected = pdTRUE;
|
||||
}
|
||||
|
||||
if( xAreBlockingQueuesStillRunning() != pdTRUE )
|
||||
{
|
||||
usErrorDetected = pdTRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Are the register test tasks still cycling? */
|
||||
|
||||
if( usTest1CycleCounter == usPreviousTest1Count )
|
||||
{
|
||||
usErrorDetected = pdTRUE;
|
||||
}
|
||||
|
||||
if( usTest2CycleCounter == usPreviousTest2Count )
|
||||
{
|
||||
usErrorDetected = pdTRUE;
|
||||
}
|
||||
|
||||
usPreviousTest2Count = usTest2CycleCounter;
|
||||
usPreviousTest1Count = usTest1CycleCounter;
|
||||
|
||||
|
||||
/* If an error has been detected in any task then the delay will be
|
||||
reduced to increase the cycle rate of this task. This has the effect
|
||||
of causing the LED to flash much faster giving a visual indication of
|
||||
the error condition. */
|
||||
if( usErrorDetected != pdFALSE )
|
||||
{
|
||||
xDelay = mainERROR_DELAY;
|
||||
}
|
||||
|
||||
/* Finally, toggle the LED before returning to delay to wait for the
|
||||
next cycle. */
|
||||
vParTestToggleLED( mainCHECK_LED );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void xRegisterTest1( void *pvParameters )
|
||||
{
|
||||
/* This static so as not to use the frame pointer. They are volatile
|
||||
also to avoid it being stored in a register that we clobber during the test. */
|
||||
static unsigned portSHORT * volatile pusParameter;
|
||||
|
||||
/* The variable incremented by this task is passed in as the parameter
|
||||
even though it is defined within this file. This is just to test the
|
||||
parameter passing mechanism. */
|
||||
pusParameter = pvParameters;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Increment the variable to show this task is still cycling. */
|
||||
( *pusParameter )++;
|
||||
|
||||
/* Set the w registers to known values, then check that each register
|
||||
contains the expected value. See the explanation at the top of this
|
||||
file for more information. */
|
||||
asm volatile( "mov.w #0x0101, W0 \n" \
|
||||
"mov.w #0x0102, W1 \n" \
|
||||
"mov.w #0x0103, W2 \n" \
|
||||
"mov.w #0x0104, W3 \n" \
|
||||
"mov.w #0x0105, W4 \n" \
|
||||
"mov.w #0x0106, W5 \n" \
|
||||
"mov.w #0x0107, W6 \n" \
|
||||
"mov.w #0x0108, W7 \n" \
|
||||
"mov.w #0x0109, W8 \n" \
|
||||
"mov.w #0x010a, W9 \n" \
|
||||
"mov.w #0x010b, W10 \n" \
|
||||
"mov.w #0x010c, W11 \n" \
|
||||
"mov.w #0x010d, W12 \n" \
|
||||
"mov.w #0x010e, W13 \n" \
|
||||
"mov.w #0x010f, W14 \n" \
|
||||
"sub #0x0101, W0 \n" \
|
||||
"cp0.w W0 \n" \
|
||||
"bra NZ, ERROR_TEST1 \n" \
|
||||
"sub #0x0102, W1 \n" \
|
||||
"cp0.w W1 \n" \
|
||||
"bra NZ, ERROR_TEST1 \n" \
|
||||
"sub #0x0103, W2 \n" \
|
||||
"cp0.w W2 \n" \
|
||||
"bra NZ, ERROR_TEST1 \n" \
|
||||
"sub #0x0104, W3 \n" \
|
||||
"cp0.w W3 \n" \
|
||||
"bra NZ, ERROR_TEST1 \n" \
|
||||
"sub #0x0105, W4 \n" \
|
||||
"cp0.w W4 \n" \
|
||||
"bra NZ, ERROR_TEST1 \n" \
|
||||
"sub #0x0106, W5 \n" \
|
||||
"cp0.w W5 \n" \
|
||||
"bra NZ, ERROR_TEST1 \n" \
|
||||
"sub #0x0107, W6 \n" \
|
||||
"cp0.w W6 \n" \
|
||||
"bra NZ, ERROR_TEST1 \n" \
|
||||
"sub #0x0108, W7 \n" \
|
||||
"cp0.w W7 \n" \
|
||||
"bra NZ, ERROR_TEST1 \n" \
|
||||
"sub #0x0109, W8 \n" \
|
||||
"cp0.w W8 \n" \
|
||||
"bra NZ, ERROR_TEST1 \n" \
|
||||
"sub #0x010a, W9 \n" \
|
||||
"cp0.w W9 \n" \
|
||||
"bra NZ, ERROR_TEST1 \n" \
|
||||
"sub #0x010b, W10 \n" \
|
||||
"cp0.w W10 \n" \
|
||||
"bra NZ, ERROR_TEST1 \n" \
|
||||
"sub #0x010c, W11 \n" \
|
||||
"cp0.w W11 \n" \
|
||||
"bra NZ, ERROR_TEST1 \n" \
|
||||
"sub #0x010d, W12 \n" \
|
||||
"cp0.w W12 \n" \
|
||||
"bra NZ, ERROR_TEST1 \n" \
|
||||
"sub #0x010e, W13 \n" \
|
||||
"cp0.w W13 \n" \
|
||||
"bra NZ, ERROR_TEST1 \n" \
|
||||
"sub #0x010f, W14 \n" \
|
||||
"cp0.w W14 \n" \
|
||||
"bra NZ, ERROR_TEST1 \n" \
|
||||
"bra NO_ERROR1 \n" \
|
||||
"ERROR_TEST1: \n" \
|
||||
"mov.w #1, W0 \n" \
|
||||
"mov.w W0, _usErrorDetected\n" \
|
||||
"NO_ERROR1: \n" );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void xRegisterTest2( void *pvParameters )
|
||||
{
|
||||
/* This static so as not to use the frame pointer. They are volatile
|
||||
also to avoid it being stored in a register that we clobber during the test. */
|
||||
static unsigned portSHORT * volatile pusParameter;
|
||||
|
||||
/* The variable incremented by this task is passed in as the parameter
|
||||
even though it is defined within this file. This is just to test the
|
||||
parameter passing mechanism. */
|
||||
pusParameter = pvParameters;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Increment the variable to show this task is still cycling. */
|
||||
( *pusParameter )++;
|
||||
|
||||
/* Set the w registers to known values, then check that each register
|
||||
contains the expected value. See the explanation at the top of this
|
||||
file for more information. */
|
||||
asm volatile( "mov.w #0x0100, W0 \n" \
|
||||
"mov.w #0x0101, W1 \n" \
|
||||
"mov.w #0x0102, W2 \n" \
|
||||
"mov.w #0x0103, W3 \n" \
|
||||
"mov.w #0x0104, W4 \n" \
|
||||
"mov.w #0x0105, W5 \n" \
|
||||
"mov.w #0x0106, W6 \n" \
|
||||
"mov.w #0x0107, W7 \n" \
|
||||
"mov.w #0x0108, W8 \n" \
|
||||
"mov.w #0x0109, W9 \n" \
|
||||
"mov.w #0x010a, W10 \n" \
|
||||
"mov.w #0x010b, W11 \n" \
|
||||
"mov.w #0x010c, W12 \n" \
|
||||
"mov.w #0x010d, W13 \n" \
|
||||
"mov.w #0x010e, W14 \n" \
|
||||
"sub #0x0100, W0 \n" \
|
||||
"cp0.w W0 \n" \
|
||||
"bra NZ, ERROR_TEST2 \n" \
|
||||
"sub #0x0101, W1 \n" \
|
||||
"cp0.w W1 \n" \
|
||||
"bra NZ, ERROR_TEST2 \n" \
|
||||
"sub #0x0102, W2 \n" \
|
||||
"cp0.w W2 \n" \
|
||||
"bra NZ, ERROR_TEST2 \n" \
|
||||
"sub #0x0103, W3 \n" \
|
||||
"cp0.w W3 \n" \
|
||||
"bra NZ, ERROR_TEST2 \n" \
|
||||
"sub #0x0104, W4 \n" \
|
||||
"cp0.w W4 \n" \
|
||||
"bra NZ, ERROR_TEST2 \n" \
|
||||
"sub #0x0105, W5 \n" \
|
||||
"cp0.w W5 \n" \
|
||||
"bra NZ, ERROR_TEST2 \n" \
|
||||
"sub #0x0106, W6 \n" \
|
||||
"cp0.w W6 \n" \
|
||||
"bra NZ, ERROR_TEST2 \n" \
|
||||
"sub #0x0107, W7 \n" \
|
||||
"cp0.w W7 \n" \
|
||||
"bra NZ, ERROR_TEST2 \n" \
|
||||
"sub #0x0108, W8 \n" \
|
||||
"cp0.w W8 \n" \
|
||||
"bra NZ, ERROR_TEST2 \n" \
|
||||
"sub #0x0109, W9 \n" \
|
||||
"cp0.w W9 \n" \
|
||||
"bra NZ, ERROR_TEST2 \n" \
|
||||
"sub #0x010a, W10 \n" \
|
||||
"cp0.w W10 \n" \
|
||||
"bra NZ, ERROR_TEST2 \n" \
|
||||
"sub #0x010b, W11 \n" \
|
||||
"cp0.w W11 \n" \
|
||||
"bra NZ, ERROR_TEST2 \n" \
|
||||
"sub #0x010c, W12 \n" \
|
||||
"cp0.w W12 \n" \
|
||||
"bra NZ, ERROR_TEST2 \n" \
|
||||
"sub #0x010d, W13 \n" \
|
||||
"cp0.w W13 \n" \
|
||||
"bra NZ, ERROR_TEST2 \n" \
|
||||
"sub #0x010e, W14 \n" \
|
||||
"cp0.w W14 \n" \
|
||||
"bra NZ, ERROR_TEST2 \n" \
|
||||
"bra NO_ERROR2 \n" \
|
||||
"ERROR_TEST2: \n" \
|
||||
"mov.w #1, W0 \n" \
|
||||
"mov.w W0, _usErrorDetected\n" \
|
||||
"NO_ERROR2: \n" );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationIdleHook( void )
|
||||
{
|
||||
/* Schedule the co-routines from within the idle task hook. */
|
||||
vCoRoutineSchedule();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
1986
Demo/dsPIC_MPLAB/p33FJ256GP710.gld
Normal file
1986
Demo/dsPIC_MPLAB/p33FJ256GP710.gld
Normal file
File diff suppressed because it is too large
Load diff
234
Demo/dsPIC_MPLAB/serial/serial.c
Normal file
234
Demo/dsPIC_MPLAB/serial/serial.c
Normal file
|
@ -0,0 +1,234 @@
|
|||
/*
|
||||
FreeRTOS.org V4.1.0 - Copyright (C) 2003-2006 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.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER.
|
||||
|
||||
NOTE: This driver is primarily to test the scheduler functionality. It does
|
||||
not effectively use the buffers or DMA and is therefore not intended to be
|
||||
an example of an efficient driver. */
|
||||
|
||||
/* Standard include file. */
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Scheduler include files. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Demo app include files. */
|
||||
#include "serial.h"
|
||||
|
||||
/* Hardware setup. */
|
||||
#define serOUTPUT 0
|
||||
#define serINPUT 1
|
||||
#define serLOW_SPEED 0
|
||||
#define serONE_STOP_BIT 0
|
||||
#define serEIGHT_DATA_BITS_NO_PARITY 0
|
||||
#define serNORMAL_IDLE_STATE 0
|
||||
#define serAUTO_BAUD_OFF 0
|
||||
#define serLOOPBACK_OFF 0
|
||||
#define serWAKE_UP_DISABLE 0
|
||||
#define serNO_HARDWARE_FLOW_CONTROL 0
|
||||
#define serSTANDARD_IO 0
|
||||
#define serNO_IRDA 0
|
||||
#define serCONTINUE_IN_IDLE_MODE 0
|
||||
#define serUART_ENABLED 1
|
||||
#define serINTERRUPT_ON_SINGLE_CHAR 0
|
||||
#define serTX_ENABLE 1
|
||||
#define serINTERRUPT_ENABLE 1
|
||||
#define serINTERRUPT_DISABLE 0
|
||||
#define serCLEAR_FLAG 0
|
||||
#define serSET_FLAG 1
|
||||
|
||||
|
||||
/* The queues used to communicate between tasks and ISR's. */
|
||||
static xQueueHandle xRxedChars;
|
||||
static xQueueHandle xCharsForTx;
|
||||
|
||||
static portBASE_TYPE xTxHasEnded;
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
xComPortHandle xSerialPortInitMinimal( unsigned portLONG ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
|
||||
{
|
||||
portCHAR cChar;
|
||||
|
||||
/* Create the queues used by the com test task. */
|
||||
xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) );
|
||||
xCharsForTx = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) );
|
||||
|
||||
/* Setup the UART. */
|
||||
U2MODEbits.BRGH = serLOW_SPEED;
|
||||
U2MODEbits.STSEL = serONE_STOP_BIT;
|
||||
U2MODEbits.PDSEL = serEIGHT_DATA_BITS_NO_PARITY;
|
||||
U2MODEbits.ABAUD = serAUTO_BAUD_OFF;
|
||||
U2MODEbits.LPBACK = serLOOPBACK_OFF;
|
||||
U2MODEbits.WAKE = serWAKE_UP_DISABLE;
|
||||
U2MODEbits.UEN = serNO_HARDWARE_FLOW_CONTROL;
|
||||
U2MODEbits.IREN = serNO_IRDA;
|
||||
U2MODEbits.USIDL = serCONTINUE_IN_IDLE_MODE;
|
||||
U2MODEbits.UARTEN = serUART_ENABLED;
|
||||
|
||||
U2BRG = (unsigned portSHORT)(( (float)configCPU_CLOCK_HZ / ( (float)16 * (float)ulWantedBaud ) ) - (float)0.5);
|
||||
|
||||
U2STAbits.URXISEL = serINTERRUPT_ON_SINGLE_CHAR;
|
||||
U2STAbits.UTXEN = serTX_ENABLE;
|
||||
U2STAbits.UTXINV = serNORMAL_IDLE_STATE;
|
||||
U2STAbits.UTXISEL0 = serINTERRUPT_ON_SINGLE_CHAR;
|
||||
U2STAbits.UTXISEL1 = serINTERRUPT_ON_SINGLE_CHAR;
|
||||
|
||||
/* It is assumed that this function is called prior to the scheduler being
|
||||
started. Therefore interrupts must not be allowed to occur yet as they
|
||||
may attempt to perform a context switch. */
|
||||
portDISABLE_INTERRUPTS();
|
||||
|
||||
IFS1bits.U2RXIF = serCLEAR_FLAG;
|
||||
IFS1bits.U2TXIF = serCLEAR_FLAG;
|
||||
IPC7bits.U2RXIP = portKERNEL_INTERRUPT_PRIORITY;
|
||||
IPC7bits.U2TXIP = portKERNEL_INTERRUPT_PRIORITY;
|
||||
IEC1bits.U2TXIE = serINTERRUPT_ENABLE;
|
||||
IEC1bits.U2RXIE = serINTERRUPT_ENABLE;
|
||||
|
||||
/* Clear the Rx buffer. */
|
||||
while( U2STAbits.URXDA == serSET_FLAG )
|
||||
{
|
||||
cChar = U2RXREG;
|
||||
}
|
||||
|
||||
xTxHasEnded = pdTRUE;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed portCHAR *pcRxedChar, portTickType xBlockTime )
|
||||
{
|
||||
/* Only one port is supported. */
|
||||
( void ) pxPort;
|
||||
|
||||
/* Get the next character from the buffer. Return false if no characters
|
||||
are available or arrive before xBlockTime expires. */
|
||||
if( xQueueReceive( xRxedChars, pcRxedChar, xBlockTime ) )
|
||||
{
|
||||
return pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return pdFALSE;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed portCHAR cOutChar, portTickType xBlockTime )
|
||||
{
|
||||
/* Only one port is supported. */
|
||||
( void ) pxPort;
|
||||
|
||||
/* Return false if after the block time there is no room on the Tx queue. */
|
||||
if( xQueueSend( xCharsForTx, &cOutChar, xBlockTime ) != pdPASS )
|
||||
{
|
||||
return pdFAIL;
|
||||
}
|
||||
|
||||
/* A critical section should not be required as xTxHasEnded will not be
|
||||
written to by the ISR if it is already 0 (is this correct?). */
|
||||
if( xTxHasEnded )
|
||||
{
|
||||
xTxHasEnded = pdFALSE;
|
||||
IFS1bits.U2TXIF = serSET_FLAG;
|
||||
}
|
||||
|
||||
return pdPASS;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vSerialClose( xComPortHandle xPort )
|
||||
{
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
volatile short s = 0;
|
||||
char c[80] = {0};
|
||||
|
||||
void __attribute__((__interrupt__)) _U2RXInterrupt( void )
|
||||
{
|
||||
portCHAR cChar;
|
||||
portBASE_TYPE xYieldRequired = pdFALSE;
|
||||
|
||||
/* 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. */
|
||||
IFS1bits.U2RXIF = serCLEAR_FLAG;
|
||||
while( U2STAbits.URXDA )
|
||||
{
|
||||
cChar = U2RXREG;
|
||||
xYieldRequired = xQueueSendFromISR( xRxedChars, &cChar, xYieldRequired );
|
||||
}
|
||||
|
||||
if( xYieldRequired != pdFALSE )
|
||||
{
|
||||
taskYIELD();
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void __attribute__((__interrupt__)) _U2TXInterrupt( void )
|
||||
{
|
||||
signed portCHAR cChar;
|
||||
portBASE_TYPE xTaskWoken = pdFALSE;
|
||||
|
||||
/* If the transmit buffer is full we cannot get the next character.
|
||||
Another interrupt will occur the next time there is space so this does
|
||||
not matter. */
|
||||
IFS1bits.U2TXIF = serCLEAR_FLAG;
|
||||
while( !( U2STAbits.UTXBF ) )
|
||||
{
|
||||
if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xTaskWoken ) == pdTRUE )
|
||||
{
|
||||
/* Send the next character queued for Tx. */
|
||||
U2TXREG = cChar;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Queue empty, nothing to send. */
|
||||
xTxHasEnded = pdTRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( xTaskWoken != pdFALSE )
|
||||
{
|
||||
taskYIELD();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue