Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uint16_t divh1 = RTC->DIVH;
- uint16_t divl1 = RTC->DIVL;
- uint16_t cnth1 = RTC->CNTH;
- uint16_t cntl1 = RTC->CNTL;
- uint16_t divh2 = RTC->DIVH;
- uint16_t divl2 = RTC->DIVL;
- uint16_t cnth2 = RTC->CNTH;
- uint16_t cntl2 = RTC->CNTL;
- uint16_t divh, divl, cnth, cntl;
- /* cntl is decrementing */
- if(cntl1 < cntl2) {
- /* overflow occurred between reads of cntl, hence it
- * couldn't have occurred before the first read. */
- divh = divh1;
- divl = divl1;
- cnth = cnth1;
- cntl = cntl1;
- } else {
- /* no overflow between reads of cntl, hence the
- * values between the reads are correct */
- divh = divh2;
- divl = divl2;
- cnth = cnth2;
- cntl = cntl2;
- }
Add Comment
Please, Sign In to add comment