Skip to content

Commit 4a0f9a2

Browse files
committed
Interrupt priority assert improvements for CM3/4/7
In the ARM_CM3, ARM_CM4, and ARM_CM7 ports, change the assertion that configMAX_SYSCALL_INTERRUPT_PRIORITY is nonzero to account for the number of priority bits implemented by the hardware. Change these ports to also use the lowest priority for PendSV and SysTick, ignoring configKERNEL_INTERRUPT_PRIORITY.
1 parent 99d3d54 commit 4a0f9a2

File tree

16 files changed

+176
-84
lines changed

16 files changed

+176
-84
lines changed

portable/CCS/ARM_CM3/port.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@
5252
#define portNVIC_PEND_SYSTICK_SET_BIT ( 1UL << 26UL )
5353
#define portNVIC_PEND_SYSTICK_CLEAR_BIT ( 1UL << 25UL )
5454

55-
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 16UL )
56-
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 24UL )
55+
#define portMIN_INTERRUPT_PRIORITY ( 255UL )
56+
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL )
57+
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL )
5758

5859
/* Constants required to check the validity of an interrupt priority. */
5960
#define portFIRST_USER_INTERRUPT_NUMBER ( 16 )
@@ -239,6 +240,14 @@ BaseType_t xPortStartScheduler( void )
239240
/* Use the same mask on the maximum system call priority. */
240241
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;
241242

243+
/* Check that the maximum system call priority is nonzero after
244+
* accounting for the number of priority bits supported by the
245+
* hardware. A priority of 0 is invalid because setting the BASEPRI
246+
* register to 0 unmasks all interrupts, and interrupts with priority 0
247+
* cannot be masked using BASEPRI.
248+
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
249+
configASSERT( ucMaxSysCallPriority );
250+
242251
/* Calculate the maximum acceptable priority group value for the number
243252
* of bits read back. */
244253
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;

portable/CCS/ARM_CM4F/port.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@
5656
#define portNVIC_PEND_SYSTICK_SET_BIT ( 1UL << 26UL )
5757
#define portNVIC_PEND_SYSTICK_CLEAR_BIT ( 1UL << 25UL )
5858

59-
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 16UL )
60-
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 24UL )
59+
#define portMIN_INTERRUPT_PRIORITY ( 255UL )
60+
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL )
61+
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL )
6162

6263
/* Constants required to check the validity of an interrupt priority. */
6364
#define portFIRST_USER_INTERRUPT_NUMBER ( 16 )
@@ -258,6 +259,14 @@ BaseType_t xPortStartScheduler( void )
258259
/* Use the same mask on the maximum system call priority. */
259260
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;
260261

262+
/* Check that the maximum system call priority is nonzero after
263+
* accounting for the number of priority bits supported by the
264+
* hardware. A priority of 0 is invalid because setting the BASEPRI
265+
* register to 0 unmasks all interrupts, and interrupts with priority 0
266+
* cannot be masked using BASEPRI.
267+
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
268+
configASSERT( ucMaxSysCallPriority );
269+
261270
/* Calculate the maximum acceptable priority group value for the number
262271
* of bits read back. */
263272
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;

portable/GCC/ARM_CM3/port.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@
5555
#define portNVIC_PEND_SYSTICK_SET_BIT ( 1UL << 26UL )
5656
#define portNVIC_PEND_SYSTICK_CLEAR_BIT ( 1UL << 25UL )
5757

58-
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 16UL )
59-
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 24UL )
58+
#define portMIN_INTERRUPT_PRIORITY ( 255UL )
59+
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL )
60+
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL )
6061

