Skip to content

Nuvoton: Fix Greentea test common_tickers failed #8030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion TESTS/mbed_hal/common_tickers/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,14 @@ void ticker_speed_test(void)

/* ---- Test fire_interrupt function. ---- */
counter = NUM_OF_CALLS;
/* Disable ticker interrupt which would interfere with speed test */
core_util_critical_section_enter();
start = us_ticker_read();
while (counter--) {
intf->fire_interrupt();
}
stop = us_ticker_read();
core_util_critical_section_exit();

TEST_ASSERT(diff_us(start, stop, us_ticker_info) < (NUM_OF_CALLS * (MAX_FUNC_EXEC_TIME_US + DELTA_FUNC_EXEC_TIME_US)));

Expand Down Expand Up @@ -569,7 +572,7 @@ utest::v1::status_t lp_ticker_teardown(const Case *const source, const size_t pa

utest::v1::status_t test_setup(const size_t number_of_cases)
{
GREENTEA_SETUP(30, "default_auto");
GREENTEA_SETUP(80, "default_auto");
return verbose_test_setup_handler(number_of_cases);
}

Expand Down
22 changes: 4 additions & 18 deletions targets/TARGET_NUVOTON/TARGET_M2351/lp_ticker.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ void lp_ticker_init(void)
/* By HAL spec, ticker_init allows the ticker to keep counting and disables the
* ticker interrupt. */
lp_ticker_disable_interrupt();
lp_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);
return;
}
ticker_inited = 1;
Expand Down Expand Up @@ -162,23 +160,7 @@ void lp_ticker_init(void)

void lp_ticker_free(void)
{
TIMER_T *timer_base = (TIMER_T *) NU_MODBASE(TIMER_MODINIT.modname);

/* Stop counting */
TIMER_Stop(timer_base);
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);

/* Wait for timer to stop counting and unset active flag */
while((timer_base->CTL & TIMER_CTL_ACTSTS_Msk));

/* Disable wakeup */
TIMER_DisableWakeup(timer_base);
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);

/* Disable interrupt */
TIMER_DisableInt(timer_base);
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);

NVIC_DisableIRQ(TIMER_MODINIT.irq_n);

/* Disable IP clock
Expand All @@ -203,6 +185,10 @@ timestamp_t lp_ticker_read()

void lp_ticker_set_interrupt(timestamp_t timestamp)
{
/* Clear any previously pending interrupts */
lp_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);

/* In continuous mode, counter will be reset to zero with the following sequence:
* 1. Stop counting
* 2. Configure new CMP value
Expand Down
15 changes: 4 additions & 11 deletions targets/TARGET_NUVOTON/TARGET_M2351/us_ticker.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ void us_ticker_init(void)
/* By HAL spec, ticker_init allows the ticker to keep counting and disables the
* ticker interrupt. */
us_ticker_disable_interrupt();
us_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);
return;
}
ticker_inited = 1;
Expand Down Expand Up @@ -125,16 +123,7 @@ void us_ticker_init(void)

void us_ticker_free(void)
{
TIMER_T *timer_base = (TIMER_T *) NU_MODBASE(TIMER_MODINIT.modname);

/* Stop counting */
TIMER_Stop(timer_base);

/* Wait for timer to stop counting and unset active flag */
while((timer_base->CTL & TIMER_CTL_ACTSTS_Msk));

/* Disable interrupt */
TIMER_DisableInt(timer_base);
NVIC_DisableIRQ(TIMER_MODINIT.irq_n);

/* Disable IP clock
Expand All @@ -159,6 +148,10 @@ uint32_t us_ticker_read()

void us_ticker_set_interrupt(timestamp_t timestamp)
{
/* Clear any previously pending interrupts */
us_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);

/* In continuous mode, counter will be reset to zero with the following sequence:
* 1. Stop counting
* 2. Configure new CMP value
Expand Down
22 changes: 4 additions & 18 deletions targets/TARGET_NUVOTON/TARGET_M451/lp_ticker.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ void lp_ticker_init(void)
/* By HAL spec, ticker_init allows the ticker to keep counting and disables the
* ticker interrupt. */
lp_ticker_disable_interrupt();
lp_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);
return;
}
ticker_inited = 1;
Expand Down Expand Up @@ -128,23 +126,7 @@ void lp_ticker_init(void)

void lp_ticker_free(void)
{
TIMER_T *timer_base = (TIMER_T *) NU_MODBASE(TIMER_MODINIT.modname);

/* Stop counting */
TIMER_Stop(timer_base);
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);

