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

Marian Buschsieweke notifications at github.com
Tue Jan 8 11:17:48 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))
+#endif
+#ifndef LTC4150_PARAM_POL
+#define LTC4150_PARAM_POL             (GPIO_UNDEF)
+#endif
+#ifndef LTC4150_PARAM_SHUTDOWN
+#define LTC4150_PARAM_SHUTDOWN        (GPIO_PIN(0, 5))
+#endif
+#ifndef LTC4150_PARAM_PULSES
+#define LTC4150_PARAM_PULSES          (45700)

Regarding the `UL` suffix I also disagree. According to the [C99 standard](http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf) in section 6.4.4.1 a decimal constant without any suffix will have the smallest integer type of the following list: `int`, `long int`, `long long int`. Suffixes will only be needed in two cases:

1. The decimal number does fit into `unsigned long long int`, but not into `long long int`
2. The decimal number is used in expressions in which could overflow the automatically determent type of the number, e.g. `uint64_t foo = 42 << 32;`

(Explaining 2.: The 42 would fit into `int`, thus this would be the determent type. However, shifting any `int` by 32 bits to the left will result in `0`. Thus, `foo` will have the value `0` here. Using `uint64_t foo = 42ULL << 32` would have the expected result - so here the suffix would be needed for correct operation.)

Suffixes are really rarely needed. But they make reading the code harder. Adding them only were  actually harm could occur will be more readable in my opinion and raise awareness of the actual reason, why the suffixes are needed in some places.

-- 
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/9653#discussion_r245942097
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190108/1d7218d0/attachment.html>


More information about the notifications mailing list