6162
/* Constants required to check the validity of an interrupt priority. */
6263
#define portFIRST_USER_INTERRUPT_NUMBER ( 16 )
@@ -265,10 +266,6 @@ static void prvPortStartFirstTask( void )
265266
*/
266267
BaseType_t xPortStartScheduler( void )
267268
{
268-
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0.
269-
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
270-
configASSERT( configMAX_SYSCALL_INTERRUPT_PRIORITY );
271-
272269
#if ( configASSERT_DEFINED == 1 )
273270
{
274271
volatile uint32_t ulOriginalPriority;
@@ -293,6 +290,14 @@ BaseType_t xPortStartScheduler( void )
293290
/* Use the same mask on the maximum system call priority. */
294291
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;
295292

293+
/* Check that the maximum system call priority is nonzero after
294+
* accounting for the number of priority bits supported by the
295+
* hardware. A priority of 0 is invalid because setting the BASEPRI
296+
* register to 0 unmasks all interrupts, and interrupts with priority 0
297+
* cannot be masked using BASEPRI.
298+
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
299+
configASSERT( ucMaxSysCallPriority );
300+
296301
/* Calculate the maximum acceptable priority group value for the number
297302
* of bits read back. */
298303
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;

portable/GCC/ARM_CM3_MPU/port.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@
8383
/* Constants required to access and manipulate the SysTick. */
8484
#define portNVIC_SYSTICK_INT ( 0x00000002UL )
8585
#define portNVIC_SYSTICK_ENABLE ( 0x00000001UL )
86-
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 16UL )
87-
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 24UL )
86+
#define portMIN_INTERRUPT_PRIORITY ( 255UL )
87+
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL )
88+
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL )
8889
#define portNVIC_SVC_PRI ( ( ( uint32_t ) configMAX_SYSCALL_INTERRUPT_PRIORITY - 1UL ) << 24UL )
8990

9091
/* Constants required to set up the initial stack. */
@@ -381,10 +382,6 @@ static void prvRestoreContextOfFirstTask( void )
381382
*/
382383
BaseType_t xPortStartScheduler( void )
383384
{
384-
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See
385-
* https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
386-
configASSERT( ( configMAX_SYSCALL_INTERRUPT_PRIORITY ) );
387-
388385
#if ( configASSERT_DEFINED == 1 )
389386
{
390387
volatile uint32_t ulOriginalPriority;
@@ -409,6 +406,14 @@ BaseType_t xPortStartScheduler( void )
409406
/* Use the same mask on the maximum system call priority. */
410407
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;
411408

409+
/* Check that the maximum system call priority is nonzero after
410+
* accounting for the number of priority bits supported by the
411+
* hardware. A priority of 0 is invalid because setting the BASEPRI
412+
* register to 0 unmasks all interrupts, and interrupts with priority 0
413+
* cannot be masked using BASEPRI.
414+
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
415+
configASSERT( ucMaxSysCallPriority );
416+
412417
/* Calculate the maximum acceptable priority group value for the number
413418
* of bits read back. */
414419
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;

portable/GCC/ARM_CM4F/port.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@
5858
#define portCORTEX_M7_r0p1_ID ( 0x410FC271UL )
5959
#define portCORTEX_M7_r0p0_ID ( 0x410FC270UL )
6060

61-
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 16UL )
62-
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 24UL )
61+
#define portMIN_INTERRUPT_PRIORITY ( 255UL )
62+
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL )
63+
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL )
6364

6465
/* Constants required to check the validity of an interrupt priority. */
6566
#define portFIRST_USER_INTERRUPT_NUMBER ( 16 )
@@ -295,10 +296,6 @@ static void prvPortStartFirstTask( void )
295296
*/
296297
BaseType_t xPortStartScheduler( void )
297298
{
298-
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0.
299-
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
300-
configASSERT( configMAX_SYSCALL_INTERRUPT_PRIORITY );
301-
302299
/* This port can be used on all revisions of the Cortex-M7 core other than
303300
* the r0p1 parts. r0p1 parts should use the port from the
304301
* /source/portable/GCC/ARM_CM7/r0p1 directory. */
@@ -329,6 +326,14 @@ BaseType_t xPortStartScheduler( void )
329326
/* Use the same mask on the maximum system call priority. */
330327
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;
331328

329+
/* Check that the maximum system call priority is nonzero after
330+
* accounting for the number of priority bits supported by the
331+
* hardware. A priority of 0 is invalid because setting the BASEPRI
332+
* register to 0 unmasks all interrupts, and interrupts with priority 0
333+
* cannot be masked using BASEPRI.
334+
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
335+
configASSERT( ucMaxSysCallPriority );
336+
332337
/* Calculate the maximum acceptable priority group value for the number
333338
* of bits read back. */
334339
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;

portable/GCC/ARM_CM4_MPU/port.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@
9393
/* Constants required to access and manipulate the SysTick. */
9494
#define portNVIC_SYSTICK_INT ( 0x00000002UL )
9595
#define portNVIC_SYSTICK_ENABLE ( 0x00000001UL )
96-
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 16UL )
97-
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 24UL )
96+
#define portMIN_INTERRUPT_PRIORITY ( 255UL )
97+
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL )
98+
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL )
9899
#define portNVIC_SVC_PRI ( ( ( uint32_t ) configMAX_SYSCALL_INTERRUPT_PRIORITY - 1UL ) << 24UL )
99100