/* Wait for timer to stop counting and unset active flag */
while((timer_base->CTL & TIMER_CTL_ACTSTS_Msk));

/* Disable wakeup */
TIMER_DisableWakeup(timer_base);
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);

/* Disable interrupt */
TIMER_DisableInt(timer_base);
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);

NVIC_DisableIRQ(TIMER_MODINIT.irq_n);

/* Disable IP clock */
Expand All @@ -166,6 +148,10 @@ timestamp_t lp_ticker_read()

void lp_ticker_set_interrupt(timestamp_t timestamp)
{
/* Clear any previously pending interrupts */
lp_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);

/* In continuous mode, counter will be reset to zero with the following sequence:
* 1. Stop counting
* 2. Configure new CMP value
Expand Down
15 changes: 4 additions & 11 deletions targets/TARGET_NUVOTON/TARGET_M451/us_ticker.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ void us_ticker_init(void)
/* By HAL spec, ticker_init allows the ticker to keep counting and disables the
* ticker interrupt. */
us_ticker_disable_interrupt();
us_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);
return;
}
ticker_inited = 1;
Expand Down Expand Up @@ -93,16 +91,7 @@ void us_ticker_init(void)

void us_ticker_free(void)
{
TIMER_T *timer_base = (TIMER_T *) NU_MODBASE(TIMER_MODINIT.modname);

/* Stop counting */
TIMER_Stop(timer_base);

/* Wait for timer to stop counting and unset active flag */
while((timer_base->CTL & TIMER_CTL_ACTSTS_Msk));

/* Disable interrupt */
TIMER_DisableInt(timer_base);
NVIC_DisableIRQ(TIMER_MODINIT.irq_n);

/* Disable IP clock */
Expand All @@ -124,6 +113,10 @@ uint32_t us_ticker_read()

void us_ticker_set_interrupt(timestamp_t timestamp)
{
/* Clear any previously pending interrupts */
us_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);

/* In continuous mode, counter will be reset to zero with the following sequence:
* 1. Stop counting
* 2. Configure new CMP value
Expand Down
22 changes: 4 additions & 18 deletions targets/TARGET_NUVOTON/TARGET_M480/lp_ticker.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ void lp_ticker_init(void)
/* By HAL spec, ticker_init allows the ticker to keep counting and disables the
* ticker interrupt. */
lp_ticker_disable_interrupt();
lp_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);
return;
}
ticker_inited = 1;
Expand Down Expand Up @@ -128,23 +126,7 @@ void lp_ticker_init(void)

void lp_ticker_free(void)
{
TIMER_T *timer_base = (TIMER_T *) NU_MODBASE(TIMER_MODINIT.modname);

/* Stop counting */
TIMER_Stop(timer_base);
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);

/* Wait for timer to stop counting and unset active flag */
while((timer_base->CTL & TIMER_CTL_ACTSTS_Msk));

/* Disable wakeup */
TIMER_DisableWakeup(timer_base);
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);

/* Disable interrupt */
TIMER_DisableInt(timer_base);
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);

NVIC_DisableIRQ(TIMER_MODINIT.irq_n);

/* Disable IP clock */
Expand All @@ -166,6 +148,10 @@ timestamp_t lp_ticker_read()

void lp_ticker_set_interrupt(timestamp_t timestamp)
{
/* Clear any previously pending interrupts */
lp_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);

/* In continuous mode, counter will be reset to zero with the following sequence:
* 1. Stop counting
* 2. Configure new CMP value
Expand Down
15 changes: 4 additions & 11 deletions targets/TARGET_NUVOTON/TARGET_M480/us_ticker.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ void us_ticker_init(void)
/* By HAL spec, ticker_init allows the ticker to keep counting and disables the
* ticker interrupt. */
us_ticker_disable_interrupt();
us_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);
return;
}
ticker_inited = 1;
Expand Down Expand Up @@ -93,16 +91,7 @@ void us_ticker_init(void)

