[riot-notifications] [RIOT-OS/RIOT] drivers/hm3301: initial commit (#16333)

Alexandre Abadie notifications at github.com
Sun May 30 10:17:12 CEST 2021


@aabadie commented on this pull request.



> +        .nc_pm_0p5  = (buf[18] << 8) | buf[19],
+        .nc_pm_1    = (buf[20] << 8) | buf[21],
+        .nc_pm_2p5  = (buf[22] << 8) | buf[23],
+        .nc_pm_5    = (buf[24] << 8) | buf[25],
+        .nc_pm_10   = (buf[26] << 8) | buf[27],
+    };
+    memcpy(data, &tmp, sizeof(hm3301_data_t));
+
+    return 0;
+}
+
+void hm3301_reset(hm3301_t *dev)
+{
+    if (gpio_is_valid(dev->params.reset_pin)) {
+        gpio_clear(dev->params.reset_pin);
+        for (uint32_t i = 0; i < 10 * (CLOCK_CORECLOCK / US_PER_SEC) ; i++) {

Using `CLOCK_CORECLOCK` outside of cpu/board specific code won't work with FE310 based boards when HFROSC is used: in this case the clock speed is computed at runtime and this constant is not defined:

https://github.com/RIOT-OS/RIOT/blob/3d18f1ad672ac5eeab1f2a25b14a2aece0eb7e58/cpu/fe310/clock.c#L97-L112

This is why I thing we should not rely on a constant to get the clock speed but rather on an inline function provided by CPU implementations that would return it if possible or a computed value if not.

This was one of the indirect goals I had when I started to work on #14975.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16333#pullrequestreview-671803778
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210530/0eb30345/attachment.htm>


More information about the notifications mailing list