[riot-notifications] [RIOT-OS/RIOT] drivers: Add driver for the LTC4150 coulomb counter (#9653)

Marian Buschsieweke notifications at github.com
Tue Jan 8 11:00:45 CET 2019

maribu commented on this pull request.

> +
+ * @name    Set default configuration parameters for the LTC4150
+ * @{
+ */
+#ifndef LTC4150_PARAM_INT
+#define LTC4150_PARAM_INT             (GPIO_PIN(0, 4))
+#ifndef LTC4150_PARAM_POL
+#define LTC4150_PARAM_POL             (GPIO_UNDEF)
+#define LTC4150_PARAM_SHUTDOWN        (GPIO_PIN(0, 5))
+#ifndef LTC4150_PARAM_PULSES
+#define LTC4150_PARAM_PULSES          (45700)

I do not agree on the parentheses remarks. In my opinion there should be a reasonable rule to where to add them. A reasonable rule to could be one of the following to me:

1. add enclosing parentheses in every preprocessor macro, just to be safe
2. add enclosing parentheses  when order of precedence bugs can be introduced

A bug could be introduced e.g. in:

``` c
#define FOO 3 + 4

int bar = 2 * FOO; /* (2 * 3) + 4 not 2 * (3 + 4) */

But a precedence bug cannot be introduced by an integer constant. So unless adding enclosing parentheses everywhere, no parentheses are needed here. But if enclosing parentheses would be needed everywhere, they should also be placed around `GPIO_PIN(0, 4)`.

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190108/44e3bc77/attachment.html>

More information about the notifications mailing list