Project

General

Profile

EtherCard for 32-bit targets

Added by PekkaNikander almost 6 years ago

I am working with a new 32-bit Cortex-M0 based Arduino compatible board, using the STM32F0discovery board while still waiting for the actual boards. I have already the bases of the Arduino IDE working for the STM32F0discovery, and now I’d like to get EtherCard and ENC28J60 support working.

However, when trying to compile the current EtherCard from github/jcw, the compile fails miserably. The main issue is that in a 32-bit environment the “word” data type is no longer 16 but 32 bits. As a consequence of this, the method signatures in the class declarations and in the actual method implementations do not match. Of course, there are also other HW-dependent issues such as accessing the eeprom etc, but those are relatively easy to handle with suitable ifdefs.

So, my main question is what to do about the method signatures and the “word” (and “byte”) data types. Should I convert all the class declarations to use “word” (and “byte”) and change the code to support 32-bit words? Or should I change all the method implementations to use uint16_t (and uint8_t), and stick with the 16-bit code. As far as I can see, the main drawback of the latter approach is that in Cortex-M series handling 16-bit variables is clearly less efficient than using 32-bit variables, in most contexts.

Furthermore, I have to confess that I don’t fully understand the existing Stash design. I do understand its main idea of storing data into the ENC28J60 memory. But the code seems to rely on the word size at places, and I don’t (yet) fully understand what’s going on there.

Hence, any advice on how to handle the “word” vs. uint16_t/uint32_t issue currently present in the code?

—Pekka Nikander

PS. In the case anyone is interested in this, an early (and hacky) version of the SMT32F0 discovery code is available at https://github.com/Ell-i/Arduino The code is very ugly at the moment; please bear with me, I started with the Arduino IDE just two weeks ago. But I have already a plan how to clean up the code once I have a little bit more functionality working.