if (high1 != high2)
{ /* In this case the counter roll over during reading of CNTL and CNTH registers,
read again CNTL register then return the counter value */
return (((uint32_t) high2 << 16 ) | RTC->CNTL);
}
else
{ /* No counter roll over during reading of CNTL and CNTH registers, counter
value is equal to first value of CNTL and CNTH */
return (((uint32_t) high1 << 16 ) | low);
}
}
你没有回答我的问题
回答完了呀
我问这个函数的功能。RTC_GetCounter()
返回计数值
/**
* @brief Gets the RTC counter value.
* @param None
* @retval RTC counter value.
*/
uint32_t RTC_GetCounter(void)
{
uint16_t high1 = 0, high2 = 0, low = 0;
high1 = RTC->CNTH;
low = RTC->CNTL;
high2 = RTC->CNTH;
if (high1 != high2)
{ /* In this case the counter roll over during reading of CNTL and CNTH registers,
read again CNTL register then return the counter value */
return (((uint32_t) high2 << 16 ) | RTC->CNTL);
}
else
{ /* No counter roll over during reading of CNTL and CNTH registers, counter
value is equal to first value of CNTL and CNTH */
return (((uint32_t) high1 << 16 ) | low);
}
}
一周热门 更多>