100101
/* Constants required to manipulate the VFP. */
@@ -412,10 +413,6 @@ static void prvRestoreContextOfFirstTask( void )
412413
*/
413414
BaseType_t xPortStartScheduler( void )
414415
{
415-
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See
416-
* https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
417-
configASSERT( ( configMAX_SYSCALL_INTERRUPT_PRIORITY ) );
418-
419416
/* Errata 837070 workaround must only be enabled on Cortex-M7 r0p0
420417
* and r0p1 cores. */
421418
#if ( configENABLE_ERRATA_837070_WORKAROUND == 1 )
@@ -452,6 +449,14 @@ BaseType_t xPortStartScheduler( void )
452449
/* Use the same mask on the maximum system call priority. */
453450
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;
454451

452+
/* Check that the maximum system call priority is nonzero after
453+
* accounting for the number of priority bits supported by the
454+
* hardware. A priority of 0 is invalid because setting the BASEPRI
455+
* register to 0 unmasks all interrupts, and interrupts with priority 0
456+
* cannot be masked using BASEPRI.
457+
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
458+
configASSERT( ucMaxSysCallPriority );
459+
455460
/* Calculate the maximum acceptable priority group value for the number
456461
* of bits read back. */
457462
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;

portable/GCC/ARM_CM7/r0p1/port.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@
5252
#define portNVIC_PEND_SYSTICK_SET_BIT ( 1UL << 26UL )
5353
#define portNVIC_PEND_SYSTICK_CLEAR_BIT ( 1UL << 25UL )
5454

55-
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 16UL )
56-
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 24UL )
55+
#define portMIN_INTERRUPT_PRIORITY ( 255UL )
56+
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL )
57+
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL )
5758

5859
/* Constants required to check the validity of an interrupt priority. */
5960
#define portFIRST_USER_INTERRUPT_NUMBER ( 16 )
@@ -289,10 +290,6 @@ static void prvPortStartFirstTask( void )
289290
*/
290291
BaseType_t xPortStartScheduler( void )
291292
{
292-
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0.
293-
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
294-
configASSERT( configMAX_SYSCALL_INTERRUPT_PRIORITY );
295-
296293
#if ( configASSERT_DEFINED == 1 )
297294
{
298295
volatile uint32_t ulOriginalPriority;
@@ -317,6 +314,14 @@ BaseType_t xPortStartScheduler( void )
317314
/* Use the same mask on the maximum system call priority. */
318315
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;
319316

317+
/* Check that the maximum system call priority is nonzero after
318+
* accounting for the number of priority bits supported by the
319+
* hardware. A priority of 0 is invalid because setting the BASEPRI
320+
* register to 0 unmasks all interrupts, and interrupts with priority 0
321+
* cannot be masked using BASEPRI.
322+
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
323+
configASSERT( ucMaxSysCallPriority );
324+
320325
/* Calculate the maximum acceptable priority group value for the number
321326
* of bits read back. */
322327
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;

portable/IAR/ARM_CM3/port.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@
5555
#define portNVIC_PEND_SYSTICK_SET_BIT ( 1UL << 26UL )
5656
#define portNVIC_PEND_SYSTICK_CLEAR_BIT ( 1UL << 25UL )
5757

58-
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 16UL )
59-
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 24UL )
58+
#define portMIN_INTERRUPT_PRIORITY ( 255UL )
59+
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL )
60+
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL )
6061

