barryjo:
Lets say that I am writing a program that uses interrupts. If I want to write the program for a variety of processors, I need to know what the processor is that I am compiling for.
That isn't necessarily always true. There are ways to use interrupts using Arduino that do not require knowing the specific processor.
In the Arduino IDE, under tools, you make a selection as to what processor you are using.
The IDE does not let you select a processor type, it merely lets you select a board type.
And while a given board does contain a particularly processor, the board type and the processor type are not the same thing.
When diving down really low, there can be reasons to know:
- board type
- processor type
- core
The 3 are not the same but depending on what is being done there can be needs for any of that information.
Where things can get really messy is that the variant files are allowed to map things like pins in any crazy way they want to. And the variant file is per board type.
So depending on what you are doing, just knowing the processor type may not be good enough.
In many cases there are low level Arduino macros in the variant file that can be used or at least help in avoiding having to write processor specific code.
If those macros are not good enough, things will quickly get complicated.
The main reason is that the IDE does not provide information about the core being used or the processor.
It only provides information about the board being used.
And the information available varies quite a bit between IDE versions.
So if you are writing processor specific code it is unwise to use defines like ARDUINO_AVR_UNO as designator for m328 as the UNO is only one of many boards that have that processor on it and defines like that only exist in the more recent IDEs.
I've done stuff like this in my openGLCD library, and it is a total bear to do especially when looking at other cores like the 1284 or the chipKit pic32 cores.
I would advise against it unless there is some compelling reason to do so - like no other way of handling it.
What specifically are you doing that needs to drive down to touching h/w registers within specific processors?
that cannot be done in some other more portable way?
i.e. there are ways to use interrupts without having to dive down and touch h/w registers.
--- bill