Commit Graph

25 Commits (8b6d0920a8df97e00e84c54cb521ed6d177b5662)

Author SHA1 Message Date
Przemyslaw Stekiel 874ff1fe22 tests-mbed_hal-sleep: add exception for STM LPTIM targets.
On some targets like STM family boards with LPTIM enabled an interrupt is triggered on counter rollover.
We need special handling for cases when next_match_timestamp < start_timestamp (interrupt is to be fired after rollover).
In such case after first wake-up we need to reset interrupt and go back to sleep waiting for the valid one.

On some targets like STM family boards with LPTIM enabled there is a required delay (~100 us) before we are able to reprogram LPTIM_COMPARE register back to back.
This is handled by the low level lp ticker wrapper which uses LPTIM_CMPOK interrupt. CMPOK fires when LPTIM_COMPARE register can be safely reprogrammed again.
This means that on these platforms we have additional interrupt (CMPOK) fired always ~100 us after programming lp ticker.
Since this interrupt wake-ups the board from the sleep we need to go to sleep after CMPOK is handled.

Background:
There is an errata in LPTIM specification that explains that CMP Flag
condition is not an exact match (COUNTER = MATCH) but rather a
comparison (COUNTER >= MATCH).

As a consequence the interrupt is firing early than expected when
programing a timestamp after the 0xFFFF wrap-around.

In order to
work-around this issue, we implement the below work-around.
In case timestamp is after the work-around, let's decide to program the
CMP value to 0xFFFF, which is the wrap-around value. There would anyway be
a wake-up at the time of wrap-around to let the OS update the system time.
When the wrap-around interrupt happen, OS will check the current time and
program again the timestamp to the proper value.
2019-05-31 14:16:34 +02:00
Alastair D'Silva 2617c5d55b Don't use define checks on DEVICE_FOO macros (mbed code)
The DEVICE_FOO macros are always defined (either 0 or 1).

This patch replaces any instances of a define check on a DEVICE_FOO
macro with value test instead.

Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
2018-12-20 10:16:42 +11:00
Martin Kojtal ef728d01dc tests: fix doxygen style 2018-11-15 07:20:12 +00:00
Cruz Monrreal II 14ce8f2721 Merge branch 'fix-freestanding-tests-module' of ssh://github.com/pan-/mbed into rollup 2018-10-26 11:42:59 -05:00
Martin Kojtal f90f1fc01d sleep test: fix coding style 2018-10-25 09:58:18 +01:00
Martin Kojtal bbfa322afb tests: fix astyle 2018-10-25 09:58:17 +01:00
Vincent Coubard 85bd15ce6e Doxygen: Move free standing HAL tests module inside their related HAL module. 2018-10-24 14:42:29 +01:00
Filip Jagodzinski 9e34f76b4e Tests: Sleep: Extract test utility functions
Move a few of utility functions so other tests can use them.
2018-10-09 17:52:44 +02:00
Przemyslaw Stekiel 1fced21d3b tests-mbed_hal-sleep: add message with failure details 2018-09-30 19:31:50 +02:00
Przemyslaw Stekiel 25b23a9286 tests-mbed_hal-sleep: finish UART transmission before sleep test
There is no problem with this test during the morph, but some issue has been noticed while testing new Jenkins CI in Oulu on NRF52_DK.
I was able to reproduce the issue locally. The difference between morph and local run is that CPU statistics are enabled on morph. This makes the difference and test passes.

The sleep test case perform sleep for 100 us, 200 us, ... ,1000 us in loop (us ticker wakes the board) and verifies if sleep time matches the assumption.
I got the following results:

sleep                 wake-up after
100 us                   ~100 us    ok
200 us                   ~200 us    ok
300 us                   ~300 us    ok
400 us                   ~400 us    ok
500 us                   ~14 us     (??)

When requested sleep time is equal to 500 us some unexpected interrupt occurs which wakeup the board and force the test to fail.
Register state just after exit from sleep:
Control and State Register: 0x00400000 (ISRPENDING - Interrupt pending flag is set).
NVIC Interrupt Set-pending Register[0]: 0x00000004 (UARTE0_UART0_IRQn) or 0x00000200 (TIMER1_IRQn - timer used by us ticker).

UART interrupt is generated because of green-tea transmission. We know that it is performed while test is executed since we need to wait before going into deep-sleep since otherwise the transmission will be broken. So to take care of UART interrupt we need to wait before sleep test in the same way like it is done in deep-sleep test.
2018-09-26 14:29:14 +02:00
Russ Butler f68958df4e Fix tests to work with LPTICKER_DELAY_TICKS
Fix the HAL common_tickers and sleep tests so they work correctly when
the define LPTICKER_DELAY_TICKS is set.
2018-08-17 11:58:55 -05:00
Martin Kojtal e52bb68f93 tests: astyle fix
All tests should comply to our coding standard now
2018-08-03 10:23:38 +01:00
ccli8 9416a32636 Enlarge wait time for flushing serial buffer in Greentea test code
Original wait time is not enough for UART to flush out before deepsleep on some targets.
2018-06-21 15:55:14 +08:00
Maciej Bocianski 53548e212b fix and enable sleep_usticker_test
Increases tolerance value for sleep_usticker_test to cover extra time needed
for cpu stats computation (for more details see MBED_CPU_STATS_ENABLED).
Prevent scheduling interrupt during ticker initialization (in lp_ticker_init)
while test execution.
2018-06-11 10:07:34 +02:00
Maciej Bocianski fb28c41be1 enable HAL sleep test 2018-06-05 06:56:48 +02:00
Maciej Bocianski 0ed26e58a0 HAL sleep test fix
Prevents ticker upper layer initialization during test execution
2018-06-05 06:56:47 +02:00
Bartek Szatkowski 4ae6491fd5 Disable sleep tests as they are unstable 2018-05-27 23:31:20 -05:00
Bartek Szatkowski 817bf0b092 Disable intermittently failing sleep test 2018-05-27 23:31:20 -05:00
Bartek Szatkowski a305d849a8 Rename LOWPOWERTIMER to LPTICKER 2018-05-25 13:06:56 -05:00
Przemyslaw Stekiel f226ae2fc9 tests-mbed_hal-sleep: decrease delay when testing if us ticker is disabled in deep-sleep mode.
This is done because of possible limitations of lowpower ticker freq/width.
2018-05-25 12:04:32 -05:00
Przemyslaw Stekiel 996374e4dc tests-mbed_hal-sleep: fix formatting. 2018-05-25 12:04:32 -05:00
Przemyslaw Stekiel 7f56bb0c23 tests-mbed_hal-sleep: remove unused variable. 2018-05-25 12:04:32 -05:00
Przemyslaw Stekiel 20a9da5b73 tests-mbed_hal-sleep: use lp ticker data while testing deepsleep. 2018-05-25 12:04:32 -05:00
Przemyslaw Stekiel 160c75d099 tests-mbed_hal-sleep: add lp/us ticker overflow handling. 2018-05-25 12:04:32 -05:00
Przemyslaw Stekiel b2d3338ad7 Add test and test header to Sleep HAL API. 2018-05-25 12:03:37 -05:00