Commit Graph

30 Commits (96ecd48a40e7185f7d8749b3e6e51f98f78e8df7)

Author SHA1 Message Date
jeromecoutant 2496f1dc16 STM32 SLEEP update for easy maintenance 2018-12-04 11:08:31 +01:00
jeromecoutant 7b605b6160 STM32L4 : sleep issue 2018-10-15 10:19:42 +02:00
Martin Kojtal 232543ac4b
Merge pull request #7813 from MSiglreithmaierRB/os_sleep_stm32l4
STM32L4: Fix sleep implementation
2018-10-01 17:24:12 +02:00
Markus Siglreithmaier ea6c886d22 STM32L4: Use HAL layer functions for sleep implementation 2018-09-26 08:54:13 +02:00
Filip Jagodzinski 6821556b47 STM: Fix us_ticker timestamp after deep sleep
Use the `mbed_sdk_inited` flag to correct the `HAL_GetTick()` behavior
after waking up from deep sleep mode. `ticker_read_us()` must not be
used to read us_ticker timestamp after waking up until the us_ticker
context is restored. More detailed description in issue #8117.

Fixes #8117
2018-09-14 15:44:40 +02:00
Markus Siglreithmaier 97fef1160c STM32L4: Fix sleep implementation
Correctly detect and handle the low power run mode when entering and exiting sleep mode.

The generic `hal_sleep` implementation tries to exit LPR mode always, resulting in a spin-loop during a critical section (disabled IRQ).
The new approach returns from LPR to Run mode if enabled (LPR bit set), enters sleep, and resets to the original state on wakeup (WFI).
2018-08-13 09:21:31 +02:00
Laurent Meunier e12d98e1c0 Use HAL coding style for function naming 2018-08-07 13:42:46 +02:00
Laurent Meunier 402f3f1c3f STM32: check for UART ongoing transfers before entering deepsleep
As suggested by Russ Butler in mbed-os issue #7328, and until there is an
implementation of mbed-os issue #4408, we are implementing a workaround
at HAL level to check if there is any ongoing serial transfer (which happens
if HW FIFO is not yet empty).

In case a transfer is ongoing, we're not entering deep sleep and
return immediately.
2018-08-07 11:30:53 +02:00
Cruz Monrreal e1df16e843
Merge pull request #7365 from jeromecoutant/PR_RTC_SHADOW
STM32 RTC : bypass shadow registers
2018-07-11 21:29:02 -05:00
bcostm 32031cbab3 stm32 ticker: rename hal_tick.h in us_ticker_data.h 2018-07-11 14:42:44 +02:00
jeromecoutant 1052993236 STM32 RTC : bypass shadow registers
- RTC_SSR for the subseconds
- RTC_TR for the time
- RTC_DR for the date

These registers were accessed through shadow registers which are synchronized with PCLK1 (APB1 clock).
They are now accessed directly in order to avoid waiting for the synchronization duration.
2018-07-11 10:08:02 +02:00
bcostm a838cb21d1 save/restore timer registers before/after deepsleep 2018-07-04 16:44:00 +02:00
bcostm fcdd529f89 Re-enable IT CC1 after deepsleep 2018-07-04 10:16:32 +02:00
jeromecoutant 433ba46132 TARGET_STM astyle 2018-06-27 14:21:07 +02:00
Laurent MEUNIER 81adafb5a7 STM32: Reduce HAL_deepsleep stack usage
There are cases where a call hal_deepsleep would overflow the idle task
stack, especially in developper or debug profile.

In order to avoid this case, we split ForceClockOutofDeepSleep
into two separate functions the two structure RCC_ClkInitStruct and
RCC_OscInitStruct are not allocated at the same time.
2018-06-19 17:32:00 +02:00
bcostm e09e1147d8 Cleanup
- Remove calls to HAL_SuspendTick and HAL_ResumeTick
- Rename stm_common.c in hal_tick_common.c
2018-06-05 14:48:54 +02:00
jeromecoutant 39a9801675 STM32 LPTICKER : clean include file 2018-05-25 12:29:54 -05:00
Laurent MEUNIER ad4a250292 Style fix 2018-04-06 17:03:53 +02:00
Laurent MEUNIER 3d92af50ce Add delay to let clock stabilize when out of deep sleep
Tests have shown that there is hich-up on MSI clock during the setup phase.
If this stabilization phase happens when application has restarted again
this can have side effects, like grambled UART characters typically.

So we're adding a delay before hading-over back to application.

With this modification, on NCULEO_L476RG, the wake-up time is increased
from 2ms to 2,5ms.
If possible this should be improved in the future to save 500 microseconds
of wak-up time.  See TODO
2018-04-06 16:10:27 +02:00
Laurent MEUNIER 8007b1df7c Use temporarily MSI or HSI when exiting Deep Sleep
There are cases where HW registers are found in unpexcepted state when
exiting Deep Sleep only few micro-seconds after it was entered.

By using an internal clock that does not depend on anythin and clocking
the system without using PLL, this allows SetSysClock default configuration
to run fine whatever possible configuration we find the HW in when
exiting Deep Sleep.

Also we shall restore interrupts only after all cloks are back to
expected running state.
2018-04-06 16:10:27 +02: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 c13ffaf477 STM32 LOW_POWER_TIMER update : sleep
RSF synchro after deepsleep is not specific to Low Power Timer feature
And we have to check if RTC is configured before synchro
2017-12-04 17:35:29 +01:00
Wolfgang Betz e2dc67750c Make HAL & US tickers idle safe 2017-08-09 14:29:57 +02:00
jeromecoutant 053072c2dc STM32 : set back US counter after deepsleep 2017-02-21 17:46:15 +01:00
jeromecoutant e8519416c1 STM32 sleep.c remove compilation warning 2017-02-21 17:46:11 +01:00
Helmut Tschemernjak 10bb94a365 Fixed code style violation needs '{' 2017-02-07 22:24:20 +01:00
Helmut Tschemernjak 605059e683 Fixed a problem that the STOP2 was falling back to STOP1 because
the LPR was not turned on. Now the deepsleep mode only needs 1.6uA
instead of 10uA.
2017-01-31 11:44:41 +01:00
Bartek Szatkowski 6a045a49a9 Platform: Add sleep/deepsleep user facing functions
Add sleep/deepsleep functions to platform layer which are replacing HAL
functions with the same name, rename existing symbols in HAL layer
to hal_sleep/hal_deepsleep. This way sleep functions
are always available, even if target doesn't implement them, which makes
the code using sleep clearer. It also enables us to make decision on in
which builds (debug/release) the sleep will be enabled.
2017-01-19 09:39:29 +00:00
jeromecoutant 633240b93b STM32L4 deepsleep improvement 2017-01-09 12:21:24 +01: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