[riot-notifications] [RIOT-OS/RIOT] driver/sgp30: initial import (#16222)

Kaspar Schleiser notifications at github.com
Wed Apr 7 10:24:57 CEST 2021


@kaspar030 commented on this pull request.



> +    *version = (frame[0] << 8) + frame[1];
+    return 0;
+}
+
+int sgp30_set_absolute_humidity(sgp30_t *dev, uint32_t a_humidity)
+{
+    /* max value is (255g/m3+255/256g/m3), or 255999 mg/m3*/
+    if (a_humidity > 256000) {
+        return -1;
+    }
+
+    /* scale down to g/m^3 */
+    uint16_t humidity_scaled =
+        (uint16_t)(((uint64_t)a_humidity * 256 * 16777) >> 24);
+
+    uint8_t frame[3];

here and below would benefit for a setter (`_set(uint8_t *buf, uint16_t val) { buf[0] = val >> 8; buf[1] = val & 0xFF; buf[3] = _crc8(...);}`.

-- 
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/16222#pullrequestreview-629728668
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210407/f55df430/attachment.htm>


More information about the notifications mailing list