[riot-notifications] [RIOT-OS/RIOT] drivers/ltc4150: (Re-)implemented driver for the LTC4150 coulomb counter (#10755)

Marian Buschsieweke notifications at github.com
Wed Jan 16 13:14:25 CET 2019


maribu commented on this pull request.



> +     * @brief External pull on the /POL pin is present
+     */
+    LTC4150_POL_EXT_PULL_UP = 0x02,
+    /**
+     * @brief External pull on the /INT *and* the /POL pin is present
+     */
+    LTC4150_EXT_PULL_UP = LTC4150_INT_EXT_PULL_UP | LTC4150_POL_EXT_PULL_UP,
+};
+
+/**
+ * @brief Enumeration of directions in which the charge can be transferred
+ */
+typedef enum {
+    LTC4150_CHARGE,             /**< The battery is charged */
+    LTC4150_DISCHARGE,          /**< Charge is drawn from the battery */
+} ltc4150_dir_t;

> plus it saves 16 Bytes, when using `bool` instead of the `enum` ...

This is a good point. I personally consider enums more readable than `bool`, but if someone wants to use that driver and her/his ROM is overflown by only a couple of bytes, this user would clearly favor the `bool` over the `enum`.

Honestly, I am totally surprised that there is a difference in code size by using a two-value `enum` over a `bool`. I'll have to look into this to understand that.

@miri64, @MichelRottleuthner, @smlng:

Would 

``` C
typedef bool ltc4150_dir_t;

#define LTC4150_CHARGE      true
#define LTC4150_DISCHARGE   false
```

be a compromise? (Sure, with the `enum` gdb would be able to show `LTC4150_CHARGE` instead of `1`...)

-- 
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/10755#discussion_r248257797
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190116/736c153c/attachment.html>


More information about the notifications mailing list