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

Kaspar Schleiser notifications at github.com
Wed Apr 7 10:17:35 CEST 2021


@kaspar030 commented on this pull request.



> +    }
+
+    i2c_release(dev->params.i2c_dev);
+
+    return res;
+}
+
+int _read_measurements(sgp30_t *dev, sgp30_data_t *data)
+{
+    uint8_t frame[6];
+
+    if (_rx_tx_data(dev, SGP30_CMD_MEASURE_AIR_QUALITY, frame, sizeof(frame),
+                    SGP30_DELAY_MEASURE_AIR_QUALITY, true)) {
+        return -EPROTO;
+    }
+    if (_crc8(frame, 2) != frame[2] || _crc8(frame + 3, 2) != frame[5]) {

I've seen this at least two times. maybe factor out a function that does the equivalent of `_crc8(buf, 2) == buf[2]`, then one using that for a full 6 byte frame (`_crc8_matches(frame) && _crc8_matches(frame + 3)`)?

-- 
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-629719826
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210407/9ac3f05c/attachment-0001.htm>


More information about the notifications mailing list