Ethernet - source for "writeMR"

Hi,
I am trying to get started with using Arduino Ethernet and I am examining the library source code to get an understanding of how things are done.
I've looked through the file "...\Arduino\libraries\Ethernet\src\utilty\w5100.cpp" to see how to read/write the WizNet chip and many of the functions call routines named "writeMR" and "readMR" but I just can't see where those two routines are defined. I can guess that these are routines to write and read the MODE REGISTER but I would like to confirm the details of just how this is done...

Can anyone help point me in the right direction?
Many thanks
PhilipJ

those are functions generated by the preprocessor in w5100.h

#define __GP_REGISTER8(name, address)             \
  static inline void write##name(uint8_t _data) { \
    write(address, _data);                        \
  }                                               \
  static inline uint8_t read##name() {            \
    return read(address);                         \
  }
  __GP_REGISTER8 (MR,     0x0000);    // Mode
  __GP_REGISTER_N(GAR,    0x0001, 4); // Gateway IP address
  __GP_REGISTER_N(SUBR,   0x0005, 4); // Subnet mask address

Hi Juraj,
thanks, that's a great help :slight_smile:
I've spent most of my life programming 'C' but there are features like this that I hardly ever use and so they catch me out when I do a global search for something and can't find it.

Kind regards
PhilipJ

a proper IDE helps. I use Eclipse Sloeber

Hi, sorry to bother you again but you might know the answer to this question also:
I am following through the code of DhcpAddressPrinter.ino to try and understand how DHCP works. One of the first things it does is to call Ethernet.begin(mac) but when I look in the source for Ethernet.cpp there are a number of EthernetClass::begin() functions defined but none with only one parameter. I understand about overloaded functions and how the compiler chooses the correct one according to the passed parameters but how does it work in this case for only the one parameter? I can guess that somewhere there is a stub that adds a 2nd parameter (IP address) and calls the begin() function with two params but I'd like to see it.
Kind regards
PhilipJ

in Ethernet.h

Thanks, I think I've got it (sorry but my knowledge of C++ is limited as I've always programmed embedded CPU is 'C').
The function is defined in the class with the two params "unsigned long timeout = 60000, unsigned long responseTimeout = 4000" given default values so I'm guessing they do not need to be included when the function is called? but can be overridden if different values are required.
Sorry to be a trouble!
Kind regards
PhilipJ

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.