[riot-notifications] [RIOT-OS/RIOT] sys/arduino: Added SPI interface (#12118)

Kees Bakker notifications at github.com
Sat Sep 7 22:54:12 CEST 2019


keestux commented on this pull request.



> +     * @brief   Transfer a single byte of data
+     * @param[in]   data        Byte to send
+     * @return  The received byte
+     */
+    uint8_t transfer(uint8_t data) {
+        transfer(&data, sizeof(data));
+        return data;
+    }
+
+    /**
+     * @brief   Transfer two bytes of data
+     * @param[in]       data        The two bytes to send
+     * @return  The received two bytes
+     */
+    uint16_t transfer16(uint16_t data) {
+        transfer(&data, sizeof(data));

This has a potential endiness problem. In this implementation you're using the native endianess of the selected CPU. In most cases that is Little Endian.

To be honest I don't know enough about SPI and its bit order. Is that bit order or byte order? Arduino's implementation does something with the byte ordering. And it seems to think that with MSBFIRST, that the MS byte comes first. Now, combine that with the fact that we currently `assert(bitOrder == MSBFIRST);` and we for sure have a problem on Little Endian machines.

-- 
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/12118#pullrequestreview-285187550
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190907/2228c3ec/attachment.htm>


More information about the notifications mailing list