|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
-
-
- #include "imxrt.h"
- #include "debug/printf.h"
-
-
- unsigned long rtc_get(void)
- {
- uint32_t hi1 = SNVS_HPRTCMR;
- uint32_t lo1 = SNVS_HPRTCLR;
- while (1) {
- uint32_t hi2 = SNVS_HPRTCMR;
- uint32_t lo2 = SNVS_HPRTCLR;
- if (lo1 == lo2 && hi1 == hi2) {
- return (hi2 << 17) | (lo2 >> 15);
- }
- hi1 = hi2;
- lo1 = lo2;
- }
- }
-
- void rtc_set(unsigned long t)
- {
- SNVS_HPCR &= ~SNVS_HPCR_RTC_EN;
- while (SNVS_HPCR & SNVS_HPCR_RTC_EN) ;
- SNVS_HPRTCLR = t << 15;
- SNVS_HPRTCMR = t >> 17;
- SNVS_HPCR |= SNVS_HPCR_RTC_EN;
- }
-
- void rtc_compensate(int adjust)
- {
- }
-
|