Commit Graph

33 Commits (d8c2c6f97fe419d682cdc11d859a4ce2952ca23d)

Author SHA1 Message Date
int_szyk a95450bdc0 AStyle 2019-09-02 10:48:41 +02:00
int_szyk 16c5121705 Fix problem with low level lp_ticker STM wrapper 2019-09-02 10:48:40 +02:00
jeromecoutant 96a773a0e6 STM32L4: update drivers version to CUBE V1.14.0 2019-07-19 13:15:07 +02:00
Laurent Meunier 58a4685811 STM32: lp_ticker optim: initialize handle once only 2019-07-01 09:33:23 +02:00
Laurent Meunier ee95c7e64a STM32: lp_ticker optim: remove irq_handler variable 2019-07-01 09:33:23 +02:00
Laurent Meunier 8616cd7655 Update comments and fix typo 2019-07-01 09:33:23 +02:00
Laurent Meunier 501881bf38 Update warning now that C++ wrapper is not needed anymore
Now we'd rather not use this wrapper and use instead the low level
wrapper implemented in this driver.
2019-07-01 09:33:22 +02:00
Laurent Meunier d4ec62ff0c Manage lp_ticker delay at low level
LP TICKER mbed-os wrapper needs to be disabled as it introduces too much latencies.

LP TICKER wrapper has been disabled and we need to managed the HW constraints at low level:
- main HW constraint is that once the comparator has been programmed once,
driver cannot program it again before CMPOK HW flag is set, which takes about 3 30us cycles.

To make it even more complex, the driver also needs to cope with "LP ticker workaround"

See commit:

LP ticker workaround

    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).

Also the disable interrupt is more complete now:
- always check sleep manager status and restore it
- remove irq_handler as comparator is always programed and might get called
eventually when LP TICK is restarted
- reset delayed_prog

Also in set_interrupt, make sure interrupt does not fire early.
If needed, we decide to slightly delay the tick to cope with the HW limitation to
make sure it will fire as soon as HW is capable.

Functions are called under critical section as they may be called from
the IRQ handler now, not only from driver layer.
2019-07-01 09:31:53 +02:00
Laurent Meunier 6452eb3172 LP ticker workaround
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-07-01 09:31:53 +02:00
Laurent Meunier 27e7e4d9df NUCLEO_WB55RG: Rework Clock and sleep support
- move hw_conf.h file to targets/TARGET_STM/TARGET_STM32WB directory as
this is used also out of BLE feature.
- create a dedicated hal_deepsleep function as the behavior in WB is a lot
different from other existing STM32 targets
- update clock tree configuration to directly clock the entire tree @ 32MHz
out of HSE. This is needed as we want to let the M0 core running without
any change on M0-side of clocks when M4 enters /exits deep sleep.
2019-03-29 16:21:40 +01:00
jeromecoutant 0d620fe720 STM32 LPTICKER (LPTIM): correct init execution after bootloader 2019-02-21 16:25:20 +01:00
jeromecoutant 4aca14fe8b STM32 LPTIM update for easy maintenance 2018-12-04 11:08:34 +01:00
Martin Kojtal fa858a58ac
Merge pull request #8771 from jeromecoutant/PR_LPTICKER_LPTIM
STM32 LPTICKER with LPTIM optimisation
2018-11-30 14:31:52 +01:00
jeromecoutant f9ddc5a08e STM32 LPTICKER with LPTIM optimisation 2018-11-20 15:03:44 +01:00
jeromecoutant 1ec222f268 STM32 LPTICKER with LPTIM : reduce clock feature 2018-11-16 15:34:57 +01:00
jeromecoutant 9bc2e5a5ad STM32 LPTICKER with RTC : Fix tickless and lp wrapper
When both tickless and LPTICKER_DELAY_TICKS are enabled some ST
devices randomly get stuck sleeping forever. This is because the
wake up time passed to the rtc is ignored if the previous match is
about to occur. This causes the device to get stuck in sleep.

This patch prevents matches from getting dropped by the rtc by
deactivating the rtc wake up timer before setting a new value.

Events leading up to this failure for the RTC:

-1st call to lp_ticker_set_interrupt
-delay until ticker interrupt is about to fire
-2nd call to lp_ticker_set_interrupt
-interrupt for 1st call fires and match time for 2nd call is dropped
-LowPowerTickerWrapper gets ticker interrupt but treats it as a
 spurious interrupt and drops it since it comes in too early
