Skip to content

Commit 9863019

Browse files
committed
[Work In Progress] Adding the xPortIsInsideInterrupt to the PIC32MZ port
1 parent 32e5816 commit 9863019

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

portable/MPLAB/PIC32MZ/port.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,3 +372,25 @@ void vPortClearInterruptMaskFromISR( UBaseType_t uxSavedStatusRegister )
372372
#endif /* __mips_hard_float == 1 */
373373

374374
/*-----------------------------------------------------------*/
375+
376+
__attribute__((always_inline)) static BaseType_t xPortIsInsideInterrupt( void )
377+
{
378+
uint32_t ulCurrentInterrupt;
379+
BaseType_t xReturn;
380+
381+
/* Obtain the number of the currently executing interrupt. */
382+
__asm volatile("mfc0 %0, $12" : "=r" (ulCurrentInterrupt));
383+
384+
if( ulCurrentInterrupt == 0 )
385+
{
386+
xReturn = pdFALSE;
387+
}
388+
else
389+
{
390+
xReturn = pdTRUE;
391+
}
392+
393+
return xReturn;
394+
}
395+
396+
/*-----------------------------------------------------------*/

portable/MPLAB/PIC32MZ/portmacro.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ extern void vPortClearInterruptMaskFromISR( UBaseType_t );
146146
#define portSET_INTERRUPT_MASK_FROM_ISR() uxPortSetInterruptMaskFromISR()
147147
#define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusRegister ) vPortClearInterruptMaskFromISR( uxSavedStatusRegister )
148148

149+
extern BaseType_t xPortIsInsideInterrupt( void );
150+
149151
#if ( __mips_hard_float == 0 ) && ( configUSE_TASK_FPU_SUPPORT == 1 )
150152
#error configUSE_TASK_FPU_SUPPORT can only be set to 1 when the part supports a hardware FPU module.
151153
#endif

0 commit comments

Comments
 (0)