mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-19 17:48:33 -04:00
Add PIC32MEC14xx port and demo application.
This commit is contained in:
parent
f19497c3d6
commit
a29dc8d6c6
103 changed files with 49682 additions and 6 deletions
151
FreeRTOS/Demo/PIC32MEC14xx_MPLAB/src/Full_Demo/IntQueueTimer.c
Normal file
151
FreeRTOS/Demo/PIC32MEC14xx_MPLAB/src/Full_Demo/IntQueueTimer.c
Normal file
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
|
||||
|
||||
***************************************************************************
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
***************************************************************************
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
/* Standard demo includes. */
|
||||
#include "IntQueueTimer.h"
|
||||
#include "IntQueue.h"
|
||||
|
||||
/* Microchip includes. */
|
||||
#include "MEC14xx/mec14xx_timers.h"
|
||||
#include "MEC14xx/mec14xx_jtvic.h"
|
||||
#include "MEC14xx/mec14xx.h"
|
||||
|
||||
/* The frequency of the two timers is offset so the time between the timers
|
||||
expiring is not always the same. */
|
||||
#define timerINTERRUPT0_FREQUENCY ( 2000UL )
|
||||
#define timerINTERRUPT1_FREQUENCY ( 2221UL )
|
||||
|
||||
/* MEC14xx JTVIC external interrupt controller is mapped to M14K closely-coupled
|
||||
peripheral space. */
|
||||
#define portMMCR_JTVIC_GIRQ23_PRIA *((volatile uint32_t *)(0xBFFFC3F0ul))
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* These are the C handlers called from the asm wrappers. */
|
||||
void vT0InterruptHandler( void );
|
||||
void vT1InterruptHandler( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vInitialiseTimerForIntQueueTest( void )
|
||||
{
|
||||
/* Timer RT is used for the tick interrupt, timer 3 is used for the high
|
||||
frequency interrupt test. This file therefore uses timers 0 and 1. */
|
||||
uint32_t ulPreload = ( unsigned short ) ( ( configPERIPHERAL_CLOCK_HZ / ( unsigned long ) timerINTERRUPT0_FREQUENCY ) );
|
||||
|
||||
btmr_sleep_en( BTMR0_ID, 0 );
|
||||
btmr_init( BTMR0_ID, BTMR_COUNT_DOWN + BTMR_AUTO_RESTART + BTMR_INT_EN, 0, ulPreload, ulPreload );
|
||||
btmr_start( BTMR0_ID );
|
||||
|
||||
jtvic_clr_source( MEC14xx_GIRQ23_ID, 0 );
|
||||
portMMCR_JTVIC_GIRQ23_PRIA &= ~( 0x0Ful << 0 );
|
||||
portMMCR_JTVIC_GIRQ23_PRIA |= ( ( portIPL_TO_CODE( configMAX_SYSCALL_INTERRUPT_PRIORITY ) ) << 0 );
|
||||
jtvic_en_source( MEC14xx_GIRQ23_ID, 0, pdTRUE );
|
||||
|
||||
ulPreload = ( unsigned short ) ( ( configPERIPHERAL_CLOCK_HZ / ( unsigned long ) timerINTERRUPT1_FREQUENCY ) );
|
||||
btmr_sleep_en( BTMR1_ID, 0 );
|
||||
btmr_init( BTMR1_ID, BTMR_COUNT_DOWN + BTMR_AUTO_RESTART + BTMR_INT_EN, 0, ulPreload, ulPreload );
|
||||
btmr_start( BTMR1_ID );
|
||||
|
||||
jtvic_clr_source( MEC14xx_GIRQ23_ID, 1 );
|
||||
portMMCR_JTVIC_GIRQ23_PRIA &= ~( 0x0Ful << 4 );
|
||||
portMMCR_JTVIC_GIRQ23_PRIA |= ( ( portIPL_TO_CODE( configMAX_SYSCALL_INTERRUPT_PRIORITY ) ) << 4 );
|
||||
jtvic_en_source( MEC14xx_GIRQ23_ID, 1, pdTRUE );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vT0InterruptHandler( void )
|
||||
{
|
||||
/* Disable all interrupts because the source bit is shared with a bit used
|
||||
by the other timer and the high frequency timer test. */
|
||||
__asm volatile( "di" );
|
||||
/* Clear the timer interrupt. */
|
||||
jtvic_clr_source( MEC14xx_GIRQ23_ID, 0 );
|
||||
__asm volatile( "ei" );
|
||||
|
||||
portEND_SWITCHING_ISR( xFirstTimerHandler() );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vT1InterruptHandler( void )
|
||||
{
|
||||
/* Disable all interrupts because the source bit is shared with a bit used
|
||||
by the other timer and the high frequency timer test. */
|
||||
__asm volatile( "di" );
|
||||
/* Clear the timer interrupt. */
|
||||
jtvic_clr_source( MEC14xx_GIRQ23_ID, 1 );
|
||||
__asm volatile( "ei" );
|
||||
|
||||
portEND_SWITCHING_ISR( xSecondTimerHandler() );
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
|
||||
|
||||
***************************************************************************
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
***************************************************************************
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#ifndef INT_QUEUE_TIMER_H
|
||||
#define INT_QUEUE_TIMER_H
|
||||
|
||||
void vInitialiseTimerForIntQueueTest( void );
|
||||
portBASE_TYPE xTimer0Handler( void );
|
||||
portBASE_TYPE xTimer1Handler( void );
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
|
||||
|
||||
***************************************************************************
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
***************************************************************************
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#include <xc.h>
|
||||
#include <sys/asm.h>
|
||||
#include "ISR_Support.h"
|
||||
|
||||
#define portEXC_CODE_MASK ( 0x1f << 2 )
|
||||
|
||||
|
||||
.extern vT0InterruptHandler
|
||||
.extern vT1InterruptHandler
|
||||
|
||||
.global vT0InterruptWrapper
|
||||
.global vT1InterruptWrapper
|
||||
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
.set micromips
|
||||
.set noreorder
|
||||
.set noat
|
||||
.ent vT0InterruptWrapper
|
||||
.global girq23_b0
|
||||
|
||||
girq23_b0:
|
||||
vT0InterruptWrapper:
|
||||
|
||||
portSAVE_CONTEXT
|
||||
|
||||
jal vT0InterruptHandler
|
||||
nop
|
||||
|
||||
portRESTORE_CONTEXT
|
||||
|
||||
.end vT0InterruptWrapper
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
.set micromips
|
||||
.set noreorder
|
||||
.set noat
|
||||
.ent vT1InterruptWrapper
|
||||
.global girq23_b1
|
||||
|
||||
girq23_b1:
|
||||
vT1InterruptWrapper:
|
||||
|
||||
portSAVE_CONTEXT
|
||||
|
||||
jal vT1InterruptHandler
|
||||
nop
|
||||
|
||||
portRESTORE_CONTEXT
|
||||
|
||||
.end vT1InterruptWrapper
|
||||
|
|
@ -0,0 +1,257 @@
|
|||
/*
|
||||
FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
|
||||
|
||||
***************************************************************************
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
***************************************************************************
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
|
||||
#include <xc.h>
|
||||
#include <sys/asm.h>
|
||||
|
||||
|
||||
.global vRegTest1
|
||||
.global vRegTest2
|
||||
|
||||
/* Reg test macro helper. Test a register for a known value branching to
|
||||
error_loop if not correct otherwise continuing on */
|
||||
.macro portREG_TEST work_reg, test_reg, test_value
|
||||
.set micromips
|
||||
.set noreorder
|
||||
.set noat
|
||||
|
||||
/* Check each register maintains the value assigned to it for the lifetime
|
||||
of the task. */
|
||||
addiu \work_reg, $0, 0x00
|
||||
addiu \work_reg, \test_reg, -\test_value
|
||||
beq \work_reg, $0, 1f
|
||||
nop
|
||||
/* The register value was not that expected. Jump to the error loop so the
|
||||
cycle counter stops incrementing. */
|
||||
b error_loop
|
||||
nop
|
||||
1:
|
||||
.endm
|
||||
|
||||
|
||||
.set micromips
|
||||
.set noreorder
|
||||
.set noat
|
||||
.ent error_loop
|
||||
|
||||
/* Reg test tasks call the error loop when they find an error. Sitting in the
|
||||
tight error loop prevents them incrementing their ulRegTestnCycles counter, and
|
||||
so allows the check softwate timer to know an error has been found. */
|
||||
error_loop:
|
||||
b error_loop
|
||||
nop
|
||||
|
||||
.end error_loop
|
||||
|
||||
|
||||
.set micromips
|
||||
.set noreorder
|
||||
.set noat
|
||||
.ent vRegTest1
|
||||
|
||||
vRegTest1:
|
||||
/* Fill the registers with known values. */
|
||||
addiu $1, $0, 0x11
|
||||
addiu $2, $0, 0x12
|
||||
addiu $3, $0, 0x13
|
||||
/* $4 contains the address of the loop counter - don't mess with $4. */
|
||||
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 $23, $0, 0x123
|
||||
addiu $24, $0, 0x124
|
||||
addiu $25, $0, 0x125
|
||||
addiu $30, $0, 0x130
|
||||
addiu $22, $0, 0x131
|
||||
|
||||
vRegTest1Loop:
|
||||
portREG_TEST $22, $1, 0x11
|
||||
portREG_TEST $22, $2, 0x12
|
||||
portREG_TEST $22, $3, 0x13
|
||||
portREG_TEST $22, $5, 0x15
|
||||
portREG_TEST $22, $6, 0x16
|
||||
portREG_TEST $22, $7, 0x17
|
||||
portREG_TEST $22, $8, 0x18
|
||||
portREG_TEST $22, $9, 0x19
|
||||
portREG_TEST $22, $10, 0x110
|
||||
portREG_TEST $22, $11, 0x111
|
||||
portREG_TEST $22, $12, 0x112
|
||||
portREG_TEST $22, $13, 0x113
|
||||
portREG_TEST $22, $14, 0x114
|
||||
portREG_TEST $22, $15, 0x115
|
||||
portREG_TEST $22, $16, 0x116
|
||||
portREG_TEST $22, $17, 0x117
|
||||
portREG_TEST $22, $18, 0x118
|
||||
portREG_TEST $22, $19, 0x119
|
||||
portREG_TEST $22, $20, 0x120
|
||||
portREG_TEST $22, $21, 0x121
|
||||
portREG_TEST $22, $23, 0x123
|
||||
portREG_TEST $22, $24, 0x124
|
||||
portREG_TEST $22, $25, 0x125
|
||||
portREG_TEST $22, $30, 0x130
|
||||
|
||||
/* No errors detected. Increment the loop count so the check timer knows
|
||||
this task is still running without error, then loop back to do it all
|
||||
again. The address of the loop counter is in $4. */
|
||||
lw $22, 0( $4 )
|
||||
addiu $22, $22, 0x01
|
||||
sw $22, 0( $4 )
|
||||
b vRegTest1Loop
|
||||
nop
|
||||
|
||||
.end vRegTest1
|
||||
|
||||
|
||||
.set micromips
|
||||
.set noreorder
|
||||
.set noat
|
||||
.ent vRegTest2
|
||||
|
||||
vRegTest2:
|
||||
addiu $1, $0, 0x21
|
||||
addiu $2, $0, 0x22
|
||||
addiu $3, $0, 0x23
|
||||
/* $4 contains the address of the loop counter - don't mess with $4. */
|
||||
addiu $5, $0, 0x25
|
||||
addiu $6, $0, 0x26
|
||||
addiu $7, $0, 0x27
|
||||
addiu $8, $0, 0x28
|
||||
addiu $9, $0, 0x29
|
||||
addiu $10, $0, 0x210
|
||||
addiu $11, $0, 0x211
|
||||
addiu $12, $0, 0x212
|
||||
addiu $13, $0, 0x213
|
||||
addiu $14, $0, 0x214
|
||||
addiu $15, $0, 0x215
|
||||
addiu $16, $0, 0x216
|
||||
addiu $17, $0, 0x217
|
||||
addiu $18, $0, 0x218
|
||||
addiu $19, $0, 0x219
|
||||
addiu $20, $0, 0x220
|
||||
addiu $21, $0, 0x221
|
||||
addiu $23, $0, 0x223
|
||||
addiu $24, $0, 0x224
|
||||
addiu $25, $0, 0x225
|
||||
addiu $30, $0, 0x230
|
||||
addiu $22, $0, 0x231
|
||||
|
||||
vRegTest2Loop:
|
||||
portREG_TEST $22, $1, 0x21
|
||||
portREG_TEST $22, $2, 0x22
|
||||
portREG_TEST $22, $3, 0x23
|
||||
portREG_TEST $22, $5, 0x25
|
||||
portREG_TEST $22, $6, 0x26
|
||||
portREG_TEST $22, $7, 0x27
|
||||
portREG_TEST $22, $8, 0x28
|
||||
portREG_TEST $22, $9, 0x29
|
||||
portREG_TEST $22, $10, 0x210
|
||||
portREG_TEST $22, $11, 0x211
|
||||
portREG_TEST $22, $12, 0x212
|
||||
portREG_TEST $22, $13, 0x213
|
||||
portREG_TEST $22, $14, 0x214
|
||||
portREG_TEST $22, $15, 0x215
|
||||
portREG_TEST $22, $16, 0x216
|
||||
portREG_TEST $22, $17, 0x217
|
||||
portREG_TEST $22, $18, 0x218
|
||||
portREG_TEST $22, $19, 0x219
|
||||
portREG_TEST $22, $20, 0x220
|
||||
portREG_TEST $22, $21, 0x221
|
||||
portREG_TEST $22, $23, 0x223
|
||||
portREG_TEST $22, $24, 0x224
|
||||
portREG_TEST $22, $25, 0x225
|
||||
portREG_TEST $22, $30, 0x230
|
||||
|
||||
/* No errors detected. Increment the loop count so the check timer knows
|
||||
this task is still running without error, then loop back to do it all
|
||||
again. The address of the loop counter is in $4. */
|
||||
lw $22, 0( $4 )
|
||||
addiu $22, $22, 0x01
|
||||
sw $22, 0( $4 )
|
||||
b vRegTest2Loop
|
||||
nop
|
||||
|
||||
.end vRegTest2
|
||||
|
||||
|
||||
|
378
FreeRTOS/Demo/PIC32MEC14xx_MPLAB/src/Full_Demo/main_full.c
Normal file
378
FreeRTOS/Demo/PIC32MEC14xx_MPLAB/src/Full_Demo/main_full.c
Normal file
|
@ -0,0 +1,378 @@
|
|||
/*
|
||||
FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
|
||||
|
||||
***************************************************************************
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
***************************************************************************
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* NOTE 1: This project provides two demo applications. A simple blinky style
|
||||
* project, and a more comprehensive test and demo application. The
|
||||
* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select
|
||||
* between the two. See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY
|
||||
* in main.c. This file implements the comprehensive test and demo version.
|
||||
*
|
||||
* NOTE 2: This file only contains the source code that is specific to the
|
||||
* full demo. Generic functions, such as FreeRTOS hook functions, and functions
|
||||
* required to configure the hardware, are defined in main.c.
|
||||
******************************************************************************
|
||||
*
|
||||
* main_full() creates all the demo application tasks and software timers, 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 also defined:
|
||||
*
|
||||
* "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.
|
||||
*
|
||||
* "High Frequency Timer Test" - The high frequency timer is created to test
|
||||
* the interrupt nesting method. The standard demo interrupt nesting test tasks
|
||||
* are created with priorities at or below configMAX_SYSCALL_INTERRUPT_PRIORITY
|
||||
* because they use interrupt safe FreeRTOS API functions. The high frequency
|
||||
* time is created with a priority above configMAX_SYSCALL_INTERRUPT_PRIORITY,
|
||||
* so cannot us the same API functions.
|
||||
*
|
||||
* "Check" timer - The check software timer period is initially set to three
|
||||
* seconds. The callback function associated with the check software timer
|
||||
* checks that all the standard demo tasks, and the register check tasks, are
|
||||
* not only still executing, but are executing without reporting any errors. If
|
||||
* the check software timer discovers that a task has either stalled, or
|
||||
* reported an error, then it changes its own execution period from the initial
|
||||
* three seconds, to just 200ms. The check software timer also toggle LED
|
||||
* mainCHECK_LED; If mainCHECK_LED toggles every 3 seconds, no errors have
|
||||
* been detected. If mainCHECK_LED toggles every 200ms then an error has been
|
||||
* detected in at least one task.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
#include "semphr.h"
|
||||
#include "timers.h"
|
||||
|
||||
/* Demo application includes. */
|
||||
#include "blocktim.h"
|
||||
#include "semtest.h"
|
||||
#include "GenQTest.h"
|
||||
#include "IntQueue.h"
|
||||
#include "countsem.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The period after which the check timer will expire, in ms, provided no errors
|
||||
have been reported by any of the standard demo tasks. ms are converted to the
|
||||
equivalent in ticks using the portTICK_PERIOD_MS constant. */
|
||||
#define mainCHECK_TIMER_PERIOD_MS pdMS_TO_TICKS( 3000UL )
|
||||
|
||||
/* The period at which the check timer will expire, in ms, if an error has been
|
||||
reported in one of the standard demo tasks. ms are converted to the equivalent
|
||||
in ticks using the portTICK_PERIOD_MS constant. */
|
||||
#define mainERROR_CHECK_TIMER_PERIOD_MS pdMS_TO_TICKS( 200UL )
|
||||
|
||||
/* The priorities of the various demo application tasks. */
|
||||
#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
||||
#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
|
||||
|
||||
/* The LED controlled by the 'check' software timer. */
|
||||
#define mainCHECK_LED ( 2 )
|
||||
|
||||
/* Misc. */
|
||||
#define mainDONT_BLOCK ( 0 )
|
||||
|
||||
/* The frequency at which the "high frequency interrupt" interrupt will
|
||||
occur. */
|
||||
#define mainTEST_INTERRUPT_FREQUENCY ( 20000 )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* The check timer callback function, as described at the top of this file.
|
||||
*/
|
||||
static void prvCheckTimerCallback( TimerHandle_t xTimer );
|
||||
|
||||
/*
|
||||
* It is important to ensure the high frequency timer test does not start before
|
||||
* the kernel. It is therefore started from inside a software timer callback
|
||||
* function, which will not execute until the timer service/daemon task is
|
||||
* executing. A one-shot timer is used, so the callback function will only
|
||||
* execute once (unless it is manually reset/restarted).
|
||||
*/
|
||||
static void prvSetupHighFrequencyTimerTest( TimerHandle_t xTimer );
|
||||
|
||||
/*
|
||||
* 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 prvRegTestTask1( void *pvParameters );
|
||||
static void prvRegTestTask2( void *pvParameters );
|
||||
|
||||
/*
|
||||
* LED toggle function that uses a critical section to ensure thread safety.
|
||||
*/
|
||||
extern void vToggleLED( uint8_t ucLED );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Variables incremented by prvRegTestTask1() and prvRegTestTask2() respectively
|
||||
on each iteration of their function. These are used to detect errors in the
|
||||
reg test tasks. */
|
||||
volatile unsigned long ulRegTest1Cycles = 0, ulRegTest2Cycles = 0;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Create the demo tasks then start the scheduler.
|
||||
*/
|
||||
int main_full( void )
|
||||
{
|
||||
TimerHandle_t xTimer = NULL;
|
||||
|
||||
/* Create all the other standard demo tasks. */
|
||||
vCreateBlockTimeTasks();
|
||||
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
|
||||
vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
|
||||
vStartInterruptQueueTasks();
|
||||
vStartCountingSemaphoreTasks();
|
||||
|
||||
/* Create the tasks defined within this file. */
|
||||
xTaskCreate( prvRegTestTask1, /* The function that implements the task. */
|
||||
"Reg1", /* Text name for the task to assist debugger - not used by FreeRTOS itself. */
|
||||
configMINIMAL_STACK_SIZE, /* The stack size to allocate for the task - specified in words not bytes. */
|
||||
NULL, /* The parameter to pass into the task - not used in this case so set to NULL. */
|
||||
tskIDLE_PRIORITY, /* The priority to assign to the task. */
|
||||
NULL ); /* Used to obtain a handle to the task being created - not used in this case so set to NULL. */
|
||||
|
||||
xTaskCreate( prvRegTestTask2, "Reg2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||
|
||||
/* Create the software timer that performs the 'check' functionality, as
|
||||
described at the top of this file. */
|
||||
xTimer = xTimerCreate( "CheckTimer",/* A text name, purely to help debugging. */
|
||||
( mainCHECK_TIMER_PERIOD_MS ), /* The timer period, in this case 3000ms (3s). */
|
||||
pdTRUE, /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */
|
||||
( void * ) 0, /* The ID is not used, so can be set to anything. */
|
||||
prvCheckTimerCallback ); /* The callback function that inspects the status of all the other tasks. */
|
||||
|
||||
if( xTimer != NULL )
|
||||
{
|
||||
xTimerStart( xTimer, mainDONT_BLOCK );
|
||||
}
|
||||
|
||||
/* A software timer is also used to start the high frequency timer test.
|
||||
This is to ensure the test does not start before the kernel. This time a
|
||||
one shot software timer is used. */
|
||||
xTimer = xTimerCreate( "HighHzTimerSetup", 1, pdFALSE, ( void * ) 0, prvSetupHighFrequencyTimerTest );
|
||||
if( xTimer != NULL )
|
||||
{
|
||||
xTimerStart( xTimer, mainDONT_BLOCK );
|
||||
}
|
||||
|
||||
/* Finally start the scheduler. */
|
||||
vTaskStartScheduler();
|
||||
|
||||
/* If all is well, the scheduler will now be running, and the following line
|
||||
will never be reached. If the following line does execute, then there was
|
||||
insufficient FreeRTOS heap memory available for the idle and/or timer tasks
|
||||
to be created. See the memory management section on the FreeRTOS web site
|
||||
for more details. http://www.freertos.org/a00111.html */
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvRegTestTask1( void *pvParameters )
|
||||
{
|
||||
extern void vRegTest1( volatile unsigned long * );
|
||||
|
||||
/* Avoid compiler warnings. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Pass the address of the RegTest1 loop counter into the test function,
|
||||
which is necessarily implemented in assembler. */
|
||||
vRegTest1( &ulRegTest1Cycles );
|
||||
|
||||
/* vRegTest1 should never exit! */
|
||||
vTaskDelete( NULL );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvRegTestTask2( void *pvParameters )
|
||||
{
|
||||
extern void vRegTest2( volatile unsigned long * );
|
||||
|
||||
/* Avoid compiler warnings. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Pass the address of the RegTest2 loop counter into the test function,
|
||||
which is necessarily implemented in assembler. */
|
||||
vRegTest2( &ulRegTest2Cycles );
|
||||
|
||||
/* vRegTest1 should never exit! */
|
||||
vTaskDelete( NULL );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCheckTimerCallback( TimerHandle_t xTimer )
|
||||
{
|
||||
static long lChangedTimerPeriodAlready = pdFALSE;
|
||||
static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0, ulLastHighFrequencyTimerInterrupts = 0;
|
||||
static const unsigned long ulExpectedHighFrequencyInterrupts = ( ( mainTEST_INTERRUPT_FREQUENCY / 1000UL ) * mainCHECK_TIMER_PERIOD_MS ) - 10; /* 10 allows for a margin of error. */
|
||||
unsigned long ulErrorOccurred = pdFALSE;
|
||||
/* The count of the high frequency timer interrupts. */
|
||||
extern unsigned long ulHighFrequencyTimerInterrupts;
|
||||
|
||||
/* Avoid compiler warnings. */
|
||||
( void ) xTimer;
|
||||
|
||||
/* Check that the register test 1 task is still running. */
|
||||
if( ulLastRegTest1Value == ulRegTest1Cycles )
|
||||
{
|
||||
ulErrorOccurred |= ( 0x01UL << 1UL );
|
||||
}
|
||||
ulLastRegTest1Value = ulRegTest1Cycles;
|
||||
|
||||
/* Check that the register test 2 task is still running. */
|
||||
if( ulLastRegTest2Value == ulRegTest2Cycles )
|
||||
{
|
||||
ulErrorOccurred |= ( 0x01UL << 2UL );
|
||||
}
|
||||
ulLastRegTest2Value = ulRegTest2Cycles;
|
||||
|
||||
/* Have any of the standard demo tasks detected an error in their
|
||||
operation? */
|
||||
if( xAreGenericQueueTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulErrorOccurred |= ( 0x01UL << 3UL );
|
||||
}
|
||||
else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulErrorOccurred |= ( 0x01UL << 4UL );
|
||||
}
|
||||
else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulErrorOccurred |= ( 0x01UL << 5UL );
|
||||
}
|
||||
else if( xAreIntQueueTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulErrorOccurred |= ( 0x01UL << 6UL );
|
||||
}
|
||||
else if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
ulErrorOccurred |= ( 0x01UL << 7UL );
|
||||
}
|
||||
|
||||
/* Ensure the expected number of high frequency interrupts have occurred. */
|
||||
if( ulLastHighFrequencyTimerInterrupts != 0 )
|
||||
{
|
||||
if( ( ulHighFrequencyTimerInterrupts - ulLastHighFrequencyTimerInterrupts ) < ulExpectedHighFrequencyInterrupts )
|
||||
{
|
||||
ulErrorOccurred |= ( 0x01UL << 8UL );
|
||||
}
|
||||
}
|
||||
ulLastHighFrequencyTimerInterrupts = ulHighFrequencyTimerInterrupts;
|
||||
|
||||
if( ulErrorOccurred != pdFALSE )
|
||||
{
|
||||
/* An error occurred. Increase the frequency at which the check timer
|
||||
toggles its LED to give visual feedback of the potential error
|
||||
condition. */
|
||||
if( lChangedTimerPeriodAlready == pdFALSE )
|
||||
{
|
||||
lChangedTimerPeriodAlready = pdTRUE;
|
||||
|
||||
/* This call to xTimerChangePeriod() uses a zero block time.
|
||||
Functions called from inside of a timer callback function must
|
||||
*never* attempt to block as to do so could impact other software
|
||||
timers. */
|
||||
xTimerChangePeriod( xTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK );
|
||||
}
|
||||
}
|
||||
|
||||
vToggleLED( mainCHECK_LED );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSetupHighFrequencyTimerTest( TimerHandle_t xTimer )
|
||||
{
|
||||
void vSetupTimerTest( unsigned short usFrequencyHz );
|
||||
|
||||
/* Prevent compiler warnings */
|
||||
(void) xTimer;
|
||||
|
||||
/* Setup the high frequency, high priority, timer test. It is setup in this
|
||||
software timer callback to ensure it does not start before the kernel does.
|
||||
This is a one shot timer - so the setup routine will only be executed once. */
|
||||
|
||||
vSetupTimerTest( mainTEST_INTERRUPT_FREQUENCY );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
144
FreeRTOS/Demo/PIC32MEC14xx_MPLAB/src/Full_Demo/timertest.c
Normal file
144
FreeRTOS/Demo/PIC32MEC14xx_MPLAB/src/Full_Demo/timertest.c
Normal file
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that has become a de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly and support the FreeRTOS *
|
||||
* project by purchasing a FreeRTOS tutorial book, reference *
|
||||
* manual, or both from: http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
* Thank you! *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
|
||||
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. Full license text is available from the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Having a problem? Start by reading the FAQ "My application does *
|
||||
* not run, what could be wrong?" *
|
||||
* *
|
||||
* http://www.FreeRTOS.org/FAQHelp.html *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, books, training, latest versions,
|
||||
license and Real Time Engineers Ltd. contact details.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
|
||||
Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/* High speed timer test as described in main.c. */
|
||||
|
||||
/* System port includes */
|
||||
#include "appcfg.h"
|
||||
#include "platform.h"
|
||||
#include "MEC14xx/mec14xx.h"
|
||||
#include "MEC14xx/mec14xx_girqs.h"
|
||||
|
||||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
/* The priority of the high speed timer interrupt. */
|
||||
#define timerTEST_INT_PRIORITY ( 7 )
|
||||
|
||||
/* MEC14xx Timer 3 Timer MMCR's */
|
||||
#define portMMCR_TMR3_COUNT *((volatile uint32_t *)(0xA0000C60ul))
|
||||
#define portMMCR_TMR3_PRELOAD *((volatile uint32_t *)(0xA0000C64ul))
|
||||
#define portMMCR_TMR3_STATUS *((volatile uint32_t *)(0xA0000C68ul))
|
||||
#define portMMCR_TMR3_INTEN *((volatile uint32_t *)(0xA0000C6Cul))
|
||||
#define portMMCR_TMR3_CONTROL *((volatile uint32_t *)(0xA0000C70ul))
|
||||
|
||||
/* MEC14xx JTVIC external interrupt controller
|
||||
* is mapped to M14K closely-coupled peripheral space.
|
||||
*/
|
||||
#define portGIRQ23_TMR3_TIMER_BITPOS (3)
|
||||
#define portGIRQ23_TMR3_TIMER_MASK (1ul << (portGIRQ23_TMR3_TIMER_BITPOS))
|
||||
#define portMMCR_JTVIC_GIRQ23_SRC *((volatile uint32_t *)(0xBFFFC0F0ul))
|
||||
#define portMMCR_JTVIC_GIRQ23_SETEN *((volatile uint32_t *)(0xBFFFC0F4ul))
|
||||
#define portMMCR_JTVIC_GIRQ23_PRIA *((volatile uint32_t *)(0xBFFFC3F0ul))
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Incremented every 20,000 interrupts, so should count in seconds. */
|
||||
unsigned long ulHighFrequencyTimerInterrupts = 0;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vSetupTimerTest( unsigned short usFrequencyHz )
|
||||
{
|
||||
/* Timer 3 is going to interrupt at usFrequencyHz Hz. */
|
||||
const uint32_t ulPreload = ( unsigned short ) ( ( configPERIPHERAL_CLOCK_HZ / ( unsigned long ) usFrequencyHz ) - 1 );
|
||||
|
||||
/* Timer 3 is used to generate interrupts above the kernel and max syscall
|
||||
interrupt priorities. No system library calls are used here as they are not
|
||||
guaranteed to be re-entrant. */
|
||||
portMMCR_TMR3_CONTROL = 1ul;
|
||||
portMMCR_TMR3_PRELOAD = ulPreload;
|
||||
portMMCR_TMR3_COUNT = ulPreload;
|
||||
portMMCR_TMR3_INTEN = 0x0001ul;
|
||||
portMMCR_TMR3_STATUS = 0x0001ul;
|
||||
/* Enable Timer 3, and set for auto restart, counting down. */
|
||||
portMMCR_TMR3_CONTROL |= 0x0008;
|
||||
portMMCR_TMR3_CONTROL |= 0x0020;
|
||||
|
||||
/* Configure interrupts from the Timer 3. */
|
||||
portMMCR_JTVIC_GIRQ23_SRC = ( portGIRQ23_TMR3_TIMER_MASK );
|
||||
portMMCR_JTVIC_GIRQ23_PRIA &= ~( 0x0Ful << 12 );
|
||||
portMMCR_JTVIC_GIRQ23_PRIA |= ( ( portIPL_TO_CODE( timerTEST_INT_PRIORITY ) ) << 12 );
|
||||
portMMCR_JTVIC_GIRQ23_SETEN = ( portGIRQ23_TMR3_TIMER_MASK );
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Interrupt handler for Timer 3 interrupts, no library functions are used
|
||||
here as they may not be re-entrant. */
|
||||
void __attribute__((interrupt, nomips16)) girq23_b3( void )
|
||||
{
|
||||
ulHighFrequencyTimerInterrupts++;
|
||||
|
||||
/* The interrupt flag registered is shared with the lower priority timer
|
||||
interrupts and the RTOS timer so disable interrupts here. This is not
|
||||
strictly necessary since this is the highest priority interrupt. */
|
||||
__asm volatile( "di" );
|
||||
/* Clear the timer interrupt. */
|
||||
portMMCR_JTVIC_GIRQ23_SRC = portGIRQ23_TMR3_TIMER_MASK;
|
||||
__asm volatile( "ei" );
|
||||
}
|
||||
|
||||
|
75
FreeRTOS/Demo/PIC32MEC14xx_MPLAB/src/Full_Demo/timertest.h
Normal file
75
FreeRTOS/Demo/PIC32MEC14xx_MPLAB/src/Full_Demo/timertest.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that has become a de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly and support the FreeRTOS *
|
||||
* project by purchasing a FreeRTOS tutorial book, reference *
|
||||
* manual, or both from: http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
* Thank you! *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
|
||||
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. Full license text is available from the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Having a problem? Start by reading the FAQ "My application does *
|
||||
* not run, what could be wrong?" *
|
||||
* *
|
||||
* http://www.FreeRTOS.org/FAQHelp.html *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, books, training, latest versions,
|
||||
license and Real Time Engineers Ltd. contact details.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
|
||||
Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#ifndef TIMER_TEST_H
|
||||
#define TIMER_TEST_H
|
||||
|
||||
/* Setup the high frequency timer interrupt. */
|
||||
void vSetupTimerTest( unsigned short usFrequencyHz );
|
||||
|
||||
#endif /* TIMER_TEST_H */
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue