imagelogin

Author Topic: Platform and Framework Identifiers in New Wiring?  (Read 3940 times)

0 Members and 1 Guest are viewing this topic.

rei_vilo

Platform and Framework Identifiers in New Wiring?
« on: June 02, 2012, 11:51:58 AM »
With the embedXcode 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, 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:
  • Arduino uses -DARDUINO=23 or -DARDUINO=100,
  • Wiring has -DWIRING=100
  • and MapleIDE uses -DMAPLE_IDE.
  • Energia for LaunchPad is considering -DENERGIA=6
  • and chipKIT sticks with -DARDUINO=23 -Danything_you_want -Danything=1.

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.
« Last Edit: June 02, 2012, 11:53:32 AM by rei_vilo »

bhagman

Re: Platform and Framework Identifiers in New Wiring?
« Reply #1 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.

rei_vilo

Re: Platform and Framework Identifiers in New Wiring?
« Reply #2 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?