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

benpicco notifications at github.com
Fri Sep 6 17:51:51 CEST 2019


benpicco commented on this pull request.



> +    return _read(dev, PCA9685_REG_MODE1, &byte, 1);
+}
+
+static int _init(pca9685_t *dev)
+{
+    /* set Auto-Increment flag */
+    EXEC_RET(_update(dev, PCA9685_REG_MODE1, PCA9685_MODE1_AI, 1));
+
+    /* switch off all channels */
+    EXEC_RET(_write_word(dev, PCA9685_REG_ALL_LED_OFF, PCA9685_ALL_LED_OFF));
+
+    /* set Auto-Increment flag */
+    uint8_t byte = 0;
+    _set_reg_bit(&byte, PCA9685_MODE2_OUTDRV, dev->params.inv);
+    _set_reg_bit(&byte, PCA9685_MODE2_OUTDRV, dev->params.out_drv);
+    _set_reg_bit(&byte, PCA9685_MODE2_OUTNE, dev->params.out_ne);

```suggestion
    _set_reg_bit(&byte, PCA9685_MODE2_OUTNE0, dev->params.out_ne & 0x1);
    _set_reg_bit(&byte, PCA9685_MODE2_OUTNE1, dev->params.out_ne & 0x2);
```

Maybe this is too hacky, but it world make the set function much simpler.
Another solution world be setting the already shifted bits.

(I can live with the while loop too, I'd just rather see if we can do without)

-- 
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-284951125
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190906/298fe28e/attachment.htm>


More information about the notifications mailing list