mirror of https://github.com/ARMmbed/mbed-os.git
[Nuvoton] Fix HAL sleep test failure with lp_ticker
Replace wait_us with nu_busy_wait_us in lp_ticker since wait_us is not allowed in sleep test which would suspend us ticker layer on which wait_us relies. nu_busy_wait_us is implemented by calling us ticker HAL API directly rather than relying on us ticker layer.pull/8049/head
parent
26c0444cc3
commit
310b12a235
|
@ -19,9 +19,9 @@
|
|||
#if DEVICE_LPTICKER
|
||||
|
||||
#include "sleep_api.h"
|
||||
#include "mbed_wait_api.h"
|
||||
#include "mbed_assert.h"
|
||||
#include "nu_modutil.h"
|
||||
#include "nu_timer.h"
|
||||
#include "nu_miscutil.h"
|
||||
#include "partition_M2351.h"
|
||||
|
||||
|
@ -137,10 +137,10 @@ void lp_ticker_init(void)
|
|||
// Continuous mode
|
||||
// NOTE: TIMER_CTL_CNTDATEN_Msk exists in NUC472, but not in M451/M480/M2351. In M451/M480/M2351, TIMER_CNT is updated continuously by default.
|
||||
timer_base->CTL = TIMER_CONTINUOUS_MODE | prescale_timer/* | TIMER_CTL_CNTDATEN_Msk*/;
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
timer_base->CMP = cmp_timer;
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
// Set vector
|
||||
NVIC_SetVector(TIMER_MODINIT.irq_n, (uint32_t) TIMER_MODINIT.var);
|
||||
|
@ -148,13 +148,13 @@ void lp_ticker_init(void)
|
|||
NVIC_DisableIRQ(TIMER_MODINIT.irq_n);
|
||||
|
||||
TIMER_EnableInt(timer_base);
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
TIMER_EnableWakeup(timer_base);
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
TIMER_Start(timer_base);
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
/* Wait for timer to start counting and raise active flag */
|
||||
while(! (timer_base->CTL & TIMER_CTL_ACTSTS_Msk));
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
#if DEVICE_LPTICKER
|
||||
|
||||
#include "sleep_api.h"
|
||||
#include "mbed_wait_api.h"
|
||||
#include "mbed_assert.h"
|
||||
#include "nu_modutil.h"
|
||||
#include "nu_timer.h"
|
||||
#include "nu_miscutil.h"
|
||||
|
||||
/* Micro seconds per second */
|
||||
|
@ -103,10 +103,10 @@ void lp_ticker_init(void)
|
|||
// Continuous mode
|
||||
// NOTE: TIMER_CTL_CNTDATEN_Msk exists in NUC472, but not in M451. In M451, TIMER_CNT is updated continuously by default.
|
||||
timer_base->CTL = TIMER_CONTINUOUS_MODE | prescale_timer/* | TIMER_CTL_CNTDATEN_Msk*/;
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
timer_base->CMP = cmp_timer;
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
// Set vector
|
||||
NVIC_SetVector(TIMER_MODINIT.irq_n, (uint32_t) TIMER_MODINIT.var);
|
||||
|
@ -114,13 +114,13 @@ void lp_ticker_init(void)
|
|||
NVIC_DisableIRQ(TIMER_MODINIT.irq_n);
|
||||
|
||||
TIMER_EnableInt(timer_base);
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
TIMER_EnableWakeup(timer_base);
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
TIMER_Start(timer_base);
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
/* Wait for timer to start counting and raise active flag */
|
||||
while(! (timer_base->CTL & TIMER_CTL_ACTSTS_Msk));
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
#if DEVICE_LPTICKER
|
||||
|
||||
#include "sleep_api.h"
|
||||
#include "mbed_wait_api.h"
|
||||
#include "mbed_assert.h"
|
||||
#include "nu_modutil.h"
|
||||
#include "nu_timer.h"
|
||||
#include "nu_miscutil.h"
|
||||
|
||||
/* Micro seconds per second */
|
||||
|
@ -103,10 +103,10 @@ void lp_ticker_init(void)
|
|||
// Continuous mode
|
||||
// NOTE: TIMER_CTL_CNTDATEN_Msk exists in NUC472, but not in M451/M480. In M451/M480, TIMER_CNT is updated continuously by default.
|
||||
timer_base->CTL = TIMER_CONTINUOUS_MODE | prescale_timer/* | TIMER_CTL_CNTDATEN_Msk*/;
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
timer_base->CMP = cmp_timer;
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
// Set vector
|
||||
NVIC_SetVector(TIMER_MODINIT.irq_n, (uint32_t) TIMER_MODINIT.var);
|
||||
|
@ -114,13 +114,13 @@ void lp_ticker_init(void)
|
|||
NVIC_DisableIRQ(TIMER_MODINIT.irq_n);
|
||||
|
||||
TIMER_EnableInt(timer_base);
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
TIMER_EnableWakeup(timer_base);
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
TIMER_Start(timer_base);
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
/* Wait for timer to start counting and raise active flag */
|
||||
while(! (timer_base->CTL & TIMER_CTL_ACTSTS_Msk));
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
#if DEVICE_LPTICKER
|
||||
|
||||
#include "sleep_api.h"
|
||||
#include "mbed_wait_api.h"
|
||||
#include "mbed_assert.h"
|
||||
#include "nu_modutil.h"
|
||||
#include "nu_timer.h"
|
||||
#include "nu_miscutil.h"
|
||||
|
||||
/* Micro seconds per second */
|
||||
|
@ -104,13 +104,13 @@ void lp_ticker_init(void)
|
|||
MBED_ASSERT(cmp_timer >= TMR_CMP_MIN && cmp_timer <= TMR_CMP_MAX);
|
||||
// Continuous mode
|
||||
timer_base->CTL = TIMER_CONTINUOUS_MODE;
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
timer_base->PRECNT = prescale_timer;
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
timer_base->CMPR = cmp_timer;
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
// Set vector
|
||||
NVIC_SetVector(TIMER_MODINIT.irq_n, (uint32_t) TIMER_MODINIT.var);
|
||||
|
@ -118,13 +118,13 @@ void lp_ticker_init(void)
|
|||
NVIC_DisableIRQ(TIMER_MODINIT.irq_n);
|
||||
|
||||
TIMER_EnableInt(timer_base);
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
TIMER_EnableWakeup(timer_base);
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
TIMER_Start(timer_base);
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
/* Wait for timer to start counting and raise active flag */
|
||||
while(! (timer_base->CTL & TIMER_CTL_TMR_ACT_Msk));
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
#if DEVICE_LPTICKER
|
||||
|
||||
#include "sleep_api.h"
|
||||
#include "mbed_wait_api.h"
|
||||
#include "mbed_assert.h"
|
||||
#include "nu_modutil.h"
|
||||
#include "nu_timer.h"
|
||||
#include "nu_miscutil.h"
|
||||
|
||||
/* Micro seconds per second */
|
||||
|
@ -102,10 +102,10 @@ void lp_ticker_init(void)
|
|||
MBED_ASSERT(cmp_timer >= TMR_CMP_MIN && cmp_timer <= TMR_CMP_MAX);
|
||||
// Continuous mode
|
||||
timer_base->CTL = TIMER_CONTINUOUS_MODE | prescale_timer | TIMER_CTL_CNTDATEN_Msk;
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
timer_base->CMP = cmp_timer;
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
// Set vector
|
||||
NVIC_SetVector(TIMER_MODINIT.irq_n, (uint32_t) TIMER_MODINIT.var);
|
||||
|
@ -113,13 +113,13 @@ void lp_ticker_init(void)
|
|||
NVIC_DisableIRQ(TIMER_MODINIT.irq_n);
|
||||
|
||||
TIMER_EnableInt(timer_base);
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
TIMER_EnableWakeup(timer_base);
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
TIMER_Start(timer_base);
|
||||
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
nu_busy_wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);
|
||||
|
||||
/* Wait for timer to start counting and raise active flag */
|
||||
while(! (timer_base->CTL & TIMER_CTL_ACTSTS_Msk));
|
||||
|
|
Loading…
Reference in New Issue