mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-09-07 06:37:47 -04:00
Before changing headers to V6 and changing portLONG, portSHORt and portCHAR to their standard C types.
This commit is contained in:
parent
3dfbb349ca
commit
5c64e1fad9
4417 changed files with 1261274 additions and 0 deletions
109
20091005/Demo/PIC32MX_MPLAB/FreeRTOSConfig.h
Normal file
109
20091005/Demo/PIC32MX_MPLAB/FreeRTOSConfig.h
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
FreeRTOS V5.4.2 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation and modified by the FreeRTOS exception.
|
||||
**NOTE** The exception to the GPL is included to allow you to distribute a
|
||||
combined work that includes FreeRTOS without being obliged to provide the
|
||||
source code for proprietary components outside of the FreeRTOS kernel.
|
||||
Alternative commercial license and support terms are also available upon
|
||||
request. See the licensing section of http://www.FreeRTOS.org for full
|
||||
license details.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Looking for a quick start? Then check out the FreeRTOS eBook! *
|
||||
* See http://www.FreeRTOS.org/Documentation for details *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
contact details.
|
||||
|
||||
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||
critical systems.
|
||||
|
||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
licensing and training services.
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
#include <p32xxxx.h>
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions.
|
||||
*
|
||||
* These definitions should be adjusted for your particular hardware and
|
||||
* application requirements.
|
||||
*
|
||||
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
|
||||
*
|
||||
* See http://www.freertos.org/a00110.html.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_IDLE_HOOK 0
|
||||
#define configUSE_TICK_HOOK 0
|
||||
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
|
||||
#define configCPU_CLOCK_HZ ( ( unsigned portLONG ) 80000000UL )
|
||||
#define configPERIPHERAL_CLOCK_HZ ( ( unsigned portLONG ) 40000000UL )
|
||||
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 )
|
||||
#define configMINIMAL_STACK_SIZE ( 190 )
|
||||
#define configISR_STACK_SIZE ( 400 )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) 28000 )
|
||||
#define configMAX_TASK_NAME_LEN ( 8 )
|
||||
#define configUSE_TRACE_FACILITY 0
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||
#define configQUEUE_REGISTRY_SIZE 0
|
||||
|
||||
/* Co-routine definitions. */
|
||||
#define configUSE_CO_ROUTINES 0
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
/* Set the following definitions to 1 to include the API function, or zero
|
||||
to exclude the API function. */
|
||||
|
||||
#define INCLUDE_vTaskPrioritySet 1
|
||||
#define INCLUDE_uxTaskPriorityGet 1
|
||||
#define INCLUDE_vTaskDelete 0
|
||||
#define INCLUDE_vTaskCleanUpResources 0
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||
|
||||
/* The priority at which the tick interrupt runs. This should probably be
|
||||
kept at 1. */
|
||||
#define configKERNEL_INTERRUPT_PRIORITY 0x01
|
||||
|
||||
/* The maximum interrupt priority from which FreeRTOS.org API functions can
|
||||
be called. Only API functions that end in ...FromISR() can be used within
|
||||
interrupts. */
|
||||
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 0x03
|
||||
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
115
20091005/Demo/PIC32MX_MPLAB/IntQueueTimer.c
Normal file
115
20091005/Demo/PIC32MX_MPLAB/IntQueueTimer.c
Normal file
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
FreeRTOS V5.4.2 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation and modified by the FreeRTOS exception.
|
||||
**NOTE** The exception to the GPL is included to allow you to distribute a
|
||||
combined work that includes FreeRTOS without being obliged to provide the
|
||||
source code for proprietary components outside of the FreeRTOS kernel.
|
||||
Alternative commercial license and support terms are also available upon
|
||||
request. See the licensing section of http://www.FreeRTOS.org for full
|
||||
license details.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Looking for a quick start? Then check out the FreeRTOS eBook! *
|
||||
* See http://www.FreeRTOS.org/Documentation for details *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
contact details.
|
||||
|
||||
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||
critical systems.
|
||||
|
||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
licensing and training services.
|
||||
*/
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "IntQueueTimer.h"
|
||||
#include "IntQueue.h"
|
||||
|
||||
#define timerINTERRUPT3_FREQUENCY ( 2000UL )
|
||||
#define timerINTERRUPT4_FREQUENCY ( 2001UL )
|
||||
|
||||
void vT3InterruptHandler( void );
|
||||
void vT4InterruptHandler( void );
|
||||
|
||||
void __attribute__( (interrupt(ipl0), vector(_TIMER_3_VECTOR))) vT3InterruptWrapper( void );
|
||||
void __attribute__( (interrupt(ipl0), vector(_TIMER_4_VECTOR))) vT4InterruptWrapper( void );
|
||||
|
||||
void vInitialiseTimerForIntQueueTest( void )
|
||||
{
|
||||
/* Timer 1 is used for the tick interrupt, timer 2 is used for the high
|
||||
frequency interrupt test. This file therefore uses timers 3 and 4. */
|
||||
|
||||
T3CON = 0;
|
||||
TMR3 = 0;
|
||||
PR3 = ( unsigned portSHORT ) ( configPERIPHERAL_CLOCK_HZ / timerINTERRUPT3_FREQUENCY );
|
||||
|
||||
/* Setup timer 3 interrupt priority to be above the kernel priority. */
|
||||
ConfigIntTimer3( T3_INT_ON | ( configMAX_SYSCALL_INTERRUPT_PRIORITY - 1 ) );
|
||||
|
||||
/* Clear the interrupt as a starting condition. */
|
||||
IFS0bits.T3IF = 0;
|
||||
|
||||
/* Enable the interrupt. */
|
||||
IEC0bits.T3IE = 1;
|
||||
|
||||
/* Start the timer. */
|
||||
T3CONbits.TON = 1;
|
||||
|
||||
|
||||
/* Do the same for timer 4. */
|
||||
T4CON = 0;
|
||||
TMR4 = 0;
|
||||
PR4 = ( unsigned portSHORT ) ( configPERIPHERAL_CLOCK_HZ / timerINTERRUPT4_FREQUENCY );
|
||||
|
||||
/* Setup timer 4 interrupt priority to be above the kernel priority. */
|
||||
ConfigIntTimer4( T4_INT_ON | ( configMAX_SYSCALL_INTERRUPT_PRIORITY ) );
|
||||
|
||||
/* Clear the interrupt as a starting condition. */
|
||||
IFS0bits.T4IF = 0;
|
||||
|
||||
/* Enable the interrupt. */
|
||||
IEC0bits.T4IE = 1;
|
||||
|
||||
/* Start the timer. */
|
||||
T4CONbits.TON = 1;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vT3InterruptHandler( void )
|
||||
{
|
||||
IFS0bits.T3IF = 0;
|
||||
portEND_SWITCHING_ISR( xFirstTimerHandler() );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vT4InterruptHandler( void )
|
||||
{
|
||||
IFS0bits.T4IF = 0;
|
||||
portEND_SWITCHING_ISR( xSecondTimerHandler() );
|
||||
}
|
||||
|
||||
|
56
20091005/Demo/PIC32MX_MPLAB/IntQueueTimer.h
Normal file
56
20091005/Demo/PIC32MX_MPLAB/IntQueueTimer.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
FreeRTOS V5.4.2 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation and modified by the FreeRTOS exception.
|
||||
**NOTE** The exception to the GPL is included to allow you to distribute a
|
||||
combined work that includes FreeRTOS without being obliged to provide the
|
||||
source code for proprietary components outside of the FreeRTOS kernel.
|
||||
Alternative commercial license and support terms are also available upon
|
||||
request. See the licensing section of http://www.FreeRTOS.org for full
|
||||
license details.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Looking for a quick start? Then check out the FreeRTOS eBook! *
|
||||
* See http://www.FreeRTOS.org/Documentation for details *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
contact details.
|
||||
|
||||
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||
critical systems.
|
||||
|
||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
licensing and training services.
|
||||
*/
|
||||
|
||||
#ifndef INT_QUEUE_TIMER_H
|
||||
#define INT_QUEUE_TIMER_H
|
||||
|
||||
void vInitialiseTimerForIntQueueTest( void );
|
||||
portBASE_TYPE xTimer0Handler( void );
|
||||
portBASE_TYPE xTimer1Handler( void );
|
||||
|
||||
#endif
|
||||
|
100
20091005/Demo/PIC32MX_MPLAB/IntQueueTimer_isr.S
Normal file
100
20091005/Demo/PIC32MX_MPLAB/IntQueueTimer_isr.S
Normal file
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
FreeRTOS V5.4.2 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation and modified by the FreeRTOS exception.
|
||||
**NOTE** The exception to the GPL is included to allow you to distribute a
|
||||
combined work that includes FreeRTOS without being obliged to provide the
|
||||
source code for proprietary components outside of the FreeRTOS kernel.
|
||||
Alternative commercial license and support terms are also available upon
|
||||
request. See the licensing section of http://www.FreeRTOS.org for full
|
||||
license details.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Looking for a quick start? Then check out the FreeRTOS eBook! *
|
||||
* See http://www.FreeRTOS.org/Documentation for details *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
contact details.
|
||||
|
||||
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||
critical systems.
|
||||
|
||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
licensing and training services.
|
||||
*/
|
||||
|
||||
#include <p32xxxx.h>
|
||||
#include <sys/asm.h>
|
||||
#include "ISR_Support.h"
|
||||
|
||||
#define portEXC_CODE_MASK ( 0x1f << 2 )
|
||||
|
||||
.set nomips16
|
||||
.set noreorder
|
||||
|
||||
.extern vT3InterruptHandler
|
||||
.extern vT4InterruptHandler
|
||||
|
||||
|
||||
.global vT3InterruptWrapper
|
||||
.global vT4InterruptWrapper
|
||||
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
.section .FreeRTOS, "ax", @progbits
|
||||
.set noreorder
|
||||
.set noat
|
||||
.ent vT3InterruptWrapper
|
||||
|
||||
vT3InterruptWrapper:
|
||||
|
||||
portSAVE_CONTEXT
|
||||
|
||||
jal vT3InterruptHandler
|
||||
nop
|
||||
|
||||
portRESTORE_CONTEXT
|
||||
|
||||
.end vT3InterruptWrapper
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
.section .FreeRTOS, "ax", @progbits
|
||||
.set noreorder
|
||||
.set noat
|
||||
.ent vT4InterruptWrapper
|
||||
|
||||
vT4InterruptWrapper:
|
||||
|
||||
portSAVE_CONTEXT
|
||||
|
||||
jal vT4InterruptHandler
|
||||
nop
|
||||
|
||||
portRESTORE_CONTEXT
|
||||
|
||||
.end vT4InterruptWrapper
|
||||
|
104
20091005/Demo/PIC32MX_MPLAB/ParTest/ParTest.c
Normal file
104
20091005/Demo/PIC32MX_MPLAB/ParTest/ParTest.c
Normal file
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
FreeRTOS V5.4.2 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation and modified by the FreeRTOS exception.
|
||||
**NOTE** The exception to the GPL is included to allow you to distribute a
|
||||
combined work that includes FreeRTOS without being obliged to provide the
|
||||
source code for proprietary components outside of the FreeRTOS kernel.
|
||||
Alternative commercial license and support terms are also available upon
|
||||
request. See the licensing section of http://www.FreeRTOS.org for full
|
||||
license details.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Looking for a quick start? Then check out the FreeRTOS eBook! *
|
||||
* See http://www.FreeRTOS.org/Documentation for details *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
contact details.
|
||||
|
||||
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||
critical systems.
|
||||
|
||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
licensing and training services.
|
||||
*/
|
||||
|
||||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
/* Demo app includes. */
|
||||
#include "partest.h"
|
||||
|
||||
#define ptOUTPUT 0
|
||||
#define ptALL_OFF 0
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Simple parallel port IO routines.
|
||||
*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestInitialise( void )
|
||||
{
|
||||
/* All LEDs output. */
|
||||
TRISA = ptOUTPUT;
|
||||
PORTA = ptALL_OFF;
|
||||
|
||||
mJTAGPortEnable( 0 );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
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. Use of the PORTASET register removes the need
|
||||
to use a critical section. */
|
||||
PORTASET = uxLEDBit;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Turn the LED off. Use of the PORTACLR register removes the need
|
||||
to use a critical section. */
|
||||
PORTACLR = uxLEDBit;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
|
||||
{
|
||||
unsigned portBASE_TYPE uxLEDBit;
|
||||
|
||||
uxLEDBit = 1 << uxLED;
|
||||
|
||||
/* Use of the PORTAINV register removes the need to use a critical section. */
|
||||
PORTAINV = uxLEDBit;
|
||||
}
|
||||
|
||||
|
||||
|
185
20091005/Demo/PIC32MX_MPLAB/RTOSDemo.mcp
Normal file
185
20091005/Demo/PIC32MX_MPLAB/RTOSDemo.mcp
Normal file
|
@ -0,0 +1,185 @@
|
|||
[HEADER]
|
||||
magic_cookie={66E99B07-E706-4689-9E80-9B2582898A13}
|
||||
file_version=1.0
|
||||
[PATH_INFO]
|
||||
BuildDirPolicy=BuildDirIsProjectDir
|
||||
dir_src=
|
||||
dir_bin=
|
||||
dir_tmp=
|
||||
dir_sin=..\..\Source\portable\MPLAB\PIC32MX;.
|
||||
dir_inc=.;.;..\common\include;..\..\source\portable\mplab\pic32mx;..\..\source\include
|
||||
dir_lib=
|
||||
dir_lkr=
|
||||
[CAT_FILTERS]
|
||||
filter_src=*.s;*.c
|
||||
filter_inc=*.h;*.inc
|
||||
filter_obj=*.o
|
||||
filter_lib=*.a
|
||||
filter_lkr=*.ld
|
||||
[CAT_SUBFOLDERS]
|
||||
subfolder_src=
|
||||
subfolder_inc=
|
||||
subfolder_obj=
|
||||
subfolder_lib=
|
||||
subfolder_lkr=
|
||||
[FILE_SUBFOLDERS]
|
||||
file_000=.
|
||||
file_001=.
|
||||
file_002=.
|
||||
file_003=.
|
||||
file_004=.
|
||||
file_005=.
|
||||
file_006=.
|
||||
file_007=.
|
||||
file_008=.
|
||||
file_009=.
|
||||
file_010=.
|
||||
file_011=.
|
||||
file_012=.
|
||||
file_013=.
|
||||
file_014=.
|
||||
file_015=.
|
||||
file_016=.
|
||||
file_017=.
|
||||
file_018=.
|
||||
file_019=.
|
||||
file_020=.
|
||||
file_021=.
|
||||
file_022=.
|
||||
file_023=.
|
||||
file_024=.
|
||||
file_025=.
|
||||
file_026=.
|
||||
file_027=.
|
||||
file_028=.
|
||||
file_029=.
|
||||
file_030=.
|
||||
file_031=.
|
||||
file_032=.
|
||||
file_033=.
|
||||
file_034=.
|
||||
[GENERATED_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_021=no
|
||||
file_022=no
|
||||
file_023=no
|
||||
file_024=no
|
||||
file_025=no
|
||||
file_026=no
|
||||
file_027=no
|
||||
file_028=no
|
||||
file_029=no
|
||||
file_030=no
|
||||
file_031=no
|
||||
file_032=no
|
||||
file_033=no
|
||||
file_034=no
|
||||
[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_021=no
|
||||
file_022=no
|
||||
file_023=no
|
||||
file_024=no
|
||||
file_025=no
|
||||
file_026=no
|
||||
file_027=no
|
||||
file_028=no
|
||||
file_029=no
|
||||
file_030=no
|
||||
file_031=no
|
||||
file_032=no
|
||||
file_033=no
|
||||
file_034=yes
|
||||
[FILE_INFO]
|
||||
file_000=main.c
|
||||
file_001=ParTest\ParTest.c
|
||||
file_002=..\..\Source\portable\MPLAB\PIC32MX\port.c
|
||||
file_003=..\..\Source\list.c
|
||||
file_004=..\..\Source\queue.c
|
||||
file_005=..\..\Source\tasks.c
|
||||
file_006=..\..\Source\portable\MPLAB\PIC32MX\port_asm.S
|
||||
file_007=RegisterTestTasks.s
|
||||
file_008=..\..\Source\portable\MemMang\heap_2.c
|
||||
file_009=..\Common\Minimal\flash.c
|
||||
file_010=..\Common\Minimal\QPeek.c
|
||||
file_011=..\Common\Minimal\semtest.c
|
||||
file_012=..\Common\Minimal\GenQTest.c
|
||||
file_013=..\Common\Minimal\blocktim.c
|
||||
file_014=lcd.c
|
||||
file_015=serial\serial.c
|
||||
file_016=..\Common\Minimal\comtest.c
|
||||
file_017=serial\serial_isr.S
|
||||
file_018=timertest.c
|
||||
file_019=timertest_isr.S
|
||||
file_020=..\Common\Minimal\IntQueue.c
|
||||
file_021=IntQueueTimer.c
|
||||
file_022=IntQueueTimer_isr.S
|
||||
file_023=printf-stdarg.c
|
||||
file_024=FreeRTOSConfig.h
|
||||
file_025=..\..\Source\portable\MPLAB\PIC32MX\portmacro.h
|
||||
file_026=..\..\Source\include\portable.h
|
||||
file_027=..\..\Source\include\task.h
|
||||
file_028=..\..\Source\include\croutine.h
|
||||
file_029=..\..\Source\include\FreeRTOS.h
|
||||
file_030=..\..\Source\include\list.h
|
||||
file_031=..\..\Source\include\projdefs.h
|
||||
file_032=..\..\Source\include\queue.h
|
||||
file_033=..\..\Source\include\semphr.h
|
||||
file_034=PIC32MX_MPLAB.map
|
||||
[SUITE_INFO]
|
||||
suite_guid={14495C23-81F8-43F3-8A44-859C583D7760}
|
||||
suite_state=
|
||||
[TOOL_SETTINGS]
|
||||
TS{CB0AF4B8-4022-429D-8F99-8A56782B2C6D}=--keep-locals --gdwarf-2
|
||||
TS{9C698E0A-CBC9-4EFF-AE7D-B569F93E7322}=-g -DMPLAB_PIC32MX_PORT -Wall -fomit-frame-pointer
|
||||
TS{77F59DA1-3C53-4677-AC5F-A03EB0125170}=--defsym=_min_heap_size=0 --defsym=_min_heap_size=0 -Map="$(BINDIR_)$(TARGETBASE).map" -o"$(BINDIR_)$(TARGETBASE).$(TARGETSUFFIX)" -O3
|
||||
TS{0396C0A1-9052-4E4F-8B84-EF0162B1B4E9}=
|
||||
[INSTRUMENTED_TRACE]
|
||||
enable=0
|
||||
transport=0
|
||||
format=0
|
||||
[CUSTOM_BUILD]
|
||||
Pre-Build=
|
||||
Pre-BuildEnabled=1
|
||||
Post-Build=
|
||||
Post-BuildEnabled=1
|
7
20091005/Demo/PIC32MX_MPLAB/RTOSDemo.mcs
Normal file
7
20091005/Demo/PIC32MX_MPLAB/RTOSDemo.mcs
Normal file
|
@ -0,0 +1,7 @@
|
|||
[Header]
|
||||
MagicCookie={0b13fe8c-dfe0-40eb-8900-6712719559a7}
|
||||
Version=1.0
|
||||
[TOOL_LOC_STAMPS]
|
||||
tool_loc{92E15EC6-5E91-4BF4-B5FA-C80AD2601AA7}=C:\Devtools\Microchip\MPLAB C32\bin\pic32-as.exe
|
||||
tool_loc{430F471F-7ECB-4852-A80D-DEF9A5C8E751}=C:\Devtools\Microchip\MPLAB C32\bin\pic32-gcc.exe
|
||||
tool_loc{C68E5105-1196-4333-A0BF-3DC57271E614}=C:\Devtools\Microchip\MPLAB C32\bin\pic32-ld.exe
|
BIN
20091005/Demo/PIC32MX_MPLAB/RTOSDemo.mcw
Normal file
BIN
20091005/Demo/PIC32MX_MPLAB/RTOSDemo.mcw
Normal file
Binary file not shown.
336
20091005/Demo/PIC32MX_MPLAB/RegisterTestTasks.s
Normal file
336
20091005/Demo/PIC32MX_MPLAB/RegisterTestTasks.s
Normal file
|
@ -0,0 +1,336 @@
|
|||
/*
|
||||
FreeRTOS V5.4.2 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation and modified by the FreeRTOS exception.
|
||||
**NOTE** The exception to the GPL is included to allow you to distribute a
|
||||
combined work that includes FreeRTOS without being obliged to provide the
|
||||
source code for proprietary components outside of the FreeRTOS kernel.
|
||||
Alternative commercial license and support terms are also available upon
|
||||
request. See the licensing section of http://www.FreeRTOS.org for full
|
||||
license details.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Looking for a quick start? Then check out the FreeRTOS eBook! *
|
||||
* See http://www.FreeRTOS.org/Documentation for details *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
contact details.
|
||||
|
||||
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||
critical systems.
|
||||
|
||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
licensing and training services.
|
||||
*/
|
||||
|
||||
|
||||
#include <p32xxxx.h>
|
||||
#include <sys/asm.h>
|
||||
|
||||
.set nomips16
|
||||
.set noreorder
|
||||
|
||||
|
||||
.global vRegTest1
|
||||
.global vRegTest2
|
||||
|
||||
|
||||
/* .section .FreeRTOS, ax, @progbits */
|
||||
.set noreorder
|
||||
.set noat
|
||||
.ent vRegTest1
|
||||
|
||||
/* Address of $4 ulStatus1 is held in A0, so don't mess with the value of $4 */
|
||||
|
||||
vRegTest1:
|
||||
addiu $1, $0, 0x11
|
||||
addiu $2, $0, 0x12
|
||||
addiu $3, $0, 0x13
|
||||
addiu $5, $0, 0x15
|
||||
addiu $6, $0, 0x16
|
||||
addiu $7, $0, 0x17
|
||||
addiu $8, $0, 0x18
|
||||
addiu $9, $0, 0x19
|
||||
addiu $10, $0, 0x110
|
||||
addiu $11, $0, 0x111
|
||||
addiu $12, $0, 0x112
|
||||
addiu $13, $0, 0x113
|
||||
addiu $14, $0, 0x114
|
||||
addiu $15, $0, 0x115
|
||||
addiu $16, $0, 0x116
|
||||
addiu $17, $0, 0x117
|
||||
addiu $18, $0, 0x118
|
||||
addiu $19, $0, 0x119
|
||||
addiu $20, $0, 0x120
|
||||
addiu $21, $0, 0x121
|
||||
addiu $22, $0, 0x122
|
||||
addiu $23, $0, 0x123
|
||||
addiu $24, $0, 0x124
|
||||
addiu $25, $0, 0x125
|
||||
addiu $30, $0, 0x130
|
||||
|
||||
addiu $1, $1, -0x11
|
||||
beq $1, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $2, $2, -0x12
|
||||
beq $2, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $3, $3, -0x13
|
||||
beq $3, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $5, $5, -0x15
|
||||
beq $5, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $6, $6, -0x16
|
||||
beq $6, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $7, $7, -0x17
|
||||
beq $7, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $8, $8, -0x18
|
||||
beq $8, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $9, $9, -0x19
|
||||
beq $9, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $10, $10, -0x110
|
||||
beq $10, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $11, $11, -0x111
|
||||
beq $11, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $12, $12, -0x112
|
||||
beq $12, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $13, $13, -0x113
|
||||
beq $13, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $14, $14, -0x114
|
||||
beq $14, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $15, $15, -0x115
|
||||
beq $15, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $16, $16, -0x116
|
||||
beq $16, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $17, $17, -0x117
|
||||
beq $17, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $18, $18, -0x118
|
||||
beq $18, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $19, $19, -0x119
|
||||
beq $19, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $20, $20, -0x120
|
||||
beq $20, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $21, $21, -0x121
|
||||
beq $21, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $22, $22, -0x122
|
||||
beq $22, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $23, $23, -0x123
|
||||
beq $23, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $24, $24, -0x124
|
||||
beq $24, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $25, $25, -0x125
|
||||
beq $25, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $30, $30, -0x130
|
||||
beq $30, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
jr $31
|
||||
nop
|
||||
|
||||
.end vRegTest1
|
||||
|
||||
|
||||
/* .section .FreeRTOS, ax, @progbits */
|
||||
.set noreorder
|
||||
.set noat
|
||||
.ent vRegTest2
|
||||
|
||||
vRegTest2:
|
||||
|
||||
addiu $1, $0, 0x10
|
||||
addiu $2, $0, 0x20
|
||||
addiu $3, $0, 0x30
|
||||
addiu $5, $0, 0x50
|
||||
addiu $6, $0, 0x60
|
||||
addiu $7, $0, 0x70
|
||||
addiu $8, $0, 0x80
|
||||
addiu $9, $0, 0x90
|
||||
addiu $10, $0, 0x100
|
||||
addiu $11, $0, 0x110
|
||||
addiu $12, $0, 0x120
|
||||
addiu $13, $0, 0x130
|
||||
addiu $14, $0, 0x140
|
||||
addiu $15, $0, 0x150
|
||||
addiu $16, $0, 0x160
|
||||
addiu $17, $0, 0x170
|
||||
addiu $18, $0, 0x180
|
||||
addiu $19, $0, 0x190
|
||||
addiu $20, $0, 0x200
|
||||
addiu $21, $0, 0x210
|
||||
addiu $22, $0, 0x220
|
||||
addiu $23, $0, 0x230
|
||||
addiu $24, $0, 0x240
|
||||
addiu $25, $0, 0x250
|
||||
addiu $30, $0, 0x300
|
||||
|
||||
addiu $1, $1, -0x10
|
||||
beq $1, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $2, $2, -0x20
|
||||
beq $2, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $3, $3, -0x30
|
||||
beq $3, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $5, $5, -0x50
|
||||
beq $5, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $6, $6, -0x60
|
||||
beq $6, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $7, $7, -0x70
|
||||
beq $7, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $8, $8, -0x80
|
||||
beq $8, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $9, $9, -0x90
|
||||
beq $9, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $10, $10, -0x100
|
||||
beq $10, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $11, $11, -0x110
|
||||
beq $11, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $12, $12, -0x120
|
||||
beq $12, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $13, $13, -0x130
|
||||
beq $13, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $14, $14, -0x140
|
||||
beq $14, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $15, $15, -0x150
|
||||
beq $15, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $16, $16, -0x160
|
||||
beq $16, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $17, $17, -0x170
|
||||
beq $17, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $18, $18, -0x180
|
||||
beq $18, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $19, $19, -0x190
|
||||
beq $19, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $20, $20, -0x200
|
||||
beq $20, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $21, $21, -0x210
|
||||
beq $21, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $22, $22, -0x220
|
||||
beq $22, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $23, $23, -0x230
|
||||
beq $23, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $24, $24, -0x240
|
||||
beq $24, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $25, $25, -0x250
|
||||
beq $25, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
addiu $30, $30, -0x300
|
||||
beq $30, $0, .+12
|
||||
nop
|
||||
sw $0, 0($4)
|
||||
jr $31
|
||||
nop
|
||||
|
||||
.end vRegTest2
|
254
20091005/Demo/PIC32MX_MPLAB/lcd.c
Normal file
254
20091005/Demo/PIC32MX_MPLAB/lcd.c
Normal file
|
@ -0,0 +1,254 @@
|
|||
/*
|
||||
FreeRTOS V5.4.2 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation and modified by the FreeRTOS exception.
|
||||
**NOTE** The exception to the GPL is included to allow you to distribute a
|
||||
combined work that includes FreeRTOS without being obliged to provide the
|
||||
source code for proprietary components outside of the FreeRTOS kernel.
|
||||
Alternative commercial license and support terms are also available upon
|
||||
request. See the licensing section of http://www.FreeRTOS.org for full
|
||||
license details.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Looking for a quick start? Then check out the FreeRTOS eBook! *
|
||||
* See http://www.FreeRTOS.org/Documentation for details *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
contact details.
|
||||
|
||||
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||
critical systems.
|
||||
|
||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
licensing and training services.
|
||||
*/
|
||||
|
||||
/* peripheral library include */
|
||||
#include <plib.h>
|
||||
|
||||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* Demo includes. */
|
||||
#include "lcd.h"
|
||||
|
||||
/*
|
||||
* The LCD is written to by more than one task so is controlled by this
|
||||
* 'gatekeeper' task. This is the only task that is actually permitted to
|
||||
* access the LCD directly. Other tasks wanting to display a message send
|
||||
* the message to the gatekeeper.
|
||||
*/
|
||||
static void vLCDTask( void *pvParameters );
|
||||
|
||||
/*
|
||||
* Setup the peripherals required to communicate with the LCD.
|
||||
*/
|
||||
static void prvSetupLCD( void );
|
||||
|
||||
/*
|
||||
* Move to the first (0) or second (1) row of the LCD.
|
||||
*/
|
||||
static void prvLCDGotoRow( unsigned portSHORT usRow );
|
||||
|
||||
/*
|
||||
* Write a string of text to the LCD.
|
||||
*/
|
||||
static void prvLCDPutString( portCHAR *pcString );
|
||||
|
||||
/*
|
||||
* Clear the LCD.
|
||||
*/
|
||||
static void prvLCDClear( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Brief delay to permit the LCD to catch up with commands. */
|
||||
#define lcdVERY_SHORT_DELAY ( 1 )
|
||||
#define lcdSHORT_DELAY ( 4 / portTICK_RATE_MS )
|
||||
#define lcdLONG_DELAY ( 15 / portTICK_RATE_MS )
|
||||
|
||||
/* LCD specific definitions. */
|
||||
#define LCD_CLEAR_DISPLAY_CMD 0x01
|
||||
#define LCD_CURSOR_HOME_CMD 0x02
|
||||
#define LCD_ENTRY_MODE_CMD 0x04
|
||||
#define LCD_ENTRY_MODE_INCREASE 0x02
|
||||
#define LCD_DISPLAY_CTRL_CMD 0x08
|
||||
#define LCD_DISPLAY_CTRL_DISPLAY_ON 0x04
|
||||
#define LCD_FUNCTION_SET_CMD 0x20
|
||||
#define LCD_FUNCTION_SET_8_BITS 0x10
|
||||
#define LCD_FUNCTION_SET_2_LINES 0x08
|
||||
#define LCD_FUNCTION_SET_LRG_FONT 0x04
|
||||
#define LCD_NEW_LINE 0xC0
|
||||
#define LCD_COMMAND_ADDRESS 0x00
|
||||
#define LCD_DATA_ADDRESS 0x01
|
||||
|
||||
/* The length of the queue used to send messages to the LCD gatekeeper task. */
|
||||
#define lcdQUEUE_SIZE 3
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The queue used to send messages to the LCD task. */
|
||||
xQueueHandle xLCDQueue;
|
||||
|
||||
/* LCD access functions. */
|
||||
static void prvLCDCommand( portCHAR cCommand );
|
||||
static void prvLCDData( portCHAR cChar );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
xQueueHandle xStartLCDTask( void )
|
||||
{
|
||||
/* Create the queue used by the LCD task. Messages for display on the LCD
|
||||
are received via this queue. */
|
||||
xLCDQueue = xQueueCreate( lcdQUEUE_SIZE, sizeof( xLCDMessage ));
|
||||
|
||||
/* Start the task that will write to the LCD. The LCD hardware is
|
||||
initialised from within the task itself so delays can be used. */
|
||||
xTaskCreate( vLCDTask, ( signed portCHAR * ) "LCD", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
|
||||
|
||||
return xLCDQueue;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvLCDGotoRow( unsigned portSHORT usRow )
|
||||
{
|
||||
if(usRow == 0)
|
||||
{
|
||||
prvLCDCommand( LCD_CURSOR_HOME_CMD );
|
||||
}
|
||||
else
|
||||
{
|
||||
prvLCDCommand( LCD_NEW_LINE );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvLCDCommand( portCHAR cCommand )
|
||||
{
|
||||
PMPSetAddress( LCD_COMMAND_ADDRESS );
|
||||
PMPMasterWrite( cCommand );
|
||||
vTaskDelay( lcdSHORT_DELAY );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvLCDData( portCHAR cChar )
|
||||
{
|
||||
PMPSetAddress( LCD_DATA_ADDRESS );
|
||||
PMPMasterWrite( cChar );
|
||||
vTaskDelay( lcdVERY_SHORT_DELAY );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvLCDPutString( portCHAR *pcString )
|
||||
{
|
||||
/* Write out each character with appropriate delay between each. */
|
||||
while(*pcString)
|
||||
{
|
||||
prvLCDData(*pcString);
|
||||
pcString++;
|
||||
vTaskDelay(lcdSHORT_DELAY);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvLCDClear(void)
|
||||
{
|
||||
prvLCDCommand(LCD_CLEAR_DISPLAY_CMD);
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSetupLCD(void)
|
||||
{
|
||||
/* Wait for proper power up. */
|
||||
vTaskDelay( lcdLONG_DELAY );
|
||||
|
||||
/* Open the PMP port */
|
||||
mPMPOpen((PMP_ON | PMP_READ_WRITE_EN | PMP_CS2_CS1_EN |
|
||||
PMP_LATCH_POL_HI | PMP_CS2_POL_HI | PMP_CS1_POL_HI |
|
||||
PMP_WRITE_POL_HI | PMP_READ_POL_HI),
|
||||
(PMP_MODE_MASTER1 | PMP_WAIT_BEG_4 | PMP_WAIT_MID_15 |
|
||||
PMP_WAIT_END_4),
|
||||
PMP_PEN_0, 0);
|
||||
|
||||
/* Wait for the LCD to power up correctly. */
|
||||
vTaskDelay( lcdLONG_DELAY );
|
||||
vTaskDelay( lcdLONG_DELAY );
|
||||
vTaskDelay( lcdLONG_DELAY );
|
||||
|
||||
/* Set up the LCD function. */
|
||||
prvLCDCommand( LCD_FUNCTION_SET_CMD | LCD_FUNCTION_SET_8_BITS | LCD_FUNCTION_SET_2_LINES | LCD_FUNCTION_SET_LRG_FONT );
|
||||
|
||||
/* Turn the display on. */
|
||||
prvLCDCommand( LCD_DISPLAY_CTRL_CMD | LCD_DISPLAY_CTRL_DISPLAY_ON );
|
||||
|
||||
/* Clear the display. */
|
||||
prvLCDCommand( LCD_CLEAR_DISPLAY_CMD );
|
||||
vTaskDelay( lcdLONG_DELAY );
|
||||
|
||||
/* Increase the cursor. */
|
||||
prvLCDCommand( LCD_ENTRY_MODE_CMD | LCD_ENTRY_MODE_INCREASE );
|
||||
vTaskDelay( lcdLONG_DELAY );
|
||||
vTaskDelay( lcdLONG_DELAY );
|
||||
vTaskDelay( lcdLONG_DELAY );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void vLCDTask(void *pvParameters)
|
||||
{
|
||||
xLCDMessage xMessage;
|
||||
unsigned portSHORT usRow = 0;
|
||||
|
||||
/* Initialise the hardware. This uses delays so must not be called prior
|
||||
to the scheduler being started. */
|
||||
prvSetupLCD();
|
||||
|
||||
/* Welcome message. */
|
||||
prvLCDPutString( "www.FreeRTOS.org" );
|
||||
|
||||
for(;;)
|
||||
{
|
||||
/* Wait for a message to arrive that requires displaying. */
|
||||
while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS );
|
||||
|
||||
/* Clear the current display value. */
|
||||
prvLCDClear();
|
||||
|
||||
/* Switch rows each time so we can see that the display is still being
|
||||
updated. */
|
||||
prvLCDGotoRow( usRow & 0x01 );
|
||||
usRow++;
|
||||
prvLCDPutString( xMessage.pcMessage );
|
||||
|
||||
/* Delay the requested amount of time to ensure the text just written
|
||||
to the LCD is not overwritten. */
|
||||
vTaskDelay( xMessage.xMinDisplayTime );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
69
20091005/Demo/PIC32MX_MPLAB/lcd.h
Normal file
69
20091005/Demo/PIC32MX_MPLAB/lcd.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
FreeRTOS V5.4.2 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation and modified by the FreeRTOS exception.
|
||||
**NOTE** The exception to the GPL is included to allow you to distribute a
|
||||
combined work that includes FreeRTOS without being obliged to provide the
|
||||
source code for proprietary components outside of the FreeRTOS kernel.
|
||||
Alternative commercial license and support terms are also available upon
|
||||
request. See the licensing section of http://www.FreeRTOS.org for full
|
||||
license details.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Looking for a quick start? Then check out the FreeRTOS eBook! *
|
||||
* See http://www.FreeRTOS.org/Documentation for details *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
contact details.
|
||||
|
||||
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||
critical systems.
|
||||
|
||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
licensing and training services.
|
||||
*/
|
||||
|
||||
#ifndef LCD_INC_H
|
||||
#define LCD_INC_H
|
||||
|
||||
/* Create the task that will control the LCD. Returned is a handle to the queue
|
||||
on which messages to get written to the LCD should be written. */
|
||||
xQueueHandle xStartLCDTask( void );
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* The minimum amount of time the message should remain on the LCD without
|
||||
being overwritten. */
|
||||
portTickType xMinDisplayTime;
|
||||
|
||||
/* A pointer to the string to be displayed. */
|
||||
portCHAR *pcMessage;
|
||||
|
||||
} xLCDMessage;
|
||||
|
||||
|
||||
#endif /* LCD_INC_H */
|
||||
|
||||
|
395
20091005/Demo/PIC32MX_MPLAB/main.c
Normal file
395
20091005/Demo/PIC32MX_MPLAB/main.c
Normal file
|
@ -0,0 +1,395 @@
|
|||
/*
|
||||
FreeRTOS V5.4.2 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation and modified by the FreeRTOS exception.
|
||||
**NOTE** The exception to the GPL is included to allow you to distribute a
|
||||
combined work that includes FreeRTOS without being obliged to provide the
|
||||
source code for proprietary components outside of the FreeRTOS kernel.
|
||||
Alternative commercial license and support terms are also available upon
|
||||
request. See the licensing section of http://www.FreeRTOS.org for full
|
||||
license details.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Looking for a quick start? Then check out the FreeRTOS eBook! *
|
||||
* See http://www.FreeRTOS.org/Documentation for details *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
contact details.
|
||||
|
||||
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||
critical systems.
|
||||
|
||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
licensing and training services.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Creates all the demo application tasks, then starts the scheduler. The WEB
|
||||
* documentation provides more details of the standard demo application tasks.
|
||||
* In addition to the standard demo tasks, the following tasks and tests are
|
||||
* defined and/or created within this file:
|
||||
*
|
||||
* "LCD" task - the LCD task is a 'gatekeeper' task. It is the only task that
|
||||
* is permitted to access the display directly. Other tasks wishing to write a
|
||||
* message to the LCD send the message on a queue to the LCD task instead of
|
||||
* accessing the LCD themselves. The LCD task just blocks on the queue waiting
|
||||
* for messages - waking and displaying the messages as they arrive.
|
||||
*
|
||||
* "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 standard demo tasks are still operational. Should any
|
||||
* unexpected behaviour within a demo task be discovered the check task will
|
||||
* write an error to the LCD (via the LCD task). If all the demo tasks are
|
||||
* executing with their expected behaviour then the check task instead writes
|
||||
* a count of the number of times the high frequency interrupt has incremented
|
||||
* ulHighFrequencyTimerInterrupts - which is one in every 20,000 interrupts.
|
||||
*
|
||||
* "Register test" tasks - These tasks are used in part to test the kernel port.
|
||||
* They set each processor register to a known value, then check that the
|
||||
* register still contains that value. Each of the tasks sets the registers
|
||||
* to different values, and will get swapping in and out between setting and
|
||||
* then subsequently checking the register values. Discovery of an incorrect
|
||||
* value would be indicative of an error in the task switching mechanism.
|
||||
*
|
||||
* By way of demonstration, the demo application defines
|
||||
* configMAX_SYSCALL_INTERRUPT_PRIORITY to be 3, configKERNEL_INTERRUPT_PRIORITY
|
||||
* to be 1, and all other interrupts as follows:
|
||||
*
|
||||
* + The UART is allocated a priority of 2. This means it can interrupt the
|
||||
* RTOS tick, and can also safely use queues.
|
||||
* + Two timers are configured to generate interrupts just to test the nesting
|
||||
* and queue access mechanisms. These timers are allocated priorities 2 and 3
|
||||
* respectively. Even though they both access the same two queues, the
|
||||
* priority 3 interrupt can safely interrupt the priority 2 interrupt. Both
|
||||
* can interrupt the RTOS tick.
|
||||
* + Finally a high frequency timer interrupt is configured to use priority 4 -
|
||||
* therefore kernel activity will never prevent the high frequency timer from
|
||||
* executing immediately that the interrupt is raised (within the limitations
|
||||
* of the hardware itself). It would not be safe to access a queue from this
|
||||
* interrupt as it is above configMAX_SYSCALL_INTERRUPT_PRIORITY.
|
||||
*
|
||||
* See the online documentation for this demo for more information on interrupt
|
||||
* usage.
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdio.h>
|
||||
|
||||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* Demo application includes. */
|
||||
#include "partest.h"
|
||||
#include "blocktim.h"
|
||||
#include "flash.h"
|
||||
#include "semtest.h"
|
||||
#include "GenQTest.h"
|
||||
#include "QPeek.h"
|
||||
#include "lcd.h"
|
||||
#include "comtest2.h"
|
||||
#include "timertest.h"
|
||||
#include "IntQueue.h"
|
||||
|
||||
#pragma config FPLLMUL = MUL_20, FPLLIDIV = DIV_2, FPLLODIV = DIV_1, FWDTEN = OFF
|
||||
#pragma config POSCMOD = HS, FNOSC = PRIPLL, FPBDIV = DIV_2
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The rate at which the LED controlled by the 'check' task will flash when no
|
||||
errors have been detected. */
|
||||
#define mainNO_ERROR_PERIOD ( 3000 / portTICK_RATE_MS )
|
||||
|
||||
/* The rate at which the LED controlled by the 'check' task will flash when an
|
||||
error has been detected. */
|
||||
#define mainERROR_PERIOD ( 500 / portTICK_RATE_MS )
|
||||
|
||||
/* The priorities of the various demo application tasks. */
|
||||
#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
|
||||
#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
|
||||
/* The LED controlled by the 'check' task. */
|
||||
#define mainCHECK_LED ( 7 )
|
||||
|
||||
/* 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 )
|
||||
|
||||
/* Baud rate used by the comtest tasks. */
|
||||
#define mainCOM_TEST_BAUD_RATE ( 115200 )
|
||||
|
||||
/* Misc. */
|
||||
#define mainDONT_WAIT ( 0 )
|
||||
|
||||
/* Dimension the buffer used to hold the value of the high frequency timer
|
||||
count when it is converted to a string. */
|
||||
#define mainMAX_STRING_LENGTH ( 20 )
|
||||
|
||||
/* The frequency at which the "fast interrupt test" interrupt will occur. */
|
||||
#define mainTEST_INTERRUPT_FREQUENCY ( 20000 )
|
||||
|
||||
/* The number of timer clocks we expect to occur between each "fast
|
||||
interrupt test" interrupt. */
|
||||
#define mainEXPECTED_CLOCKS_BETWEEN_INTERRUPTS ( ( configCPU_CLOCK_HZ >> 1 ) / mainTEST_INTERRUPT_FREQUENCY )
|
||||
|
||||
/* The number of nano seconds between each core clock. */
|
||||
#define mainNS_PER_CLOCK ( ( unsigned portLONG ) ( ( 1.0 / ( double ) ( configCPU_CLOCK_HZ >> 1 ) ) * 1000000000.0 ) )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Setup the processor ready for the demo.
|
||||
*/
|
||||
static void prvSetupHardware( void );
|
||||
|
||||
/*
|
||||
* Implements the 'check' task functionality as described at the top of this
|
||||
* file.
|
||||
*/
|
||||
static void prvCheckTask( void *pvParameters ) __attribute__((noreturn));
|
||||
|
||||
/*
|
||||
* Tasks that test the context switch mechanism by filling the processor
|
||||
* registers with known values, then checking that the values contained
|
||||
* within the registers is as expected. The tasks are likely to get swapped
|
||||
* in and out between setting the register values and checking the register
|
||||
* values. */
|
||||
static void prvTestTask1( void *pvParameters );
|
||||
static void prvTestTask2( void *pvParameters );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The queue used to send messages to the LCD task. */
|
||||
static xQueueHandle xLCDQueue;
|
||||
|
||||
/* Flag used by prvTestTask1() and prvTestTask2() to indicate their status
|
||||
(pass/fail). */
|
||||
unsigned portLONG ulStatus1 = pdPASS;
|
||||
|
||||
/* Variables incremented by prvTestTask1() and prvTestTask2() respectively on
|
||||
each iteration of their function. This is used to detect either task stopping
|
||||
their execution.. */
|
||||
unsigned portLONG ulRegTest1Cycles = 0, ulRegTest2Cycles = 0;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Create the demo tasks then start the scheduler.
|
||||
*/
|
||||
int main( void )
|
||||
{
|
||||
/* Configure any hardware required for this demo. */
|
||||
prvSetupHardware();
|
||||
|
||||
/* Create the LCD task - this returns the queue to use when writing
|
||||
messages to the LCD. */
|
||||
xLCDQueue = xStartLCDTask();
|
||||
|
||||
/* Create all the other standard demo tasks. */
|
||||
vStartLEDFlashTasks( tskIDLE_PRIORITY );
|
||||
vCreateBlockTimeTasks();
|
||||
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
|
||||
vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
|
||||
vStartQueuePeekTasks();
|
||||
vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
|
||||
vStartInterruptQueueTasks();
|
||||
|
||||
/* Create the tasks defined within this file. */
|
||||
xTaskCreate( prvTestTask1, "Tst1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||
xTaskCreate( prvTestTask2, "Tst2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||
|
||||
/* prvCheckTask uses sprintf so requires more stack. */
|
||||
xTaskCreate( prvCheckTask, "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 prvTestTask1( void *pvParameters )
|
||||
{
|
||||
extern void vRegTest1( unsigned long * );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Perform the register test function. */
|
||||
vRegTest1( &ulStatus1 );
|
||||
|
||||
/* Increment the counter so the check task knows we are still
|
||||
running. */
|
||||
ulRegTest1Cycles++;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvTestTask2( void *pvParameters )
|
||||
{
|
||||
extern void vRegTest2( unsigned long * );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Perform the register test function. */
|
||||
vRegTest2( &ulStatus1 );
|
||||
|
||||
/* Increment the counter so the check task knows we are still
|
||||
running. */
|
||||
ulRegTest2Cycles++;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSetupHardware( void )
|
||||
{
|
||||
/* Set the system and peripheral bus speeds and enable the program cache*/
|
||||
SYSTEMConfigPerformance( configCPU_CLOCK_HZ - 1 );
|
||||
mOSCSetPBDIV( OSC_PB_DIV_2 );
|
||||
|
||||
/* Setup to use the external interrupt controller. */
|
||||
INTEnableSystemMultiVectoredInt();
|
||||
|
||||
portDISABLE_INTERRUPTS();
|
||||
|
||||
/* Setup the digital IO for the LED's. */
|
||||
vParTestInitialise();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCheckTask( void *pvParameters )
|
||||
{
|
||||
unsigned portLONG ulLastRegTest1Value = 0, ulLastRegTest2Value = 0, ulTicksToWait = mainNO_ERROR_PERIOD;
|
||||
portTickType xLastExecutionTime;
|
||||
|
||||
/* Buffer into which the high frequency timer count is written as a string. */
|
||||
static portCHAR cStringBuffer[ mainMAX_STRING_LENGTH ];
|
||||
|
||||
/* The count of the high frequency timer interrupts. */
|
||||
extern unsigned portLONG ulHighFrequencyTimerInterrupts;
|
||||
xLCDMessage xMessage = { ( 200 / portTICK_RATE_MS ), cStringBuffer };
|
||||
|
||||
/* Setup the high frequency, high priority, timer test. It is setup here
|
||||
to ensure it does not fire before the scheduler is started. */
|
||||
vSetupTimerTest( mainTEST_INTERRUPT_FREQUENCY );
|
||||
|
||||
/* Initialise the variable used to control our iteration rate prior to
|
||||
its first use. */
|
||||
xLastExecutionTime = xTaskGetTickCount();
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Wait until it is time to run the tests again. */
|
||||
vTaskDelayUntil( &xLastExecutionTime, ulTicksToWait );
|
||||
|
||||
/* Has either register check 1 or 2 task discovered an error? */
|
||||
if( ulStatus1 != pdPASS )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
xMessage.pcMessage = "Error: Reg test1";
|
||||
}
|
||||
|
||||
/* Check that the register test 1 task is still running. */
|
||||
if( ulLastRegTest1Value == ulRegTest1Cycles )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
xMessage.pcMessage = "Error: Reg test2";
|
||||
}
|
||||
ulLastRegTest1Value = ulRegTest1Cycles;
|
||||
|
||||
|
||||
/* Check that the register test 2 task is still running. */
|
||||
if( ulLastRegTest2Value == ulRegTest2Cycles )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
xMessage.pcMessage = "Error: Reg test3";
|
||||
}
|
||||
ulLastRegTest2Value = ulRegTest2Cycles;
|
||||
|
||||
|
||||
/* Have any of the standard demo tasks detected an error in their
|
||||
operation? */
|
||||
if( xAreGenericQueueTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
xMessage.pcMessage = "Error: Gen Q";
|
||||
}
|
||||
else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
xMessage.pcMessage = "Error: Q Peek";
|
||||
}
|
||||
else if( xAreComTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
xMessage.pcMessage = "Error: COM test";
|
||||
}
|
||||
else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
xMessage.pcMessage = "Error: Blck time";
|
||||
}
|
||||
else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
xMessage.pcMessage = "Error: Sem test";
|
||||
}
|
||||
else if( xAreIntQueueTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulTicksToWait = mainERROR_PERIOD;
|
||||
xMessage.pcMessage = "Error: Int queue";
|
||||
}
|
||||
|
||||
/* Write the ulHighFrequencyTimerInterrupts value to the string
|
||||
buffer. It will only be displayed if no errors have been detected. */
|
||||
sprintf( cStringBuffer, "Pass %u", ( unsigned int ) ulHighFrequencyTimerInterrupts );
|
||||
|
||||
xQueueSend( xLCDQueue, &xMessage, mainDONT_WAIT );
|
||||
vParTestToggleLED( mainCHECK_LED );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationStackOverflowHook( void )
|
||||
{
|
||||
/* Look at pxCurrentTCB to see which task overflowed its stack. */
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void _general_exception_handler( unsigned portLONG ulCause, unsigned portLONG ulStatus )
|
||||
{
|
||||
/* This overrides the definition provided by the kernel. Other exceptions
|
||||
should be handled here. */
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
286
20091005/Demo/PIC32MX_MPLAB/printf-stdarg.c
Normal file
286
20091005/Demo/PIC32MX_MPLAB/printf-stdarg.c
Normal file
|
@ -0,0 +1,286 @@
|
|||
/*
|
||||
Copyright 2001, 2002 Georges Menie (www.menie.org)
|
||||
stdarg version contributed by Christian Ettinger
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
putchar is the only external dependency for this file,
|
||||
if you have a working putchar, leave it commented out.
|
||||
If not, uncomment the define below and
|
||||
replace outbyte(c) by your own function call.
|
||||
|
||||
#define putchar(c) outbyte(c)
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
static void printchar(char **str, int c)
|
||||
{
|
||||
extern int putchar(int c);
|
||||
|
||||
if (str) {
|
||||
**str = c;
|
||||
++(*str);
|
||||
}
|
||||
else (void)putchar(c);
|
||||
}
|
||||
|
||||
#define PAD_RIGHT 1
|
||||
#define PAD_ZERO 2
|
||||
|
||||
static int prints(char **out, const char *string, int width, int pad)
|
||||
{
|
||||
register int pc = 0, padchar = ' ';
|
||||
|
||||
if (width > 0) {
|
||||
register int len = 0;
|
||||
register const char *ptr;
|
||||
for (ptr = string; *ptr; ++ptr) ++len;
|
||||
if (len >= width) width = 0;
|
||||
else width -= len;
|
||||
if (pad & PAD_ZERO) padchar = '0';
|
||||
}
|
||||
if (!(pad & PAD_RIGHT)) {
|
||||
for ( ; width > 0; --width) {
|
||||
printchar (out, padchar);
|
||||
++pc;
|
||||
}
|
||||
}
|
||||
for ( ; *string ; ++string) {
|
||||
printchar (out, *string);
|
||||
++pc;
|
||||
}
|
||||
for ( ; width > 0; --width) {
|
||||
printchar (out, padchar);
|
||||
++pc;
|
||||
}
|
||||
|
||||
return pc;
|
||||
}
|
||||
|
||||
/* the following should be enough for 32 bit int */
|
||||
#define PRINT_BUF_LEN 12
|
||||
|
||||
static int printi(char **out, int i, int b, int sg, int width, int pad, int letbase)
|
||||
{
|
||||
char print_buf[PRINT_BUF_LEN];
|
||||
register char *s;
|
||||
register int t, neg = 0, pc = 0;
|
||||
register unsigned int u = i;
|
||||
|
||||
if (i == 0) {
|
||||
print_buf[0] = '0';
|
||||
print_buf[1] = '\0';
|
||||
return prints (out, print_buf, width, pad);
|
||||
}
|
||||
|
||||
if (sg && b == 10 && i < 0) {
|
||||
neg = 1;
|
||||
u = -i;
|
||||
}
|
||||
|
||||
s = print_buf + PRINT_BUF_LEN-1;
|
||||
*s = '\0';
|
||||
|
||||
while (u) {
|
||||
t = u % b;
|
||||
if( t >= 10 )
|
||||
t += letbase - '0' - 10;
|
||||
*--s = t + '0';
|
||||
u /= b;
|
||||
}
|
||||
|
||||
if (neg) {
|
||||
if( width && (pad & PAD_ZERO) ) {
|
||||
printchar (out, '-');
|
||||
++pc;
|
||||
--width;
|
||||
}
|
||||
else {
|
||||
*--s = '-';
|
||||
}
|
||||
}
|
||||
|
||||
return pc + prints (out, s, width, pad);
|
||||
}
|
||||
|
||||
static int print( char **out, const char *format, va_list args )
|
||||
{
|
||||
register int width, pad;
|
||||
register int pc = 0;
|
||||
char scr[2];
|
||||
|
||||
for (; *format != 0; ++format) {
|
||||
if (*format == '%') {
|
||||
++format;
|
||||
width = pad = 0;
|
||||
if (*format == '\0') break;
|
||||
if (*format == '%') goto out;
|
||||
if (*format == '-') {
|
||||
++format;
|
||||
pad = PAD_RIGHT;
|
||||
}
|
||||
while (*format == '0') {
|
||||
++format;
|
||||
pad |= PAD_ZERO;
|
||||
}
|
||||
for ( ; *format >= '0' && *format <= '9'; ++format) {
|
||||
width *= 10;
|
||||
width += *format - '0';
|
||||
}
|
||||
if( *format == 's' ) {
|
||||
register char *s = (char *)va_arg( args, int );
|
||||
pc += prints (out, s?s:"(null)", width, pad);
|
||||
continue;
|
||||
}
|
||||
if( *format == 'd' ) {
|
||||
pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a');
|
||||
continue;
|
||||
}
|
||||
if( *format == 'x' ) {
|
||||
pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a');
|
||||
continue;
|
||||
}
|
||||
if( *format == 'X' ) {
|
||||
pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A');
|
||||
continue;
|
||||
}
|
||||
if( *format == 'u' ) {
|
||||
pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a');
|
||||
continue;
|
||||
}
|
||||
if( *format == 'c' ) {
|
||||
/* char are converted to int then pushed on the stack */
|
||||
scr[0] = (char)va_arg( args, int );
|
||||
scr[1] = '\0';
|
||||
pc += prints (out, scr, width, pad);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
out:
|
||||
printchar (out, *format);
|
||||
++pc;
|
||||
}
|
||||
}
|
||||
if (out) **out = '\0';
|
||||
va_end( args );
|
||||
return pc;
|
||||
}
|
||||
|
||||
int printf(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start( args, format );
|
||||
return print( 0, format, args );
|
||||
}
|
||||
|
||||
int sprintf(char *out, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start( args, format );
|
||||
return print( &out, format, args );
|
||||
}
|
||||
|
||||
|
||||
int snprintf( char *buf, unsigned int count, const char *format, ... )
|
||||
{
|
||||
va_list args;
|
||||
|
||||
( void ) count;
|
||||
|
||||
va_start( args, format );
|
||||
return print( &buf, format, args );
|
||||
}
|
||||
|
||||
|
||||
#ifdef TEST_PRINTF
|
||||
int main(void)
|
||||
{
|
||||
char *ptr = "Hello world!";
|
||||
char *np = 0;
|
||||
int i = 5;
|
||||
unsigned int bs = sizeof(int)*8;
|
||||
int mi;
|
||||
char buf[80];
|
||||
|
||||
mi = (1 << (bs-1)) + 1;
|
||||
printf("%s\n", ptr);
|
||||
printf("printf test\n");
|
||||
printf("%s is null pointer\n", np);
|
||||
printf("%d = 5\n", i);
|
||||
printf("%d = - max int\n", mi);
|
||||
printf("char %c = 'a'\n", 'a');
|
||||
printf("hex %x = ff\n", 0xff);
|
||||
printf("hex %02x = 00\n", 0);
|
||||
printf("signed %d = unsigned %u = hex %x\n", -3, -3, -3);
|
||||
printf("%d %s(s)%", 0, "message");
|
||||
printf("\n");
|
||||
printf("%d %s(s) with %%\n", 0, "message");
|
||||
sprintf(buf, "justif: \"%-10s\"\n", "left"); printf("%s", buf);
|
||||
sprintf(buf, "justif: \"%10s\"\n", "right"); printf("%s", buf);
|
||||
sprintf(buf, " 3: %04d zero padded\n", 3); printf("%s", buf);
|
||||
sprintf(buf, " 3: %-4d left justif.\n", 3); printf("%s", buf);
|
||||
sprintf(buf, " 3: %4d right justif.\n", 3); printf("%s", buf);
|
||||
sprintf(buf, "-3: %04d zero padded\n", -3); printf("%s", buf);
|
||||
sprintf(buf, "-3: %-4d left justif.\n", -3); printf("%s", buf);
|
||||
sprintf(buf, "-3: %4d right justif.\n", -3); printf("%s", buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* if you compile this file with
|
||||
* gcc -Wall $(YOUR_C_OPTIONS) -DTEST_PRINTF -c printf.c
|
||||
* you will get a normal warning:
|
||||
* printf.c:214: warning: spurious trailing `%' in format
|
||||
* this line is testing an invalid % at the end of the format string.
|
||||
*
|
||||
* this should display (on 32bit int machine) :
|
||||
*
|
||||
* Hello world!
|
||||
* printf test
|
||||
* (null) is null pointer
|
||||
* 5 = 5
|
||||
* -2147483647 = - max int
|
||||
* char a = 'a'
|
||||
* hex ff = ff
|
||||
* hex 00 = 00
|
||||
* signed -3 = unsigned 4294967293 = hex fffffffd
|
||||
* 0 message(s)
|
||||
* 0 message(s) with %
|
||||
* justif: "left "
|
||||
* justif: " right"
|
||||
* 3: 0003 zero padded
|
||||
* 3: 3 left justif.
|
||||
* 3: 3 right justif.
|
||||
* -3: -003 zero padded
|
||||
* -3: -3 left justif.
|
||||
* -3: -3 right justif.
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* To keep linker happy. */
|
||||
int write( int i, char* c, int n)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
201
20091005/Demo/PIC32MX_MPLAB/serial/serial.c
Normal file
201
20091005/Demo/PIC32MX_MPLAB/serial/serial.c
Normal file
|
@ -0,0 +1,201 @@
|
|||
/*
|
||||
FreeRTOS V5.4.2 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation and modified by the FreeRTOS exception.
|
||||
**NOTE** The exception to the GPL is included to allow you to distribute a
|
||||
combined work that includes FreeRTOS without being obliged to provide the
|
||||
source code for proprietary components outside of the FreeRTOS kernel.
|
||||
Alternative commercial license and support terms are also available upon
|
||||
request. See the licensing section of http://www.FreeRTOS.org for full
|
||||
license details.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Looking for a quick start? Then check out the FreeRTOS eBook! *
|
||||
* See http://www.FreeRTOS.org/Documentation for details *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
contact details.
|
||||
|
||||
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||
critical systems.
|
||||
|
||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
licensing and training services.
|
||||
*/
|
||||
|
||||
|
||||
/* 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>
|
||||
#include <plib.h>
|
||||
|
||||
/* Scheduler include files. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Demo app include files. */
|
||||
#include "serial.h"
|
||||
|
||||
/* Hardware setup. */
|
||||
#define serSET_FLAG ( 1 )
|
||||
|
||||
/* The queues used to communicate between tasks and ISR's. */
|
||||
static xQueueHandle xRxedChars;
|
||||
static xQueueHandle xCharsForTx;
|
||||
|
||||
/* Flag used to indicate the tx status. */
|
||||
static portBASE_TYPE xTxHasEnded;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The UART interrupt handler. */
|
||||
void __attribute__( (interrupt(ipl1), vector(_UART2_VECTOR))) vU2InterruptWrapper( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
xComPortHandle xSerialPortInitMinimal( unsigned portLONG ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
|
||||
{
|
||||
unsigned portSHORT usBRG;
|
||||
|
||||
/* 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 ) );
|
||||
|
||||
/* Configure the UART and interrupts. */
|
||||
usBRG = (unsigned portSHORT)(( (float)configPERIPHERAL_CLOCK_HZ / ( (float)16 * (float)ulWantedBaud ) ) - (float)0.5);
|
||||
OpenUART2( UART_EN, UART_RX_ENABLE | UART_TX_ENABLE | UART_INT_TX | UART_INT_RX_CHAR, usBRG );
|
||||
ConfigIntUART2( ( configKERNEL_INTERRUPT_PRIORITY + 1 ) | UART_INT_SUB_PR0 | UART_TX_INT_EN | UART_RX_INT_EN );
|
||||
|
||||
xTxHasEnded = pdTRUE;
|
||||
|
||||
/* Only a single port is implemented so we don't need to return anything. */
|
||||
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 )
|
||||
{
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vU2InterruptHandler( void )
|
||||
{
|
||||
/* Declared static to minimise stack use. */
|
||||
static portCHAR cChar;
|
||||
static portBASE_TYPE xHigherPriorityTaskWoken;
|
||||
|
||||
xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
/* Are any Rx interrupts pending? */
|
||||
if( mU2RXGetIntFlag() )
|
||||
{
|
||||
while( U2STAbits.URXDA )
|
||||
{
|
||||
/* Retrieve the received character and place it in the queue of
|
||||
received characters. */
|
||||
cChar = U2RXREG;
|
||||
xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken );
|
||||
}
|
||||
mU2RXClearIntFlag();
|
||||
}
|
||||
|
||||
/* Are any Tx interrupts pending? */
|
||||
if( mU2TXGetIntFlag() )
|
||||
{
|
||||
while( !( U2STAbits.UTXBF ) )
|
||||
{
|
||||
if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE )
|
||||
{
|
||||
/* Send the next character queued for Tx. */
|
||||
U2TXREG = cChar;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Queue empty, nothing to send. */
|
||||
xTxHasEnded = pdTRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mU2TXClearIntFlag();
|
||||
}
|
||||
|
||||
/* If sending or receiving necessitates a context switch, then switch now. */
|
||||
portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
24
20091005/Demo/PIC32MX_MPLAB/serial/serial_isr.S
Normal file
24
20091005/Demo/PIC32MX_MPLAB/serial/serial_isr.S
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include <p32xxxx.h>
|
||||
#include <sys/asm.h>
|
||||
#include "ISR_Support.h"
|
||||
|
||||
.set nomips16
|
||||
.set noreorder
|
||||
|
||||
.extern vU2InterruptHandler
|
||||
.extern xISRStackTop
|
||||
.global vU2InterruptWrapper
|
||||
|
||||
.set noreorder
|
||||
.set noat
|
||||
.ent vU2InterruptWrapper
|
||||
|
||||
vU2InterruptWrapper:
|
||||
|
||||
portSAVE_CONTEXT
|
||||
jal vU2InterruptHandler
|
||||
nop
|
||||
portRESTORE_CONTEXT
|
||||
|
||||
.end vU2InterruptWrapper
|
||||
|
116
20091005/Demo/PIC32MX_MPLAB/timertest.c
Normal file
116
20091005/Demo/PIC32MX_MPLAB/timertest.c
Normal file
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
FreeRTOS V5.4.2 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation and modified by the FreeRTOS exception.
|
||||
**NOTE** The exception to the GPL is included to allow you to distribute a
|
||||
combined work that includes FreeRTOS without being obliged to provide the
|
||||
source code for proprietary components outside of the FreeRTOS kernel.
|
||||
Alternative commercial license and support terms are also available upon
|
||||
request. See the licensing section of http://www.FreeRTOS.org for full
|
||||
license details.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Looking for a quick start? Then check out the FreeRTOS eBook! *
|
||||
* See http://www.FreeRTOS.org/Documentation for details *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
contact details.
|
||||
|
||||
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||
critical systems.
|
||||
|
||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
licensing and training services.
|
||||
*/
|
||||
|
||||
/* High speed timer test as described in main.c. */
|
||||
|
||||
|
||||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
/* The maximum value the 16bit timer can contain. */
|
||||
#define timerMAX_COUNT 0xffff
|
||||
|
||||
/* The timer 2 interrupt handler. */
|
||||
void __attribute__( (interrupt(ipl0), vector(_TIMER_2_VECTOR))) vT2InterruptWrapper( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Incremented every 20,000 interrupts, so should count in seconds. */
|
||||
unsigned portLONG ulHighFrequencyTimerInterrupts = 0;
|
||||
|
||||
/* The frequency at which the timer is interrupting. */
|
||||
static unsigned portLONG ulFrequencyHz;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vSetupTimerTest( unsigned portSHORT usFrequencyHz )
|
||||
{
|
||||
/* Remember the frequency so it can be used from the ISR. */
|
||||
ulFrequencyHz = ( unsigned portLONG ) usFrequencyHz;
|
||||
|
||||
/* T2 is used to generate interrupts above the kernel and max syscall interrupt
|
||||
priority. */
|
||||
T2CON = 0;
|
||||
TMR2 = 0;
|
||||
|
||||
/* Timer 2 is going to interrupt at usFrequencyHz Hz. */
|
||||
PR2 = ( unsigned portSHORT ) ( ( configPERIPHERAL_CLOCK_HZ / ( unsigned portLONG ) usFrequencyHz ) - 1 );
|
||||
|
||||
/* Setup timer 2 interrupt priority to be above the kernel priority so
|
||||
the timer jitter is not effected by the kernel activity. */
|
||||
ConfigIntTimer2( T2_INT_ON | ( configMAX_SYSCALL_INTERRUPT_PRIORITY + 1 ) );
|
||||
|
||||
/* Clear the interrupt as a starting condition. */
|
||||
IFS0bits.T2IF = 0;
|
||||
|
||||
/* Enable the interrupt. */
|
||||
IEC0bits.T2IE = 1;
|
||||
|
||||
/* Start the timer. */
|
||||
T2CONbits.TON = 1;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vT2InterruptHandler( void )
|
||||
{
|
||||
static unsigned portLONG ulCalls = 0;
|
||||
|
||||
++ulCalls;
|
||||
if( ulCalls >= ulFrequencyHz )
|
||||
{
|
||||
/* Increment the count that will be shown on the LCD.
|
||||
The increment occurs once every 20,000 interrupts so
|
||||
ulHighFrequencyTimerInterrupts should count in seconds. */
|
||||
ulHighFrequencyTimerInterrupts++;
|
||||
ulCalls = 0;
|
||||
}
|
||||
|
||||
/* Clear the timer interrupt. */
|
||||
IFS0bits.T2IF = 0;
|
||||
}
|
||||
|
||||
|
57
20091005/Demo/PIC32MX_MPLAB/timertest.h
Normal file
57
20091005/Demo/PIC32MX_MPLAB/timertest.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
FreeRTOS V5.4.2 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation and modified by the FreeRTOS exception.
|
||||
**NOTE** The exception to the GPL is included to allow you to distribute a
|
||||
combined work that includes FreeRTOS without being obliged to provide the
|
||||
source code for proprietary components outside of the FreeRTOS kernel.
|
||||
Alternative commercial license and support terms are also available upon
|
||||
request. See the licensing section of http://www.FreeRTOS.org for full
|
||||
license details.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Looking for a quick start? Then check out the FreeRTOS eBook! *
|
||||
* See http://www.FreeRTOS.org/Documentation for details *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
contact details.
|
||||
|
||||
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||
critical systems.
|
||||
|
||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
licensing and training services.
|
||||
*/
|
||||
|
||||
#ifndef TIMER_TEST_H
|
||||
#define TIMER_TEST_H
|
||||
|
||||
/* Setup the high frequency timer interrupt. */
|
||||
void vSetupTimerTest( unsigned portSHORT usFrequencyHz );
|
||||
|
||||
#endif /* TIMER_TEST_H */
|
||||
|
||||
|
||||
|
71
20091005/Demo/PIC32MX_MPLAB/timertest_isr.S
Normal file
71
20091005/Demo/PIC32MX_MPLAB/timertest_isr.S
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
FreeRTOS V5.4.2 - Copyright (C) 2009 Real Time Engineers Ltd.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation and modified by the FreeRTOS exception.
|
||||
**NOTE** The exception to the GPL is included to allow you to distribute a
|
||||
combined work that includes FreeRTOS without being obliged to provide the
|
||||
source code for proprietary components outside of the FreeRTOS kernel.
|
||||
Alternative commercial license and support terms are also available upon
|
||||
request. See the licensing section of http://www.FreeRTOS.org for full
|
||||
license details.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Looking for a quick start? Then check out the FreeRTOS eBook! *
|
||||
* See http://www.FreeRTOS.org/Documentation for details *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
contact details.
|
||||
|
||||
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||
critical systems.
|
||||
|
||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
licensing and training services.
|
||||
*/
|
||||
|
||||
#include <p32xxxx.h>
|
||||
#include <sys/asm.h>
|
||||
#include "ISR_Support.h"
|
||||
|
||||
.set nomips16
|
||||
.set noreorder
|
||||
|
||||
.extern vT2InterruptHandler
|
||||
.extern xISRStackTop
|
||||
.global vT2InterruptWrapper
|
||||
|
||||
.set noreorder
|
||||
.set noat
|
||||
.ent vT2InterruptWrapper
|
||||
|
||||
vT2InterruptWrapper:
|
||||
|
||||
portSAVE_CONTEXT
|
||||
jal vT2InterruptHandler
|
||||
nop
|
||||
portRESTORE_CONTEXT
|
||||
|
||||
.end vT2InterruptWrapper
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue