summaryrefslogtreecommitdiff
path: root/FreeRTOS
diff options
context:
space:
mode:
authorRichard Barry <ribarry@amazon.com>2012-10-16 09:48:45 +0000
committerRichard Barry <ribarry@amazon.com>2012-10-16 09:48:45 +0000
commitf446f77fd413b150fd92357bb52515811109b0ee (patch)
tree28b24e55dbe788cce0e90cc35e8abf49c2b19ae4 /FreeRTOS
parentdbe0ae2bffc79c8f0545abecbae8a16476585d52 (diff)
downloadfreertos-git-f446f77fd413b150fd92357bb52515811109b0ee.tar.gz
Make the timer used for the PIC32 port layer user configurable.
Diffstat (limited to 'FreeRTOS')
-rw-r--r--FreeRTOS/Source/portable/MPLAB/PIC32MX/port.c20
-rw-r--r--FreeRTOS/Source/portable/MPLAB/PIC32MX/port_asm.S8
2 files changed, 19 insertions, 9 deletions
diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MX/port.c b/FreeRTOS/Source/portable/MPLAB/PIC32MX/port.c
index 7c22b4933..538c9bee8 100644
--- a/FreeRTOS/Source/portable/MPLAB/PIC32MX/port.c
+++ b/FreeRTOS/Source/portable/MPLAB/PIC32MX/port.c
@@ -83,6 +83,10 @@
the first task is being restored. */
#define portINITIAL_SR ( portIE_BIT | portEXL_BIT )
+#ifndef configTICK_INTERRUPT_VECTOR
+ #define configTICK_INTERRUPT_VECTOR _TIMER_1_VECTOR
+#endif
+
/* Records the interrupt nesting depth. This starts at one as it will be
decremented to 0 when the first task starts. */
volatile unsigned portBASE_TYPE uxInterruptNesting = 0x01;
@@ -101,9 +105,9 @@ const portSTACK_TYPE * const xISRStackTop = &( xISRStack[ configISR_STACK_SIZE -
* Place the prototype here to ensure the interrupt vector is correctly installed.
* Note that because the interrupt is written in assembly, the IPL setting in the
* following line of code has no effect. The interrupt priority is set by the
- * call to ConfigIntTimer1() in prvSetupTimerInterrupt().
+ * call to ConfigIntTimer1() in vApplicationSetupTickTimerInterrupt().
*/
-extern void __attribute__( (interrupt(ipl1), vector(_TIMER_1_VECTOR))) vT1InterruptHandler( void );
+extern void __attribute__( (interrupt(ipl1), vector( configTICK_INTERRUPT_VECTOR ))) vPortTickInterruptHandler( void );
/*
* The software interrupt handler that performs the yield. Note that, because
@@ -152,9 +156,15 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
/*-----------------------------------------------------------*/
/*
- * Setup a timer for a regular tick.
+ * Setup a timer for a regular tick. This function uses peripheral timer 1.
+ * The function is declared weak so an application writer can use a different
+ * timer by redefining this implementation. If a different timer is used then
+ * configTICK_INTERRUPT_VECTOR must also be defined in FreeRTOSConfig.h to
+ * ensure the RTOS provided tick interrupt handler is installed on the correct
+ * vector number. When Timer 1 is used the vector number is defined as
+ * _TIMER_1_VECTOR.
*/
-void prvSetupTimerInterrupt( void )
+__attribute__(( weak )) void vApplicationSetupTickTimerInterrupt( void )
{
const unsigned long ulCompareMatch = ( (configPERIPHERAL_CLOCK_HZ / portTIMER_PRESCALE) / configTICK_RATE_HZ ) - 1;
@@ -182,7 +192,7 @@ extern void *pxCurrentTCB;
/* Setup the timer to generate the tick. Interrupts will have been
disabled by the time we get here. */
- prvSetupTimerInterrupt();
+ vApplicationSetupTickTimerInterrupt();
/* Kick off the highest priority task that has been created so far.
Its stack location is loaded into uxSavedTaskStackPointer. */
diff --git a/FreeRTOS/Source/portable/MPLAB/PIC32MX/port_asm.S b/FreeRTOS/Source/portable/MPLAB/PIC32MX/port_asm.S
index 8d4a4eab8..722a5c3bb 100644
--- a/FreeRTOS/Source/portable/MPLAB/PIC32MX/port_asm.S
+++ b/FreeRTOS/Source/portable/MPLAB/PIC32MX/port_asm.S
@@ -79,16 +79,16 @@
.global vPortStartFirstTask
.global vPortYieldISR
- .global vT1InterruptHandler
+ .global vPortTickInterruptHandler
/******************************************************************/
.set noreorder
.set noat
- .ent vT1InterruptHandler
+ .ent vPortTickInterruptHandler
-vT1InterruptHandler:
+vPortTickInterruptHandler:
portSAVE_CONTEXT
@@ -97,7 +97,7 @@ vT1InterruptHandler:
portRESTORE_CONTEXT
- .end vT1InterruptHandler
+ .end vPortTickInterruptHandler
/******************************************************************/