andysworkshop / stm32plus

The C++ library for the STM32 F0, F100, F103, F107 and F4 microcontrollers
http://www.andybrown.me.uk
Other
745 stars 224 forks source link

RTC should optionally reset the backup domain #160

Closed dholth closed 8 years ago

dholth commented 8 years ago

I've got an F0 board with a battery backup on the RTC, so it would be convenient to have an RTC class that only resets the backup domain if it has not already been configured. In the STM32 example this is detected by reading a magic value from a backup register RTC_ReadBackupRegister(RTC_BKP_DR0) != BKP_VALUE (rather than a dedicated bit for this function that just detects if the calendar year is not 0...)

One strategy that I will try in my fork might be to have RtcBase check the backup register, add a flag on RtcBase, feature class resets or not based on flag. However as it is currently structured the magic number could not be a template argument? What if you want to reset the RTC again when the user sets the time just in case?

dholth commented 8 years ago

Thanks for merging my fork.