#error Missing definition: configMAX_PRIORITIES must be defined in FreeRTOSConfig.h. See the Configuration section of the FreeRTOS API documentation for details.\r
#endif\r
\r
+#if configMAX_PRIORITIES < 1\r
+ #error configMAX_PRIORITIES must be defined to be greater than or equal to 1.\r
+#endif\r
+\r
#ifndef configUSE_PREEMPTION\r
#error Missing definition: configUSE_PREEMPTION must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.\r
#endif\r
#error Missing definition: configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.\r
#endif\r
\r
-#ifndef configMAX_PRIORITIES\r
- #error configMAX_PRIORITIES must be defined to be greater than or equal to 1.\r
-#endif\r
-\r
#ifndef configUSE_CO_ROUTINES\r
#define configUSE_CO_ROUTINES 0\r
#endif\r
}\r
#endif /* configUSE_TICKLESS_IDLE */\r
\r
+ /* Stop and clear the SysTick. */\r
+ portNVIC_SYSTICK_CTRL_REG = 0UL;\r
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );\r
;/* Save the new top of stack into the first member of the TCB. */\r
str r0, [r2]\r
\r
+ ;/* Ensure thread safety of atomic operations. */\r
+ clrex\r
+\r
stmdb sp!, {r3}\r
ldr r0, ulMaxSyscallInterruptPriorityConst\r
ldr r1, [r0]\r
#include "task.h"\r
\r
/* Constants required to manipulate the NVIC. */\r
-#define portNVIC_SYSTICK_CTRL ( ( volatile uint32_t *) 0xe000e010 )\r
-#define portNVIC_SYSTICK_LOAD ( ( volatile uint32_t *) 0xe000e014 )\r
+#define portNVIC_SYSTICK_CTRL ( ( volatile uint32_t * ) 0xe000e010 )\r
+#define portNVIC_SYSTICK_LOAD ( ( volatile uint32_t * ) 0xe000e014 )\r
+#define portNVIC_SYSTICK_CURRENT_VALUE ( ( volatile uint32_t * ) 0xe000e018 )\r
#define portNVIC_INT_CTRL ( ( volatile uint32_t *) 0xe000ed04 )\r
#define portNVIC_SYSPRI2 ( ( volatile uint32_t *) 0xe000ed20 )\r
#define portNVIC_SYSTICK_CLK 0x00000004\r
" mov r5, r9 \n"\r
" mov r6, r10 \n"\r
" mov r7, r11 \n"\r
- " stmia r0!, {r4-r7} \n"\r
+ " stmia r0!, {r4-r7} \n"\r
" \n"\r
" push {r3, r14} \n"\r
" cpsid i \n"\r
" msr psp, r0 \n" /* Remember the new top of stack for the task. */\r
" \n"\r
" sub r0, r0, #32 \n" /* Go back for the low registers that are not automatically restored. */\r
- " ldmia r0!, {r4-r7} \n" /* Pop low registers. */\r
+ " ldmia r0!, {r4-r7} \n" /* Pop low registers. */\r
" \n"\r
" bx r3 \n"\r
" \n"\r
*/\r
void prvSetupTimerInterrupt( void )\r
{\r
+ /* Stop and reset the SysTick. */\r
+ *(portNVIC_SYSTICK_CTRL) = 0UL;\r
+ *(portNVIC_SYSTICK_CURRENT_VALUE) = 0UL;\r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
*(portNVIC_SYSTICK_LOAD) = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
*(portNVIC_SYSTICK_CTRL) = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE;\r
" \n"\r
" stmdb r0!, {r4-r11} \n" /* Save the remaining registers. */\r
" str r0, [r2] \n" /* Save the new top of stack into the first member of the TCB. */\r
+ " clrex \n" /* Ensure thread safety of atomic operations. */\r
" \n"\r
" stmdb sp!, {r3, r14} \n"\r
" mov r0, %0 \n"\r
}\r
#endif /* configUSE_TICKLESS_IDLE */\r
\r
+ /* Stop and clear the SysTick. */\r
+ portNVIC_SYSTICK_CTRL_REG = 0UL;\r
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );\r
/* Constants required to access and manipulate the NVIC. */\r
#define portNVIC_SYSTICK_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000e010 ) )\r
#define portNVIC_SYSTICK_LOAD_REG ( * ( ( volatile uint32_t * ) 0xe000e014 ) )\r
+#define portNVIC_SYSTICK_CURRENT_VALUE_REG ( * ( ( volatile uint32_t * ) 0xe000e018 ) )\r
#define portNVIC_SYSPRI2_REG ( * ( ( volatile uint32_t * ) 0xe000ed20 ) )\r
#define portNVIC_SYSPRI1_REG ( * ( ( volatile uint32_t * ) 0xe000ed1c ) )\r
#define portNVIC_SYS_CTRL_STATE_REG ( * ( ( volatile uint32_t * ) 0xe000ed24 ) )\r
" mrs r1, control \n"\r
" stmdb r0!, {r1, r4-r11} \n" /* Save the remaining registers. */\r
" str r0, [r2] \n" /* Save the new top of stack into the first member of the TCB. */\r
+ " clrex \n" /* Ensure thread safety of atomic operations. */\r
" \n"\r
" stmdb sp!, {r3, r14} \n"\r
" mov r0, %0 \n"\r
*/\r
static void prvSetupTimerInterrupt( void )\r
{\r
+ /* Reset the SysTick timer. */\r
+ portNVIC_SYSTICK_CTRL_REG = 0UL;\r
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
portNVIC_SYSTICK_LOAD_REG = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE;\r
" vstmdbeq r0!, {s16-s31} \n"\r
" \n"\r
" stmdb r0!, {r4-r11, r14} \n" /* Save the core registers. */\r
- " \n"\r
" str r0, [r2] \n" /* Save the new top of stack into the first member of the TCB. */\r
+ " clrex \n" /* Ensure thread safety of atomic operations. */\r
" \n"\r
" stmdb sp!, {r3} \n"\r
" mov r0, %0 \n"\r
}\r
#endif /* configUSE_TICKLESS_IDLE */\r
\r
+ /* Stop and clear the SysTick. */\r
+ portNVIC_SYSTICK_CTRL_REG = 0UL;\r
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );\r
/* Constants required to access and manipulate the NVIC. */\r
#define portNVIC_SYSTICK_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000e010 ) )\r
#define portNVIC_SYSTICK_LOAD_REG ( * ( ( volatile uint32_t * ) 0xe000e014 ) )\r
+#define portNVIC_SYSTICK_CURRENT_VALUE_REG ( * ( ( volatile uint32_t * ) 0xe000e018 ) )\r
#define portNVIC_SYSPRI2_REG ( * ( ( volatile uint32_t * ) 0xe000ed20 ) )\r
#define portNVIC_SYSPRI1_REG ( * ( ( volatile uint32_t * ) 0xe000ed1c ) )\r
#define portNVIC_SYS_CTRL_STATE_REG ( * ( ( volatile uint32_t * ) 0xe000ed24 ) )\r
* Function to enable the VFP.\r
*/\r
static void vPortEnableVFP( void ) __attribute__ (( naked ));\r
- \r
+\r
/*\r
* Used by the portASSERT_IF_INTERRUPT_PRIORITY_INVALID() macro to ensure\r
* FreeRTOS API functions are not called from interrupts that have been assigned\r
*pxTopOfStack = 0; /* LR */\r
pxTopOfStack -= 5; /* R12, R3, R2 and R1. */\r
*pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */\r
- \r
+\r
/* A save method is being used that requires each task to maintain its\r
own exec return value. */\r
pxTopOfStack--;\r
*pxTopOfStack = portINITIAL_EXEC_RETURN;\r
- \r
+\r
pxTopOfStack -= 9; /* R11, R10, R9, R8, R7, R6, R5 and R4. */\r
\r
if( xRunPrivileged == pdTRUE )\r
" mrs r1, control \n"\r
" stmdb r0!, {r1, r4-r11, r14} \n" /* Save the remaining registers. */\r
" str r0, [r2] \n" /* Save the new top of stack into the first member of the TCB. */\r
+ " clrex \n" /* Ensure thread safety of atomic operations. */\r
" \n"\r
" stmdb sp!, {r3} \n"\r
" mov r0, %0 \n"\r
*/\r
static void prvSetupTimerInterrupt( void )\r
{\r
+ /* Clear the SysTick. */\r
+ portNVIC_SYSTICK_CTRL_REG = 0UL;\r
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
portNVIC_SYSTICK_LOAD_REG = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE;\r
" vstmdbeq r0!, {s16-s31} \n"\r
" \n"\r
" stmdb r0!, {r4-r11, r14} \n" /* Save the core registers. */\r
- " \n"\r
" str r0, [r2] \n" /* Save the new top of stack into the first member of the TCB. */\r
+ " clrex \n" /* Ensure thread safety of atomic operations. */\r
" \n"\r
" stmdb sp!, {r3} \n"\r
" mov r0, %0 \n"\r
}\r
#endif /* configUSE_TICKLESS_IDLE */\r
\r
+ /* Stop and clear the SysTick. */\r
+ portNVIC_SYSTICK_CTRL_REG = 0UL;\r
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );\r
#include "task.h"\r
\r
/* Constants required to manipulate the NVIC. */\r
-#define portNVIC_SYSTICK_CTRL ( ( volatile uint32_t *) 0xe000e010 )\r
-#define portNVIC_SYSTICK_LOAD ( ( volatile uint32_t *) 0xe000e014 )\r
+#define portNVIC_SYSTICK_CTRL ( ( volatile uint32_t * ) 0xe000e010 )\r
+#define portNVIC_SYSTICK_LOAD ( ( volatile uint32_t * ) 0xe000e014 )\r
+#define portNVIC_SYSTICK_CURRENT_VALUE ( ( volatile uint32_t * ) 0xe000e018 )\r
#define portNVIC_SYSPRI2 ( ( volatile uint32_t *) 0xe000ed20 )\r
#define portNVIC_SYSTICK_CLK 0x00000004\r
#define portNVIC_SYSTICK_INT 0x00000002\r
*/\r
static void prvSetupTimerInterrupt( void )\r
{\r
+ /* Stop and reset the SysTick. */\r
+ *(portNVIC_SYSTICK_CTRL) = 0UL;\r
+ *(portNVIC_SYSTICK_CURRENT_VALUE) = 0UL;\r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
*(portNVIC_SYSTICK_LOAD) = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
*(portNVIC_SYSTICK_CTRL) = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE;\r
}\r
#endif /* configUSE_TICKLESS_IDLE */\r
\r
+ /* Stop and clear the SysTick. */\r
+ portNVIC_SYSTICK_CTRL_REG = 0UL;\r
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );\r
\r
stmdb r0!, {r4-r11} /* Save the remaining registers. */\r
str r0, [r2] /* Save the new top of stack into the first member of the TCB. */\r
+ clrex /* Ensure thread safety of atomic operations. */\r
\r
stmdb sp!, {r3, r14}\r
mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
}\r
#endif /* configUSE_TICKLESS_IDLE */\r
\r
+ /* Stop and clear the SysTick. */\r
+ portNVIC_SYSTICK_CTRL_REG = 0UL;\r
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );\r
/* Save the new top of stack into the first member of the TCB. */\r
str r0, [r2]\r
\r
+ /* Ensure thread safety of atomic operations. */\r
+ clrex\r
+\r
stmdb sp!, {r3}\r
mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
msr basepri, r0\r
}\r
#endif /* configUSE_TICKLESS_IDLE */\r
\r
+ /* Stop and clear the SysTick. */\r
+ portNVIC_SYSTICK_CTRL_REG = 0UL;\r
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );\r
/* Save the new top of stack into the first member of the TCB. */\r
str r0, [r2]\r
\r
+ /* Ensure thread safety of atomic operations. */\r
+ clrex\r
+\r
stmdb sp!, {r3}\r
mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
cpsid i\r
stmdb r0!, (r4-r11, r14) /* Save the core registers. */\r
\r
str r0, [r2] /* Save the new top of stack into the first member of the TCB. */\r
-/*_RB_? mrs r0, psp why was this here? */\r
+\r
+ clrex /* Ensure thread safety of atomic operations. */\r
\r
stmdb sp!, (r3)\r
ldr r0, =_ucMaxSyscallInterruptPriority\r
#if( configOVERRIDE_DEFAULT_TICK_CONFIGURATION == 0 )\r
\r
void vPortSetupTimerInterrupt( void )\r
- {\r
- /* Calculate the constants required to configure the tick interrupt. */\r
- #if configUSE_TICKLESS_IDLE == 1\r
- {\r
- ulTimerCountsForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ );\r
- xMaximumPossibleSuppressedTicks = portMAX_24_BIT_NUMBER / ulTimerCountsForOneTick;\r
- ulStoppedTimerCompensation = portMISSED_COUNTS_FACTOR / ( configCPU_CLOCK_HZ / configSYSTICK_CLOCK_HZ );\r
- }\r
- #endif /* configUSE_TICKLESS_IDLE */\r
+ {\r
+ /* Calculate the constants required to configure the tick interrupt. */\r
+ #if configUSE_TICKLESS_IDLE == 1\r
+ {\r
+ ulTimerCountsForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ );\r
+ xMaximumPossibleSuppressedTicks = portMAX_24_BIT_NUMBER / ulTimerCountsForOneTick;\r
+ ulStoppedTimerCompensation = portMISSED_COUNTS_FACTOR / ( configCPU_CLOCK_HZ / configSYSTICK_CLOCK_HZ );\r
+ }\r
+ #endif /* configUSE_TICKLESS_IDLE */\r
\r
- /* Configure SysTick to interrupt at the requested rate. */\r
- portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
- portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );\r
- }\r
+ /* Reset SysTick. */\r
+ portNVIC_SYSTICK_CTRL_REG = 0UL;\r
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
+\r
+ /* Configure SysTick to interrupt at the requested rate. */\r
+ portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
+ portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );\r
+ }\r
\r
#endif /* configOVERRIDE_DEFAULT_TICK_CONFIGURATION */\r
/*-----------------------------------------------------------*/\r
#include "task.h"\r
\r
/* Constants required to manipulate the NVIC. */\r
-#define portNVIC_SYSTICK_CTRL ( ( volatile uint32_t *) 0xe000e010 )\r
-#define portNVIC_SYSTICK_LOAD ( ( volatile uint32_t *) 0xe000e014 )\r
+#define portNVIC_SYSTICK_CTRL ( ( volatile uint32_t * ) 0xe000e010 )\r
+#define portNVIC_SYSTICK_LOAD ( ( volatile uint32_t * ) 0xe000e014 )\r
+#define portNVIC_SYSTICK_CURRENT_VALUE ( ( volatile uint32_t * ) 0xe000e018 )\r
#define portNVIC_INT_CTRL ( ( volatile uint32_t *) 0xe000ed04 )\r
#define portNVIC_SYSPRI2 ( ( volatile uint32_t *) 0xe000ed20 )\r
#define portNVIC_SYSTICK_CLK 0x00000004\r
*/\r
void prvSetupTimerInterrupt( void )\r
{\r
+ /* Stop and reset the SysTick. */\r
+ *(portNVIC_SYSTICK_CTRL) = 0UL;\r
+ *(portNVIC_SYSTICK_CURRENT_VALUE) = 0UL;\r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
*(portNVIC_SYSTICK_LOAD) = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
*(portNVIC_SYSTICK_CTRL) = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE;\r
\r
stmdb r0!, {r4-r11} /* Save the remaining registers. */\r
str r0, [r2] /* Save the new top of stack into the first member of the TCB. */\r
+ clrex /* Ensure thread safety of atomic operations. */\r
\r
stmdb sp!, {r3, r14}\r
mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
}\r
#endif /* configUSE_TICKLESS_IDLE */\r
\r
+ /* Stop and clear the SysTick. */\r
+ portNVIC_SYSTICK_CTRL_REG = 0UL;\r
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );\r
/* Save the new top of stack into the first member of the TCB. */\r
str r0, [r2]\r
\r
+ /* Ensure thread safety of atomic operations. */\r
+ clrex\r
+\r
stmdb sp!, {r3}\r
mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
msr basepri, r0\r
* Setup the SysTick timer to generate the tick interrupts at the required\r
* frequency.\r
*/\r
-#if configOVERRIDE_DEFAULT_TICK_CONFIGURATION == 0\r
+#if( configOVERRIDE_DEFAULT_TICK_CONFIGURATION == 0 )\r
\r
void vPortSetupTimerInterrupt( void )\r
{\r
}\r
#endif /* configUSE_TICKLESS_IDLE */\r
\r
+ /* Stop and clear the SysTick. */\r
+ portNVIC_SYSTICK_CTRL_REG = 0UL;\r
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );\r
/* Constants required to access and manipulate the NVIC. */\r
#define portNVIC_SYSTICK_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000e010 ) )\r
#define portNVIC_SYSTICK_LOAD_REG ( * ( ( volatile uint32_t * ) 0xe000e014 ) )\r
+#define portNVIC_SYSTICK_CURRENT_VALUE_REG ( * ( ( volatile uint32_t * ) 0xe000e018 ) )\r
#define portNVIC_SYSPRI2_REG ( * ( ( volatile uint32_t * ) 0xe000ed20 ) )\r
#define portNVIC_SYSPRI1_REG ( * ( ( volatile uint32_t * ) 0xe000ed1c ) )\r
#define portNVIC_SYS_CTRL_STATE_REG ( * ( ( volatile uint32_t * ) 0xe000ed24 ) )\r
* Utility function.\r
*/\r
static uint32_t prvPortGetIPSR( void );\r
- \r
+\r
/*\r
* Used by the portASSERT_IF_INTERRUPT_PRIORITY_INVALID() macro to ensure\r
* FreeRTOS API functions are not called from interrupts that have been assigned\r
__asm void vPortSVCHandler( void )\r
{\r
extern prvSVCHandler\r
- \r
+\r
PRESERVE8\r
\r
/* Assumes psp was in use. */\r
__asm void prvStartFirstTask( void )\r
{\r
PRESERVE8\r
- \r
+\r
ldr r0, =0xE000ED08 /* Use the NVIC offset register to locate the stack. */\r
ldr r0, [r0]\r
ldr r0, [r0]\r
mrs r1, control\r
stmdb r0!, {r1, r4-r11, r14} /* Save the remaining registers. */\r
str r0, [r2] /* Save the new top of stack into the first member of the TCB. */\r
+ clrex /* Ensure thread safety of atomic operations. */\r
\r
stmdb sp!, {r3}\r
mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
*/\r
static void prvSetupTimerInterrupt( void )\r
{\r
+ /* Reset the SysTick. */\r
+ portNVIC_SYSTICK_CTRL_REG = 0UL;\r
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
portNVIC_SYSTICK_LOAD_REG = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE;\r
__asm void vPortSwitchToUserMode( void )\r
{\r
PRESERVE8\r
- \r
+\r
mrs r0, control\r
orr r0, #1\r
msr control, r0\r
bx r14\r
}\r
/*-----------------------------------------------------------*/\r
- \r
+\r
__asm void vPortEnableVFP( void )\r
{\r
PRESERVE8\r
- \r
+\r
ldr.w r0, =0xE000ED88 /* The FPU enable bits are in the CPACR. */\r
ldr r1, [r0]\r
\r
extern uint32_t __privileged_data_start__;\r
extern uint32_t __privileged_data_end__;\r
\r
- \r
+\r
int32_t lIndex;\r
uint32_t ul;\r
\r
/* Save the new top of stack into the first member of the TCB. */\r
str r0, [r2]\r
\r
+ /* Ensure thread safety of atomic operations. */\r
+ clrex\r
+\r
stmdb sp!, {r3}\r
mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
cpsid i\r
}\r
#endif /* configUSE_TICKLESS_IDLE */\r
\r
+ /* Stop and clear the SysTick. */\r
+ portNVIC_SYSTICK_CTRL_REG = 0UL;\r
+ portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );\r
\r
/* If configGENERATE_RUN_TIME_STATS is defined then the following\r
macro must be defined to configure the timer/counter used to generate\r
- the run time counter time base. */\r
+ the run time counter time base. NOTE: If configGENERATE_RUN_TIME_STATS\r
+ is set to 0 and the following line fails to build then ensure you do not\r
+ have portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() defined in your\r
+ FreeRTOSConfig.h file. */\r
portCONFIGURE_TIMER_FOR_RUN_TIME_STATS();\r
\r
/* Setting up the timer tick is hardware specific and thus in the\r