void us_ticker_free(void)
{
TIMER_T *timer_base = (TIMER_T *) NU_MODBASE(TIMER_MODINIT.modname);

/* Stop counting */
TIMER_Stop(timer_base);

/* Wait for timer to stop counting and unset active flag */
while((timer_base->CTL & TIMER_CTL_ACTSTS_Msk));

/* Disable interrupt */
TIMER_DisableInt(timer_base);
NVIC_DisableIRQ(TIMER_MODINIT.irq_n);

/* Disable IP clock */
Expand All @@ -124,6 +113,10 @@ uint32_t us_ticker_read()

void us_ticker_set_interrupt(timestamp_t timestamp)
{
/* Clear any previously pending interrupts */
us_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);

/* In continuous mode, counter will be reset to zero with the following sequence:
* 1. Stop counting
* 2. Configure new CMP value
Expand Down
22 changes: 4 additions & 18 deletions targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ void lp_ticker_init(void)
/* By HAL spec, ticker_init allows the ticker to keep counting and disables the
* ticker interrupt. */
lp_ticker_disable_interrupt();
lp_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);
return;
}
ticker_inited = 1;
Expand Down Expand Up @@ -132,23 +130,7 @@ void lp_ticker_init(void)

void lp_ticker_free(void)
{
TIMER_T *timer_base = (TIMER_T *) NU_MODBASE(TIMER_MODINIT.modname);

/* Stop counting */
TIMER_Stop(timer_base);
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);

/* Wait for timer to stop counting and unset active flag */
while((timer_base->CTL & TIMER_CTL_TMR_ACT_Msk));

/* Disable wakeup */
TIMER_DisableWakeup(timer_base);
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);

/* Disable interrupt */
TIMER_DisableInt(timer_base);
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);

NVIC_DisableIRQ(TIMER_MODINIT.irq_n);

/* Disable IP clock */
Expand All @@ -170,6 +152,10 @@ timestamp_t lp_ticker_read()

void lp_ticker_set_interrupt(timestamp_t timestamp)
{
/* Clear any previously pending interrupts */
lp_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);

/* In continuous mode, counter will be reset to zero with the following sequence:
* 1. Stop counting
* 2. Configure new CMP value
Expand Down
15 changes: 4 additions & 11 deletions targets/TARGET_NUVOTON/TARGET_NANO100/us_ticker.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ void us_ticker_init(void)
/* By HAL spec, ticker_init allows the ticker to keep counting and disables the
* ticker interrupt. */
us_ticker_disable_interrupt();
us_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);
return;
}
ticker_inited = 1;
Expand Down Expand Up @@ -95,16 +93,7 @@ void us_ticker_init(void)

void us_ticker_free(void)
{
TIMER_T *timer_base = (TIMER_T *) NU_MODBASE(TIMER_MODINIT.modname);

/* Stop counting */
TIMER_Stop(timer_base);

/* Wait for timer to stop counting and unset active flag */
while((timer_base->CTL & TIMER_CTL_TMR_ACT_Msk));

/* Disable interrupt */
TIMER_DisableInt(timer_base);
NVIC_DisableIRQ(TIMER_MODINIT.irq_n);

/* Disable IP clock */
Expand All @@ -126,6 +115,10 @@ uint32_t us_ticker_read()

void us_ticker_set_interrupt(timestamp_t timestamp)
{
/* Clear any previously pending interrupts */
us_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);

/* In continuous mode, counter will be reset to zero with the following sequence:
* 1. Stop counting
* 2. Configure new CMP value
Expand Down
22 changes: 4 additions & 18 deletions targets/TARGET_NUVOTON/TARGET_NUC472/lp_ticker.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ void lp_ticker_init(void)
/* By HAL spec, ticker_init allows the ticker to keep counting and disables the
* ticker interrupt. */
lp_ticker_disable_interrupt();
lp_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);
return;
}
ticker_inited = 1;
Expand Down Expand Up @@ -127,23 +125,7 @@ void lp_ticker_init(void)

void lp_ticker_free(void)
{
TIMER_T *timer_base = (TIMER_T *) NU_MODBASE(TIMER_MODINIT.modname);

/* Stop counting */
TIMER_Stop(timer_base);
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);

/* Wait for timer to stop counting and unset active flag */
while((timer_base->CTL & TIMER_CTL_ACTSTS_Msk));

/* Disable wakeup */
TIMER_DisableWakeup(timer_base);
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);

/* Disable interrupt */
TIMER_DisableInt(timer_base);
wait_us((NU_US_PER_SEC / NU_TMRCLK_PER_SEC) * 3);

NVIC_DisableIRQ(TIMER_MODINIT.irq_n);

/* Disable IP clock */
Expand All @@ -165,6 +147,10 @@ timestamp_t lp_ticker_read()

void lp_ticker_set_interrupt(timestamp_t timestamp)
{
/* Clear any previously pending interrupts */
lp_ticker_clear_interrupt();
NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);

/* In continuous mode, counter will be reset to zero with the following sequence:
* 1. Stop counting
* 2. Configure new CMP value
Expand Down
Loading