Skip to content

Commit 4d6a183

Browse files
committed
Remove workaround for radio interrupt - patch FreeRTOS port.
Former-commit-id: 52fbe72
1 parent 10ad8e0 commit 4d6a183

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

cores/nRF5/freertos/port_nrf52.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,4 +360,24 @@ UBaseType_t uxGetCriticalNestingDepth(void)
360360
return uxCriticalNesting;
361361
}
362362

363+
uint32_t ulSetInterruptMaskFromISR( void )
364+
{
365+
__asm volatile (
366+
" mrs r0, PRIMASK \n"
367+
" cpsid i \n"
368+
" bx lr "
369+
::: "memory"
370+
);
371+
}
372+
/*-----------------------------------------------------------*/
373+
374+
void vClearInterruptMaskFromISR( __attribute__( ( unused ) ) uint32_t ulMask )
375+
{
376+
__asm volatile (
377+
" msr PRIMASK, r0 \n"
378+
" bx lr "
379+
::: "memory"
380+
);
381+
}
382+
363383
#endif /* NRF52_SERIES */

cores/nRF5/freertos/port_nrf52_systick.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,14 @@ void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )
242242
else
243243
#endif
244244
{
245+
// Fix ERRATA 87 (https://infocenter.nordicsemi.com/index.jsp?topic=%252Fcom.nordic.infocenter.sdk5.v11.0.0%252Findex.html&cp=4_0_0)
246+
// Clear FPU interrupt before going to sleep. This prevent unexpected wake-up.
247+
#define FPU_EXCEPTION_MASK 0x0000009F
248+
/* Clear exceptions and PendingIRQ from the FPU unit */
249+
__set_FPSCR(__get_FPSCR() & ~(FPU_EXCEPTION_MASK));
250+
(void) __get_FPSCR();
251+
NVIC_ClearPendingIRQ(FPU_IRQn);
252+
245253
/* No SD - we would just block interrupts globally.
246254
* BASEPRI cannot be used for that because it would prevent WFE from wake up.
247255
*/

cores/nRF5/freertos/portmacro_nrf52.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,12 @@ typedef unsigned long UBaseType_t;
106106
extern void vPortEnterCritical( void );
107107
extern void vPortExitCritical( void );
108108
extern UBaseType_t uxGetCriticalNestingDepth(void);
109-
#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortRaiseBASEPRI()
110-
#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortSetBASEPRI(x)
111-
#define portDISABLE_INTERRUPTS() vPortRaiseBASEPRI()
112-
#define portENABLE_INTERRUPTS() vPortSetBASEPRI(0)
109+
extern uint32_t ulSetInterruptMaskFromISR( void ) __attribute__( ( naked ) );
110+
extern void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__( ( naked ) );
111+
#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR()
112+
#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x )
113+
#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" )
114+
#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" )
113115
#define portENTER_CRITICAL() vPortEnterCritical()
114116
#define portEXIT_CRITICAL() vPortExitCritical()
115117

platform.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ nordic.path={build.core.path}/nordic
6060
compiler.nrf.flags=-DNRF5 -DARDUINO_ARCH_NRF5 "-I{build.core.path}/nimble_config" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{build.core.path}/CMSIS/Include" "-I{build.core.path}/FC_Store" "-I{build.core.path}/BLEBond_nvs" "-I{build.core.path}/TinyUSB" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-I{build.core.path}/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src"
6161

6262
# These can be overridden in platform.local.txt
63-
compiler.c.extra_flags=-DRIOT_VERSION=1
63+
compiler.c.extra_flags=
6464
compiler.c.elf.extra_flags=
6565
compiler.cpp.extra_flags=
6666
compiler.S.extra_flags=

0 commit comments

Comments
 (0)