-device enters sleep without a wakeup source and locks up
2018-09-27 14:31:36 +02:00
jeromecoutant b1d23e5ec5 STM32 LPTICKER with LPTIM : Fix tickless and lp wrapper
This fixes issue with mbed_hal/lp_ticker/lp_ticker_early_match_race_test
2018-09-27 14:30:00 +02:00
jeromecoutant 7b77e50082 STM32 LPTICKER : RTC wake up timer is reset before settign a new one 2018-08-14 13:59:48 +02:00
Przemyslaw Stekiel ace821017f Add implementation of ticker_free() function to CI boards.
This PR provides implementation of ticker_free() function for the following boards:
ARCH_PRO
EV_COG_AD3029LZ
EV_COG_AD4050LZ
K22F
K64F
K82F
KW24D
KW41Z
LPC546XX
NRF51_DK
NRF52_DK
NUCLEO_F207ZG
NUCLEO_F401RE
NUCLEO_F429ZI
NUCLEO_F746ZG
REALTEK_RTL8195AM
2018-08-02 09:48:10 +02:00
Przemyslaw Stekiel c0ee843d63 Add lp/us ticker_free() functions stub.
This patch adds only empty stubs of `us_ticker_free()` and `lp_ticker_free()` for all boards where these functions are not implemented.
2018-07-25 08:58:38 +02:00
jeromecoutant 8a0b83233a STM32 LPTICKER with LPTIM minor update
Code cleaning (L0 Cube update, comment precision)
2018-07-13 10:03:31 +02:00
jeromecoutant 433ba46132 TARGET_STM astyle 2018-06-27 14:21:07 +02:00
jeromecoutant e3deaecc27 STM32 LPTICKER update for targets supporting RTC 2018-05-25 12:29:54 -05:00
jeromecoutant 39a9801675 STM32 LPTICKER : clean include file 2018-05-25 12:29:54 -05:00
jeromecoutant 2b8d6cbcc5 STM32 LPTICKER : read counter 2018-05-25 12:26:05 -05:00
jeromecoutant 5701fd5ab6 STM32 LPTICKER update for targets supporting LPTIMER 2018-05-25 12:22:35 -05:00
Bartek Szatkowski 6e9f04bf2f Rename DEVICE_LOWPOWERTIMER to DEVICE_LPTICKER
That's to match DEVICE_USTICKER.
2018-05-25 12:20:09 -05:00
jeromecoutant 9fb865ae57 STM32 LPT optimisation 2018-01-16 15:16:13 +01:00
jeromecoutant a816e93e9a STM32 LOWPOWERTIMER : introduce LPTIM feature
STM32L0, L4, F7 and few F4 chip are supporting LPTIM feature.
We propose to allow user to use LPTIM for MBED LowPowerTimer API instead of using RTC wakeup timers.

By default, all targets that are supporting this feature have been configured.
2018-01-09 14:10:14 +01:00
jeromecoutant b65e861b20 STM32 LOW_POWER_TIMER update : lp_ticker
Removed unnecessary part
2017-12-04 17:35:27 +01:00
Martin Kojtal 10ea63b8e7 Ticker: add fire interrupt now function
fire_interrupt function should be used for events in the past. As we have now
64bit timestamp, we can figure out what is in the past, and ask a target to invoke
an interrupt immediately. The previous attemps in the target HAL tickers were not ideal, as it can wrap around easily (16 or 32 bit counters). This new
functionality should solve this problem.

set_interrupt for tickers in HAL code should not handle anything but the next match interrupt. If it was in the past is handled by the upper layer.

It is possible that we are setting next event to the close future, so once it is set it is already in the past. Therefore we add a check after set interrupt to verify it is in future.
If it is not, we fire interrupt immediately. This results in
two events - first one immediate, correct one. The second one might be scheduled in far future (almost entire ticker range),
that should be discarded.

The specification for the fire_interrupts are:
- should set pending bit for the ticker interrupt (as soon as possible),
the event we are scheduling is already in the past, and we do not want to skip
any events
- no arguments are provided, neither return value, not needed
- ticker should be initialized prior calling this function (no need to check if it is already initialized)

All our targets provide this new functionality, removing old misleading if (timestamp is in the past) checks.
2017-07-13 12:23:25 +01:00
jeromecoutant 2b4d83ef1e Run astyle 2016-12-21 16:54:19 +00:00
jeromecoutant ab28a5e5cb STM32: Refactor lp_ticker.c + rtc_api.c + sleep.c + rtc_api_hal.h files 2016-12-21 16:54:18 +00:00