File tree Expand file tree Collapse file tree 4 files changed +35
-5
lines changed
Expand file tree Collapse file tree 4 files changed +35
-5
lines changed Original file line number Diff line number Diff 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 */
Original file line number Diff line number Diff 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 */
Original file line number Diff line number Diff line change @@ -106,10 +106,12 @@ typedef unsigned long UBaseType_t;
106106extern void vPortEnterCritical ( void );
107107extern void vPortExitCritical ( void );
108108extern 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
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ nordic.path={build.core.path}/nordic
6060compiler.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=
6464compiler.c.elf.extra_flags=
6565compiler.cpp.extra_flags=
6666compiler.S.extra_flags=
You can’t perform that action at this time.
0 commit comments