[riot-notifications] [RIOT] xtimer: Add support for arbitrary frequency hardware timers (32768 Hz support) (#3990)

Kaspar Schleiser notifications at github.com
Wed Sep 30 11:37:55 CEST 2015


> + * (512 / 15625), which reduces the truncation caused by the integer widths */
> +
> +inline static uint32_t _xtimer_us_to_ticks(uint32_t us) {
> +    /* return (usec * 512) / 15625; */
> +    /*
> +     * Optimization to avoid division instructions or division libraries.
> +     * This code gives equivalent machine code on ARMv7-M (Cortex-M3, M4) as
> +     * generated by compiling the above code line.
> +     * at -O2 or higher with GCC 4.9. Cortex-M4 with optimization level -Os or
> +     * lower does not automatically perform this optimization.
> +     * Cortex-M0 (ARMv6-M) does not have hardware division and will insert a
> +     * call to the helper function __aeabi_uidiv which is quite complex and
> +     * slow, and uses an additional 200 bytes of ROM compared to the helper
> +     * function required for multiplying two 32 bit integers into a 64 bit result.
> +     */
> +    return ((uint64_t)(us << 9) * 0x431bde83ul) >> (12 + 32);

wait a minute, I might have something simpler...

---
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/3990/files#r40775278
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20150930/6e23b0dc/attachment.html>


More information about the notifications mailing list