Skip to content

refactor: Improve reliability and simplify implementation #67

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 1 commit into from
Jun 6, 2022

Conversation

ABOSTM
Copy link
Contributor

@ABOSTM ABOSTM commented Jun 2, 2022

refactor: Improve reliability and simplify implementation

  • call HAL_RTC_Init() only when needed to avoid losing hundreds
    of milliseconds on RTC counter
  • remove useless check of _configured at the beginning of
    STM32RTC class methods
  • Use flag "INITS" to detect whether RTC calendar is initialized
    (except for F1 which doesn't have this flag)
    This prevent the use of year 2000 which is the default hardware
    reset value and doesn't trigger INITS flag
  • Use Backup registers only for F1, and no more for other series
  • Simplify class state management:
    • remove _configured and _reset, _alarmEnabled
    • add _timeSet

Tested on BluePill and Nucleo L476RG, with examples from STM32duino_RTC library

fixes #66

* call HAL_RTC_Init() only when needed to avoid losing hundreds
  of milliseconds on RTC counter
* remove useless check of _configured at the beginning of
  STM32RTC class methods
* Use flag "INITS" to detect whether RTC calendar is initialized
  (except for F1 which doesn't have this flag)
  This prevent the use of year 2000 which is the default hardware
  reset value and doesn't trigger INITS flag
* Use Backup registers only for F1, and no more for other series
* Simplify class state management:
  - remove _configured and _reset, _alarmEnabled
  - add _timeSet

fixes stm32duino#66

Signed-off-by: Alexandre Bourdiol <[email protected]>
@ABOSTM ABOSTM force-pushed the RTC_PREVENT_1S_LOSE branch from b2f6c10 to cda850c Compare June 3, 2022 13:31
@fpistm fpistm added the enhancement New feature or request label Jun 6, 2022
@fpistm fpistm added this to the 1.3.0 milestone Jun 6, 2022
@fpistm fpistm merged commit cfd98df into stm32duino:main Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

STM32F103C8T6 RTC losing about one second on each system reset.
2 participants