Skip to content

Commit 5f19e34

Browse files
committed
portable/ARM_CM0: Add xPortIsInsideInterrupt
Add missing xPortIsInsideInterrupt function to Cortex-M0 port.
1 parent 714e543 commit 5f19e34

File tree

3 files changed

+110
-4
lines changed

3 files changed

+110
-4
lines changed

portable/GCC/ARM_CM0/portmacro.h

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@
3030
#ifndef PORTMACRO_H
3131
#define PORTMACRO_H
3232

33+
/* *INDENT-OFF* */
3334
#ifdef __cplusplus
34-
extern "C" {
35+
extern "C" {
3536
#endif
37+
/* *INDENT-ON* */
3638

3739
/*-----------------------------------------------------------
3840
* Port specific definitions.
@@ -123,8 +125,42 @@ extern void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__( ( nake
123125

124126
#define portMEMORY_BARRIER() __asm volatile ( "" ::: "memory" )
125127

126-
#ifdef __cplusplus
128+
129+
#define portINLINE __inline
130+
131+
#ifndef portFORCE_INLINE
132+
#define portFORCE_INLINE inline __attribute__( ( always_inline ) )
133+
#endif
134+
135+
/*-----------------------------------------------------------*/
136+
137+
portFORCE_INLINE static BaseType_t xPortIsInsideInterrupt( void )
138+
{
139+
uint32_t ulCurrentInterrupt;
140+
BaseType_t xReturn;
141+
142+
/* Obtain the number of the currently executing interrupt. */
143+
__asm volatile ( "mrs %0, ipsr" : "=r" ( ulCurrentInterrupt )::"memory" );
144+
145+
if( ulCurrentInterrupt == 0 )
146+
{
147+
xReturn = pdFALSE;
148+
}
149+
else
150+
{
151+
xReturn = pdTRUE;
152+
}
153+
154+
return xReturn;
127155
}
156+
157+
/*-----------------------------------------------------------*/
158+
159+
160+
/* *INDENT-OFF* */
161+
#ifdef __cplusplus
162+
}
128163
#endif
164+
/* *INDENT-ON* */
129165

130166
#endif /* PORTMACRO_H */

portable/IAR/ARM_CM0/portmacro.h

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@
2626
*
2727
*/
2828

29+
2930
#ifndef PORTMACRO_H
3031
#define PORTMACRO_H
3132

33+
/* *INDENT-OFF* */
3234
#ifdef __cplusplus
33-
extern "C" {
35+
extern "C" {
3436
#endif
37+
/* *INDENT-ON* */
3538

3639
/*-----------------------------------------------------------
3740
* Port specific definitions.
@@ -118,13 +121,45 @@ extern void vClearInterruptMaskFromISR( uint32_t ulMask );
118121

119122
#define portNOP()
120123

124+
#define portINLINE __inline
125+
126+
#ifndef portFORCE_INLINE
127+
#define portFORCE_INLINE inline __attribute__( ( always_inline ) )
128+
#endif
129+
130+
/*-----------------------------------------------------------*/
131+
132+
portFORCE_INLINE static BaseType_t xPortIsInsideInterrupt( void )
133+
{
134+
uint32_t ulCurrentInterrupt;
135+
BaseType_t xReturn;
136+
137+
/* Obtain the number of the currently executing interrupt. */
138+
__asm volatile ( "mrs %0, ipsr" : "=r" ( ulCurrentInterrupt )::"memory" );
139+
140+
if( ulCurrentInterrupt == 0 )
141+
{
142+
xReturn = pdFALSE;
143+
}
144+
else
145+
{
146+
xReturn = pdTRUE;
147+
}
148+
149+
return xReturn;
150+
}
151+
152+
/*-----------------------------------------------------------*/
153+
121154
/* Suppress warnings that are generated by the IAR tools, but cannot be fixed in
122155
* the source code because to do so would cause other compilers to generate
123156
* warnings. */
124157
#pragma diag_suppress=Pa082
125158

159+
/* *INDENT-OFF* */
126160
#ifdef __cplusplus
127-
}
161+
}
128162
#endif
163+
/* *INDENT-ON* */
129164

130165
#endif /* PORTMACRO_H */

portable/RVDS/ARM_CM0/portmacro.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,41 @@ extern void vClearInterruptMaskFromISR( uint32_t ulMask );
120120

121121
#define portNOP()
122122

123+
#define portINLINE __inline
124+
125+
#ifndef portFORCE_INLINE
126+
#define portFORCE_INLINE __forceinline
127+
#endif
128+
129+
/*-----------------------------------------------------------*/
130+
131+
static portFORCE_INLINE BaseType_t xPortIsInsideInterrupt( void )
132+
{
133+
uint32_t ulCurrentInterrupt;
134+
BaseType_t xReturn;
135+
136+
/* Obtain the number of the currently executing interrupt. */
137+
__asm
138+
{
139+
/* *INDENT-OFF* */
140+
mrs ulCurrentInterrupt, ipsr
141+
/* *INDENT-ON* */
142+
}
143+
144+
if( ulCurrentInterrupt == 0 )
145+
{
146+
xReturn = pdFALSE;
147+
}
148+
else
149+
{
150+
xReturn = pdTRUE;
151+
}
152+
153+
return xReturn;
154+
}
155+
156+
/*-----------------------------------------------------------*/
157+
123158
/* *INDENT-OFF* */
124159
#ifdef __cplusplus
125160
}

0 commit comments

Comments
 (0)