[riot-notifications] [RIOT] periph/rtt: add macros for time to tick conversion (#3174)

Daniel Krebs notifications at github.com
Tue Jun 9 10:23:21 CEST 2015


> +         "per second for the current architecture."
> +#endif
> +
> +/**
> + * @brief       Convert microseconds to rtt ticks
> + * @param[in]   us number of microseconds
> + * @return      rtt ticks
> + */
> +#define RTT_US_TO_TICKS(us)     ((uint32_t)((uint64_t)(us) * RTT_FREQUENCY / 1000000UL))
> +
> +/**
> + * @brief       Convert milliseconds to rtt ticks
> + * @param[in]   ms number of milliseconds
> + * @return      rtt ticks
> + */
> +#define RTT_MS_TO_TICKS(ms)     ( RTT_US_TO_TICKS((ms) * 1000) )

Could you please provide an example? Calculation is done from left to right and the bigger the value before division, the more stable it is, isn't it? Please note that ` * 1000` is done inside macro argument

---
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/3174/files#r31991572
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20150609/970e19d9/attachment-0001.html>


More information about the notifications mailing list