Wiring Forum

For Developers => Wiring Framework Development => Topic started by: avenue33 on June 02, 2012, 11:51:58 AM

Title: Platform and Framework Identifiers in New Wiring?
Post by: avenue33 on June 02, 2012, 11:51:58 AM
With the embedXcode (http://embedxcode.weebly.com/) template, I'm dealing with 6 different Processing-based IDEs with Wiring-derived frameworks: Arduino 0023 and 1.0, Wiring, Maple IDE, chipKIT MPIDE and LaunchPad MSP430 Energia.

Needless to say none is fully compatible. So when I develop a library I want to use on different boards, as the Serial_LCD library suite (http://embeddedcomputing.weebly.com/), I need to test the MCU, ending in such inelegant code :-\ as:
Code: [Select]
// Core library
#if defined (__AVR_ATmega328P__) || defined(__AVR_ATmega2560__) // Arduino specific
#include "WProgram.h"
#elif defined(__32MX320F128H__) || defined(__32MX795F512L__) // chipKIT specific
#include "WProgram.h"
#elif defined(__AVR_ATmega644P__) // Wiring specific
#include "Wiring.h"
#elif defined(__MSP430G2452__) || defined(__MSP430G2553__) || defined(__MSP430G2231__) // LaunchPad specific
#include "Energia.h"
#elif defined(MCU_STM32F103RB) || defined(MCU_STM32F103ZE) || defined(MCU_STM32F103CB) || defined(MCU_STM32F103RE) // Maple specific
#include "WProgram.h"
#else // error
#error Platform not defined
#endif


As at today, some of the IDEs have specific definitions passed on as arguments to the compiler and linker:

The question is, in the new Wiring framework, is there a clean way for identifying the platform and its corresponding framework?

The main benefit is a more readable code, as:
Code: [Select]
// Core library
#if defined(WIRING) // Wiring specific
#include "Wiring.h"
#if defined(MPIDE) // chipKIT specific
#include "WProgram.h"
#elif defined(ENERGIA) // LaunchPad specific
#include "Energia.h"
#elif defined(MAPLE_IDE) // Maple specific
#include "WProgram.h"
#elif defined(ARDUINO) && (ARDUINO >= 100) // Arduino 1.0 specific
#include "Arduino.h"
#elif defined(ARDUINO) && (ARDUINO < 100) // Arduino 23 specific
#include "WProgram.h"
#else // error
#error Platform not defined
#endif

The test on ARDUINO comes last as some IDE may use two definitions.
Title: Re: Platform and Framework Identifiers in New Wiring?
Post by: bhagman on June 22, 2012, 12:06:25 PM
Ultimately, the Framework will have a single definition for the Framework version.

So, for example, Wiring Framework version 1.1 will have the preprocessor constant WIRING=110.

All IDEs supporting the Wiring Framework will have this definition.

We still are defining all of this for the Framework.
Title: Re: Platform and Framework Identifiers in New Wiring?
Post by: avenue33 on June 22, 2012, 01:27:15 PM
Thanks for the information.

How do you plan to identify the different platforms, AVR, PIC32, ARM, MSP?

Or is the MCU as __AVR_ATmega644P__ or __MSP430G2553__ planned to be the only identifier?