Merge branch 'KenWillmott-patch-1' of https://github.com/KenWillmott/Arduino_STM32 into KenWillmott-KenWillmott-patch-1

This commit is contained in:
Roger Clark 2018-04-01 16:27:26 +10:00
commit 9128a78265
1 changed files with 9 additions and 5 deletions

View File

@ -182,8 +182,10 @@ void rtc_set_count(uint32 value) {
rtc_wait_sync(); rtc_wait_sync();
rtc_wait_finished(); rtc_wait_finished();
rtc_enter_config_mode(); rtc_enter_config_mode();
RTC->regs->CNTH = (value >> 16) & 0xffff; do {
RTC->regs->CNTL = value & 0xffff; h = RTC->regs->CNTH & 0xffff;
l = RTC->regs->CNTL & 0xffff;
} while (h ^ (RTC->regs->CNTH & 0xffff));
rtc_exit_config_mode(); rtc_exit_config_mode();
rtc_wait_finished(); rtc_wait_finished();
} }
@ -211,8 +213,10 @@ uint32 rtc_get_divider() {
rtc_clear_sync(); rtc_clear_sync();
rtc_wait_sync(); rtc_wait_sync();
rtc_wait_finished(); rtc_wait_finished();
h = RTC->regs->DIVH & 0x000f; do {
l = RTC->regs->DIVL & 0xffff; h = RTC->regs->DIVH & 0x000f;
l = RTC->regs->DIVL & 0xffff;
} while (h ^ (RTC->regs->DIVH & 0x000f));
return (h << 16) | l; return (h << 16) | l;
} }
@ -229,4 +233,4 @@ void rtc_set_alarm(uint32 value) {
RTC->regs->ALRL = value & 0xffff; RTC->regs->ALRL = value & 0xffff;
rtc_exit_config_mode(); rtc_exit_config_mode();
rtc_wait_finished(); rtc_wait_finished();
} }