[riot-notifications] [RIOT-OS/RIOT] drivers: Add AD7746 capacitance sensor driver (#10919)

Peter Kietzmann notifications at github.com
Fri Feb 15 12:21:13 CET 2019


PeterKietzmann approved this pull request.

Besides the minor comment I'm fine with this PR. Tested with:
*tests/driver_ad7746*
*tests/saul*
*examples/default*

 Please address my comment and squash

> +#include "ad7746_params.h"
+#include "ad7746_internal.h"
+
+#include "periph/i2c.h"
+#include "periph/gpio.h"
+
+#define ENABLE_DEBUG (0)
+#include "debug.h"
+
+#include "xtimer.h"
+
+#define I2C (dev->params.i2c)
+#define ADDR (dev->params.addr)
+
+#define CONF_TEST_VALUE (1 << AD7746_CONFIGURATION_VTF1_BIT)
+

Spend a comment that states what this is (conversion time[ms] for for vt channel at different sampling rates)

> +        *value = _raw_to_capacitance(raw);
+    }
+
+    return res;
+}
+
+static int _read_voltage_temp(ad7746_t *dev, int *value, ad7746_vt_mode_t mode)
+{
+    int res;
+    uint32_t raw;
+
+    if (dev->params.vt_mode != mode) {
+        if (ad7746_set_vt_ch_mode(dev, mode)) {
+            return AD7746_NOI2C;
+        }
+        xtimer_usleep(_vt_sr_times[dev->params.vt_sample_rate] * US_PER_MS);

Spend a comment that we sleep for one conversion cycle and flush the first sample in order to get stable output. Maybe mention that we cribbed from the linux implementation.

-- 
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/10919#pullrequestreview-204191860
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190215/2fe4fa94/attachment.html>


More information about the notifications mailing list