[riot-notifications] [RIOT-OS/RIOT] drivers: support for NXP PCA9685 I2C 16-channel, 12-bit PWM controller (#10556)

Gunar Schorcht notifications at github.com
Sat Sep 7 11:25:03 CEST 2019


gschorcht commented on this pull request.



> +}
+
+static int _update(const pca9685_t *dev, uint8_t reg, uint8_t mask, uint8_t data)
+{
+    uint8_t byte;
+    uint8_t shift = 0;
+
+    while (!((mask >> shift) & 0x01)) {
+        shift++;
+    }
+
+    /* read current register value */
+    EXEC_RET(_read(dev, reg, &byte, 1));
+
+    /* set masked bits to the given value  */
+    byte = data ? (byte | mask) : (byte & ~mask);

Although it is not used til now, `_update` function should allow to set multi-bit fields of a register. Thus, I had to change it as follows:
```diff
- byte = data ? (byte | mask) : (byte & ~mask);
+ _set_reg_bit(&byte, mask, bit);
```

-- 
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/10556#pullrequestreview-285164599
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190907/9f4ffa17/attachment.htm>


More information about the notifications mailing list