Use CMSIS wrapped asm function in function "vPortSuppressTicksAndSleep"

This commit is contained in:
paperchalice 2020-03-27 12:45:10 +08:00
parent 464695a4f2
commit e27b56d4be

View file

@ -525,9 +525,9 @@ void xPortSysTickHandler( void )
/* Enter a critical section but don't use the taskENTER_CRITICAL() /* Enter a critical section but don't use the taskENTER_CRITICAL()
method as that will mask interrupts that should exit sleep mode. */ method as that will mask interrupts that should exit sleep mode. */
__asm volatile( "cpsid i" ::: "memory" ); __disable_irq();
__asm volatile( "dsb" ); __DSB();
__asm volatile( "isb" ); __ISB();
/* If a context switch is pending or a task is waiting for the scheduler /* If a context switch is pending or a task is waiting for the scheduler
to be unsuspended then abandon the low power entry. */ to be unsuspended then abandon the low power entry. */
@ -544,9 +544,8 @@ void xPortSysTickHandler( void )
periods. */ periods. */
portNVIC_SYSTICK_LOAD_REG = ulTimerCountsForOneTick - 1UL; portNVIC_SYSTICK_LOAD_REG = ulTimerCountsForOneTick - 1UL;
/* Re-enable interrupts - see comments above the cpsid instruction() /* Re-enable interrupts. */
above. */ __enable_irq();
__asm volatile( "cpsie i" ::: "memory" );
} }
else else
{ {
@ -569,26 +568,26 @@ void xPortSysTickHandler( void )
configPRE_SLEEP_PROCESSING( xModifiableIdleTime ); configPRE_SLEEP_PROCESSING( xModifiableIdleTime );
if( xModifiableIdleTime > 0 ) if( xModifiableIdleTime > 0 )
{ {
__asm volatile( "dsb" ::: "memory" ); __DSB();
__asm volatile( "wfi" ); __WFI();
__asm volatile( "isb" ); __ISB();
} }
configPOST_SLEEP_PROCESSING( xExpectedIdleTime ); configPOST_SLEEP_PROCESSING( xExpectedIdleTime );
/* Re-enable interrupts to allow the interrupt that brought the MCU /* Re-enable interrupts to allow the interrupt that brought the MCU
out of sleep mode to execute immediately. see comments above out of sleep mode to execute immediately. see comments above
__disable_interrupt() call above. */ __disable_interrupt() call above. */
__asm volatile( "cpsie i" ::: "memory" ); __enable_irq();
__asm volatile( "dsb" ); __DSB();
__asm volatile( "isb" ); __ISB();
/* Disable interrupts again because the clock is about to be stopped /* Disable interrupts again because the clock is about to be stopped
and interrupts that execute while the clock is stopped will increase and interrupts that execute while the clock is stopped will increase
any slippage between the time maintained by the RTOS and calendar any slippage between the time maintained by the RTOS and calendar
time. */ time. */
__asm volatile( "cpsid i" ::: "memory" ); __disable_irq();
__asm volatile( "dsb" ); __DSB();
__asm volatile( "isb" ); __ISB();
/* Disable the SysTick clock without reading the /* Disable the SysTick clock without reading the
portNVIC_SYSTICK_CTRL_REG register to ensure the portNVIC_SYSTICK_CTRL_REG register to ensure the
@ -655,7 +654,7 @@ void xPortSysTickHandler( void )
portNVIC_SYSTICK_LOAD_REG = ulTimerCountsForOneTick - 1UL; portNVIC_SYSTICK_LOAD_REG = ulTimerCountsForOneTick - 1UL;
/* Exit with interrupts enabled. */ /* Exit with interrupts enabled. */
__asm volatile( "cpsie i" ::: "memory" ); __enable_irq();
} }
} }