149149 #define portTASK_RETURN_ADDRESS prvTaskExitError
150150#endif
151151
152+ #if ( configUSE_TASK_FPU_SUPPORT != 0 )
153+
152154/*
153155 * The space on the stack required to hold the FPU registers.
154156 *
160162 * the size of the bank remains the same. The FPU has also a 32-bit
161163 * status register.
162164 */
163- #define portFPU_REGISTER_WORDS ( ( 16 * 2 ) + 1 )
165+ #define portFPU_REGISTER_WORDS ( ( 16 * 2 ) + 1 )
166+ #endif /* configUSE_TASK_FPU_SUPPORT != 0 */
164167
165168/*-----------------------------------------------------------*/
166169
@@ -175,6 +178,8 @@ extern void vPortRestoreTaskContext( void );
175178 */
176179static void prvTaskExitError ( void );
177180
181+ #if ( configUSE_TASK_FPU_SUPPORT != 0 )
182+
178183/*
179184 * If the application provides an implementation of vApplicationIRQHandler(),
180185 * then it will get called directly without saving the FPU registers on
@@ -194,7 +199,8 @@ static void prvTaskExitError( void );
194199 * FPU registers to be saved on interrupt entry their IRQ handler must be
195200 * called vApplicationIRQHandler().
196201 */
197- void vApplicationFPUSafeIRQHandler ( uint32_t ulICCIAR ) __attribute__((weak ) );
202+ void vApplicationFPUSafeIRQHandler ( uint32_t ulICCIAR ) __attribute__( ( weak ) );
203+ #endif /* configUSE_TASK_FPU_SUPPORT != 0 */
198204
199205/*-----------------------------------------------------------*/
200206
@@ -205,9 +211,12 @@ void vApplicationFPUSafeIRQHandler( uint32_t ulICCIAR ) __attribute__((weak) );
205211 * automatically be set to 0 when the first task is started. */
206212volatile uint32_t ulCriticalNesting = 9999UL ;
207213
214+ #if ( configUSE_TASK_FPU_SUPPORT != 0 )
215+
208216/* Saved as part of the task context. If ulPortTaskHasFPUContext is non-zero then
209217 * a floating point context must be saved and restored for the task. */
210- uint32_t ulPortTaskHasFPUContext = pdFALSE ;
218+ uint32_t ulPortTaskHasFPUContext = pdFALSE ;
219+ #endif /* configUSE_TASK_FPU_SUPPORT != 0 */
211220
212221/* Set to 1 to pend a context switch from an ISR. */
213222uint32_t ulPortYieldRequired = pdFALSE ;
@@ -291,28 +300,28 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
291300 * enabled. */
292301 * pxTopOfStack = portNO_CRITICAL_NESTING ;
293302
294- #if ( configUSE_TASK_FPU_SUPPORT == 1 )
303+ #if ( configUSE_TASK_FPU_SUPPORT == 1 )
295304 {
296305 /* The task will start without a floating point context. A task that
297- uses the floating point hardware must call vPortTaskUsesFPU() before
298- executing any floating point instructions. */
306+ * uses the floating point hardware must call vPortTaskUsesFPU() before
307+ * executing any floating point instructions. */
299308 pxTopOfStack -- ;
300309 * pxTopOfStack = portNO_FLOATING_POINT_CONTEXT ;
301310 }
302- #elif ( configUSE_TASK_FPU_SUPPORT == 2 )
311+ #elif ( configUSE_TASK_FPU_SUPPORT == 2 )
303312 {
304313 /* The task will start with a floating point context. Leave enough
305- space for the registers - and ensure they are initialized to 0. */
314+ * space for the registers - and ensure they are initialized to 0. */
306315 pxTopOfStack -= portFPU_REGISTER_WORDS ;
307316 memset ( pxTopOfStack , 0x00 , portFPU_REGISTER_WORDS * sizeof ( StackType_t ) );
308317
309318 pxTopOfStack -- ;
310319 * pxTopOfStack = pdTRUE ;
311320 ulPortTaskHasFPUContext = pdTRUE ;
312321 }
313- #else
322+ #elif ( configUSE_TASK_FPU_SUPPORT != 0 )
314323 {
315- #error Invalid configUSE_TASK_FPU_SUPPORT setting - configUSE_TASK_FPU_SUPPORT must be set to 1, 2 , or left undefined .
324+ #error Invalid configUSE_TASK_FPU_SUPPORT setting - configUSE_TASK_FPU_SUPPORT must be set to 0, 1 , or 2 .
316325 }
317326 #endif /* configUSE_TASK_FPU_SUPPORT */
318327
@@ -337,58 +346,60 @@ static void prvTaskExitError( void )
337346}
338347/*-----------------------------------------------------------*/
339348
340- void vApplicationFPUSafeIRQHandler ( uint32_t ulICCIAR )
341- {
342- ( void ) ulICCIAR ;
343- configASSERT ( ( volatile void * ) NULL );
344- }
349+ #if ( configUSE_TASK_FPU_SUPPORT != 0 )
350+ void vApplicationFPUSafeIRQHandler ( uint32_t ulICCIAR )
351+ {
352+ ( void ) ulICCIAR ;
353+ configASSERT ( ( volatile void * ) NULL );
354+ }
355+ #endif /* configUSE_TASK_FPU_SUPPORT != 0 */
345356/*-----------------------------------------------------------*/
346357
347358BaseType_t xPortStartScheduler ( void )
348359{
349360 uint32_t ulAPSR , ulCycles = 8 ; /* 8 bits per byte. */
350361
351362 #if ( configASSERT_DEFINED == 1 )
352- {
353- volatile uint32_t ulOriginalPriority ;
354- volatile uint8_t * const pucFirstUserPriorityRegister = ( volatile uint8_t * const ) ( configINTERRUPT_CONTROLLER_BASE_ADDRESS + portINTERRUPT_PRIORITY_REGISTER_OFFSET );
355- volatile uint8_t ucMaxPriorityValue ;
363+ {
364+ volatile uint32_t ulOriginalPriority ;
365+ volatile uint8_t * const pucFirstUserPriorityRegister = ( volatile uint8_t * const ) ( configINTERRUPT_CONTROLLER_BASE_ADDRESS + portINTERRUPT_PRIORITY_REGISTER_OFFSET );
366+ volatile uint8_t ucMaxPriorityValue ;
356367
357- /* Determine how many priority bits are implemented in the GIC.
358- *
359- * Save the interrupt priority value that is about to be clobbered. */
360- ulOriginalPriority = * pucFirstUserPriorityRegister ;
368+ /* Determine how many priority bits are implemented in the GIC.
369+ *
370+ * Save the interrupt priority value that is about to be clobbered. */
371+ ulOriginalPriority = * pucFirstUserPriorityRegister ;
361372
362- /* Determine the number of priority bits available. First write to
363- * all possible bits. */
364- * pucFirstUserPriorityRegister = portMAX_8_BIT_VALUE ;
373+ /* Determine the number of priority bits available. First write to
374+ * all possible bits. */
375+ * pucFirstUserPriorityRegister = portMAX_8_BIT_VALUE ;
365376
366- /* Read the value back to see how many bits stuck. */
367- ucMaxPriorityValue = * pucFirstUserPriorityRegister ;
377+ /* Read the value back to see how many bits stuck. */
378+ ucMaxPriorityValue = * pucFirstUserPriorityRegister ;
368379
369- /* Shift to the least significant bits. */
370- while ( ( ucMaxPriorityValue & portBIT_0_SET ) != portBIT_0_SET )
371- {
372- ucMaxPriorityValue >>= ( uint8_t ) 0x01 ;
380+ /* Shift to the least significant bits. */
381+ while ( ( ucMaxPriorityValue & portBIT_0_SET ) != portBIT_0_SET )
382+ {
383+ ucMaxPriorityValue >>= ( uint8_t ) 0x01 ;
373384
374- /* If ulCycles reaches 0 then ucMaxPriorityValue must have been
375- * read as 0, indicating a misconfiguration. */
376- ulCycles -- ;
385+ /* If ulCycles reaches 0 then ucMaxPriorityValue must have been
386+ * read as 0, indicating a misconfiguration. */
387+ ulCycles -- ;
377388
378- if ( ulCycles == 0 )
379- {
380- break ;
381- }
389+ if ( ulCycles == 0 )
390+ {
391+ break ;
382392 }
393+ }
383394
384- /* Sanity check configUNIQUE_INTERRUPT_PRIORITIES matches the read
385- * value. */
386- configASSERT ( ucMaxPriorityValue == portLOWEST_INTERRUPT_PRIORITY );
395+ /* Sanity check configUNIQUE_INTERRUPT_PRIORITIES matches the read
396+ * value. */
397+ configASSERT ( ucMaxPriorityValue == portLOWEST_INTERRUPT_PRIORITY );
387398
388- /* Restore the clobbered interrupt priority register to its original
389- * value. */
390- * pucFirstUserPriorityRegister = ulOriginalPriority ;
391- }
399+ /* Restore the clobbered interrupt priority register to its original
400+ * value. */
401+ * pucFirstUserPriorityRegister = ulOriginalPriority ;
402+ }
392403 #endif /* configASSERT_DEFINED */
393404
394405 /* Only continue if the CPU is not in User mode. The CPU must be in a
@@ -426,6 +437,7 @@ BaseType_t xPortStartScheduler( void )
426437 * warning about it being defined but not referenced in the case that the user
427438 * defines their own exit address. */
428439 ( void ) prvTaskExitError ;
440+
429441 return 0 ;
430442}
431443/*-----------------------------------------------------------*/
@@ -505,7 +517,7 @@ void FreeRTOS_Tick_Handler( void )
505517}
506518/*-----------------------------------------------------------*/
507519
508- #if ( configUSE_TASK_FPU_SUPPORT != 2 )
520+ #if ( configUSE_TASK_FPU_SUPPORT == 1 )
509521
510522 void vPortTaskUsesFPU ( void )
511523 {
@@ -519,7 +531,7 @@ void FreeRTOS_Tick_Handler( void )
519531 __asm volatile ( "FMXR FPSCR, %0" ::"r" ( ulInitialFPSCR ) : "memory" );
520532 }
521533
522- #endif /* configUSE_TASK_FPU_SUPPORT */
534+ #endif /* configUSE_TASK_FPU_SUPPORT == 1 */
523535/*-----------------------------------------------------------*/
524536
525537void vPortClearInterruptMask ( uint32_t ulNewMaskValue )
0 commit comments