Intro: Using the MPIDE Board-Defs
For those of you who don't know, board-defs are hardware specific files that help your development environment to program your board. They include short-cuts (like the ability to type PIN_LED1 instead of looking up LED1's pin each time) and juicy details about your board (like what pins are PWM enabled), but how do you find these board-defs?
Step 1: Findin Board-defs on Windows
Finding the board-defs on Windows is very simple.
Navigate to the MPIDE folder in your Program Files folder. Then open up "hardware". Inside you'll see three files, "arduino", "pic32", and "tools". If you wanted to work with an Arduino board, you'd open up "arduino", but since we're going to work with chipKIT boards, we open up "pic32".
Open up "variants" to see folders for all of the different chipKIT boards that you can program with MPIDE and open up the folder for yours (I opened up WF32).
Here you'll find a couple files, but you are interested in "Board_Defs.h".
Step 2: Finding Board-Defs on Mac
Finding board-defs on Mac is slightly more complicated because you can't find them in any of the Application Support files, because it turns out they're hidden inside the app itself.
Right click on the MPIDE app and select "Show Package Contents".
Now navigate to:
From here things should start looking familiar. You'll see three files: Arduino, pic32, and tools. Open up pic32, find your board's folder, and open up the "Board_Defs.h" file inside!
Step 3: Using the Board Defs
Now that you've got them, how do you use them? Let's start with something simple. Go into MPIDE and open up the "Blink" example.
Check out line 15:
digitalWrite(PIN_LED1, HIGH); // set the LED on
Do a search for "PIN_LED1" in the board-defs file* and you'll find the following line:
#define PIN_LED1 13
LED1 is connected to pin 13 on your board, so you could have addressed pin 13 when turning that LED on, but it's more intuitive and natural to substitute the name of the actual hardware you're using, and this short-cut doesn't just work for LEDs!
chipKIT boards have a mess of different signals on all their pins, including communication lines like SPI, I2C and UART, input and output compare pins, external interrupts, change notice pins, and analogue input pins. the board-defs files will list them for your specific board**. When you branch off from tutorials and start working on your own projects, you'll want to have access to these files to not only reference functions that you already know exist, but also find new ones that you didn't know were there!
*Note that I'm using a WF32 for this tutorial, so some board-defs may differ from your board.
**Some signals may not be supported by default. More advanced users may try enabling them by changing the board-defs, but be very careful when doing this!