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

Gunar Schorcht notifications at github.com
Fri Sep 6 18:44:44 CEST 2019


gschorcht commented on this pull request.



> +
+    DEBUG_DEV("mode=%u freq=%"PRIu32" res=%u", dev, mode, freq, res);
+
+    dev->params.mode = mode;
+    dev->params.freq = freq;
+    dev->params.res = res;
+
+    /* prescale can only be set while in sleep mode (powered off) */
+    if (dev->powered_on) {
+        pca9685_pwm_poweroff(dev);
+    }
+
+    /* prescale = round(clk / (PCA9685_RESOLUTION * freq)) - 1; */
+    float clk = (float)(dev->params.ext_freq ? dev->params.ext_freq
+                                             : PCA9685_OSC_FREQ);
+    float prescale = clk / PCA9685_RESOLUTION / freq;

Indeed, `uint32` sholud be enough for a maximum frequency of 1524 Hz and 12 bit resolution. I will change.

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


More information about the notifications mailing list