6162
/* Constants required to check the validity of an interrupt priority. */
6263
#define portFIRST_USER_INTERRUPT_NUMBER ( 16 )
@@ -214,10 +215,6 @@ static void prvTaskExitError( void )
214215
*/
215216
BaseType_t xPortStartScheduler( void )
216217
{
217-
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0.
218-
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
219-
configASSERT( configMAX_SYSCALL_INTERRUPT_PRIORITY );
220-
221218
#if ( configASSERT_DEFINED == 1 )
222219
{
223220
volatile uint32_t ulOriginalPriority;
@@ -242,6 +239,14 @@ BaseType_t xPortStartScheduler( void )
242239
/* Use the same mask on the maximum system call priority. */
243240
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;
244241

242+
/* Check that the maximum system call priority is nonzero after
243+
* accounting for the number of priority bits supported by the
244+
* hardware. A priority of 0 is invalid because setting the BASEPRI
245+
* register to 0 unmasks all interrupts, and interrupts with priority 0
246+
* cannot be masked using BASEPRI.
247+
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
248+
configASSERT( ucMaxSysCallPriority );
249+
245250
/* Calculate the maximum acceptable priority group value for the number
246251
* of bits read back. */
247252
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;

portable/IAR/ARM_CM4F/port.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@
6565
#define portCORTEX_M7_r0p1_ID ( 0x410FC271UL )
6666
#define portCORTEX_M7_r0p0_ID ( 0x410FC270UL )
6767

68-
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 16UL )
69-
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 24UL )
68+
#define portMIN_INTERRUPT_PRIORITY ( 255UL )
69+
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL )
70+
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL )
7071

7172
/* Constants required to check the validity of an interrupt priority. */
7273
#define portFIRST_USER_INTERRUPT_NUMBER ( 16 )
@@ -239,10 +240,6 @@ static void prvTaskExitError( void )
239240
*/
240241
BaseType_t xPortStartScheduler( void )
241242
{
242-
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0.
243-
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
244-
configASSERT( configMAX_SYSCALL_INTERRUPT_PRIORITY );
245-
246243
/* This port can be used on all revisions of the Cortex-M7 core other than
247244
* the r0p1 parts. r0p1 parts should use the port from the
248245
* /source/portable/GCC/ARM_CM7/r0p1 directory. */
@@ -273,6 +270,14 @@ BaseType_t xPortStartScheduler( void )
273270
/* Use the same mask on the maximum system call priority. */
274271
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;
275272

273+
/* Check that the maximum system call priority is nonzero after
274+
* accounting for the number of priority bits supported by the
275+
* hardware. A priority of 0 is invalid because setting the BASEPRI
276+
* register to 0 unmasks all interrupts, and interrupts with priority 0
277+
* cannot be masked using BASEPRI.
278+
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
279+
configASSERT( ucMaxSysCallPriority );
280+
276281
/* Calculate the maximum acceptable priority group value for the number
277282
* of bits read back. */
278283
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;

portable/IAR/ARM_CM4F_MPU/port.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@
104104
#define portCORTEX_M7_r0p1_ID ( 0x410FC271UL )
105105
#define portCORTEX_M7_r0p0_ID ( 0x410FC270UL )
106106

107-
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 16UL )
108-
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 24UL )
107+
#define portMIN_INTERRUPT_PRIORITY ( 255UL )
108+
#define portNVIC_PENDSV_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 16UL )
109+
#define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) portMIN_INTERRUPT_PRIORITY ) << 24UL )
109110
#define portNVIC_SVC_PRI ( ( ( uint32_t ) configMAX_SYSCALL_INTERRUPT_PRIORITY - 1UL ) << 24UL )
110111

111112
/* Constants required to check the validity of an interrupt priority. */
@@ -346,10 +347,6 @@ void vPortSVCHandler_C( uint32_t * pulParam )
346347
*/
347348
BaseType_t xPortStartScheduler( void )
348349
{
349-
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0.
350-
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
351-
configASSERT( configMAX_SYSCALL_INTERRUPT_PRIORITY );
352-
353350
/* Errata 837070 workaround must only be enabled on Cortex-M7 r0p0
354351
* and r0p1 cores. */
355352
#if ( configENABLE_ERRATA_837070_WORKAROUND == 1 )
@@ -386,6 +383,14 @@ BaseType_t xPortStartScheduler( void )
386383
/* Use the same mask on the maximum system call priority. */
387384
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;
388385

386+
/* Check that the maximum system call priority is nonzero after
387+
* accounting for the number of priority bits supported by the
388+
* hardware. A priority of 0 is invalid because setting the BASEPRI
389+
* register to 0 unmasks all interrupts, and interrupts with priority 0
390+
* cannot be masked using BASEPRI.
391+
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
392+
configASSERT( ucMaxSysCallPriority );
393+
389394
/* Calculate the maximum acceptable priority group value for the number
390395
* of bits read back. */
391396
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;

0 commit comments

Comments
 (0)