[riot-notifications] [RIOT-OS/RIOT] Driver for AT24CXXX EEPROM (#11929)

benpicco notifications at github.com
Wed Jul 31 23:34:32 CEST 2019


benpicco commented on this pull request.



> +    DEBUG("_read::i2c_read_regs check: %d; polls: %d\n", check, polls);
+    return check < 0 ? check : (int)len;
+}
+
+static int _write(const at24cxxx_t *dev, uint32_t pos, const uint8_t *data,
+                  size_t len)
+{
+    int check = 0;
+    size_t wr = 0;
+    size_t chunk_len;
+
+    while (!check && (chunk_len = len - wr)) {
+        const uint8_t *chunk_data = data + wr;
+        size_t max_chunk_len =
+            (AT24CXXX_PAGE_SIZE - (pos % AT24CXXX_PAGE_SIZE));
+        chunk_len = chunk_len < max_chunk_len ? chunk_len : max_chunk_len;

how about
`chunk_len = min(len, AT24CXXX_PAGE_SIZE - (pos & (AT24CXXX_PAGE_SIZE - 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/11929#pullrequestreview-269295832
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190731/fb01b507/attachment-0001.htm>


More information about the notifications mailing list