Mercurial > ~darius > hgwebdir.cgi > stm32temp
view rtc.h @ 81:d7002925c15d
Fix compilation on newer toolchain.
http://www.atollic.com/index.php/kb/1-kb_building/117-kb_error_in_strexb
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Mon, 02 Mar 2015 14:30:58 +1030 |
parents | 435c6330896c |
children |
line wrap: on
line source
/* RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1) */ #define RTC_PRESCALE 32768 /* usec = x * 1e6 / 32768 * However, 1e6 / 32768 = 30.5 which will result in a large error (max of 15807 usec), so we use * some extra bits to get more precision. We can scale up until 32768 * n is > 2^32. * This results in a maximum error of 1 usec. */ #define RTC_PS2USEC(x) ( \ (uint32_t)( \ (uint32_t)((1 << 9) * (1e6 / RTC_PRESCALE)) * (RTC_PRESCALE - (x))) >> 9)