[riot-notifications] [RIOT-OS/RIOT] drivers/periph/ptp_clock (#15074)

Marian Buschsieweke notifications at github.com
Wed Nov 18 08:55:41 CET 2020

@maribu commented on this pull request.

> +/**
+ * @brief   Return the result of x / y, scientifically rounded
+ * @param   x       Number to divide
+ * @param   y       @p x should be divided by this
+ * @return  x/y, scientifically rounded
+ * @pre     Both @p x and @p y are compile time constant integers and the
+ *          expressions are evaluated without side-effects
+ */
+#define ROUNDED_DIV(x, y)   (((x) + ((y) / 2)) / (y))
+static const uint32_t ptpssir = STM32_PTPSSIR;
+static const uint32_t ptptsar = ROUNDED_DIV(NS_PER_SEC * (1ULL << 32), HCLK * STM32_PTPSSIR);
+void ptp_init(void)
+    stm32_eth_common_init();

> Are we sure ptp_init() is always called before stm32_eth_init()?

Yes, `periph_init()` is done before `auto_init()`, as `auto_init()` will initialize drivers that want to use peripheral buses and other stuff. And network devices might be external (thus using periph/spi), so they are currently in `auto_init()`. Only if peripheral network devices start getting special treatment in regard to their initialization, special care needs to be taken. But I don't think this is going to happen, as we generally dislike special treatments :-)

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20201117/69a04cd1/attachment-0001.htm>

More information about the notifications mailing list