Help understanding pin selection...

I'm using the UIPEthernet library for an ENC28J60 chip (project is working), and was curious how the library knows which pins on my board to use. I'm using a Pololu A-Star 32U4 Mini SV, which is an Arduino compatible board.

I believe I found the file that defines which pins to use:

It looks like a bunch of if/else statements try to detect which constants are defined (or which pins are defined), and if not to define them on specific pins. I'm curious about these constants:

TARGET_LPC1114
TARGET_NUCLEO_F334R8
MK20DX128
MKL26Z64

And so on. I suspect these are constants that identify what particular Arduino board is being used - or perhaps the underlying chipset.

Mostly curious - though I would like to get a better sense of what this file is doing.

(I should mention - I'm using the pins labeled RXL (SS), SCK, MOSI, MISO on the A-Star, and was able to successfully communicate with the Arduino over ethernet.)

Thanks!

John

Did you see line 29 in that file? You are not programming an MBED device, so forget everything from line 30 to line 56. The other two values are for other non-Arduino boards.

If you are using a shield you would look at the documentation (or schematic) for the shield.

Most complex peripherals will use SPI (MOSI,MISO,SCK,SS) or I2C/TWI/Wire (SDA,SCL). On the UNO the SPI pins are 10-13 and the I2C pins are A4 and A5 (or the two pins they added in R3).

I realize my question didn't get to the heart of what I was asking:

Where do all the constants come from? Specifically:

TARGET_LPC1114
TARGET_NUCLEO_F334R8
MK20DX128
MKL26Z64

Are these defined by the Arduino IDE? Does each board mfg identify their board via the "Boards Manager"? I know with the A-Star I had to add the Pololu board specifically.

I have the board hooked up correctly and working, I just wanted a bit more info on how these constants get defined.

I assume you've done a file search. If you cant find references to those macros in any source file then they may be specified on the command line by the Arduino IDE. This is configured in the platform.txt file associated with your board. A quick way to determine if this is the case is to turn on Verbose output during compile in the File -> Preferences menu and copy-paste the output into your favorite text editor to search for the strings, probably in the form of -DTARGET_LPC1114, etc.

-Brian

ururk:
Where do all the constants come from? Are these defined by the Arduino IDE? Does each board mfg identify their board via the "Boards Manager"?

Yes. The manufacturer (or someone else) prepares some sort of Arduino IDE config file for the board, and that file is what you see in the boards manager. At a guess, that file contains a lot of stuff - libraries for the board, include files to be silently included into Arduino.h, and command-line flags and environment settings for the compiler and the uploader when compiling to the board you have selected.

Look in your IDE directory in Program Files or wherever, and find hardware/arduino/avr/boards.txt