Leeds, UK
Offline
Edison Member
Karma: 38
Posts: 1028
Once the magic blue smoke is released, it won't go back in!
|
 |
« on: October 22, 2012, 12:55:18 pm » |
Could you tell me if there is a #define that identifies whether the board is a ARM/Due or an AVR/Uno/Mega/Leonard/etc? The best I could come up with it to just pick a random #define that is in the Arduino.h file for the Due, but not in the Arduino.h file for the atmega core. I stuck this at the top of my cpp file, which appears to work, but surely there is a more future proof method #ifdef WEAK #define ARM_CORTEX #endif
|
|
|
|
|
Logged
|
~Tom~
|
|
|
|
nr Bundaberg, Australia
Online
Tesla Member
Karma: 75
Posts: 6973
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #1 on: October 22, 2012, 01:11:21 pm » |
There's a _LIB_SAM_ define in chip.h, I don't know if that will be good enough for an ID.
______ Rob
|
|
|
|
|
Logged
|
|
|
|
|
Leeds, UK
Offline
Edison Member
Karma: 38
Posts: 1028
Once the magic blue smoke is released, it won't go back in!
|
 |
« Reply #2 on: October 22, 2012, 02:05:37 pm » |
Yup, it works. I can live with that.
|
|
|
|
|
Logged
|
~Tom~
|
|
|
|
Forum Administrator
Milano, Italy
Offline
Full Member
Karma: 19
Posts: 213
|
 |
« Reply #3 on: October 22, 2012, 04:53:46 pm » |
I see that gcc has the following built-in defines that I used into the SD library to distinguish between architectures: #if defined(__arm__)
// Arduino Due Board follows
#elif defined(__AVR__)
// Other AVR based Boards follows
#else
#error Architecture or board not supported.
#endif
|
|
|
|
|
Logged
|
C.
|
|
|
|
Leeds, UK
Offline
Edison Member
Karma: 38
Posts: 1028
Once the magic blue smoke is released, it won't go back in!
|
 |
« Reply #4 on: October 22, 2012, 06:04:13 pm » |
Even better as it is part of the compiler, not the core 
|
|
|
|
|
Logged
|
~Tom~
|
|
|
|
0
Offline
Sr. Member
Karma: 20
Posts: 426
Always making something...
|
 |
« Reply #5 on: October 23, 2012, 04:41:31 am » |
Using "#if defined(__arm__)" will also match to Teensy 3.0, Leaflabs Maple, and all other ARM-based boards that are created in the future.
Perhaps "#if defined(__SAM3X8E__)" would be a better check for Due?
|
|
|
|
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Online
Tesla Member
Karma: 75
Posts: 6973
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #6 on: October 23, 2012, 04:48:25 am » |
Looks like it, in sam\boards.txt
arduino_due_x_dbg.build.extra_flags=-D__SAM3X8E__ -mthumb -DUSB_PID={build.pid} -DUSB_VID={build.vid} -DUSBCON
______ Rob
|
|
|
|
|
Logged
|
|
|
|
|
Leeds, UK
Offline
Edison Member
Karma: 38
Posts: 1028
Once the magic blue smoke is released, it won't go back in!
|
 |
« Reply #7 on: October 23, 2012, 05:28:24 am » |
Using "#if defined(__arm__)" will also match to Teensy 3.0, Leaflabs Maple, and all other ARM-based boards that are created in the future.
Perhaps "#if defined(__SAM3X8E__)" would be a better check for Due?
For what I want it to mean that is not an issue, in fact it is a good thing. Basically it is a check to say, if it is an ARM processor, don't use the PROGMEM command, and default to using digitalWrite() rather than direct port writes.
|
|
|
|
|
Logged
|
~Tom~
|
|
|
|
0
Offline
Sr. Member
Karma: 20
Posts: 426
Always making something...
|
 |
« Reply #8 on: October 23, 2012, 07:51:15 am » |
Yes, of course, if your goal is to detect 32 bit ARM vs 8 bit AVR, then __arm__ and __AVR__ are the symbols you want.
|
|
|
|
|
Logged
|
|
|
|
|
Nice, France
Offline
Full Member
Karma: 10
Posts: 232
|
 |
« Reply #9 on: October 25, 2012, 02:42:31 am » |
Using "#if defined(__arm__)" will also match to Teensy 3.0, Leaflabs Maple, and all other ARM-based boards that are created in the future.
Perhaps "#if defined(__SAM3X8E__)" would be a better check for Due?
And what would be a suitable check for Teensy 3.0?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Sr. Member
Karma: 20
Posts: 426
Always making something...
|
 |
« Reply #10 on: October 25, 2012, 04:12:07 am » |
And what would be a suitable check for Teensy 3.0?
#if defined(__MK20DX128__)
|
|
|
|
|
Logged
|
|
|
|
|
North Queensland, Australia
Offline
Edison Member
Karma: 35
Posts: 1279
|
 |
« Reply #11 on: October 27, 2012, 02:15:09 am » |
Hi all, I'm updating my AtomicBlock library for the Due, the update contains versions for 'ARM' and the 'Cortex M3' variant. However I can't find any defines to conditionally decide which to use.
Is there a macro like _TARGET_ARCH_xx or similar?
|
|
|
|
|
Logged
|
|
|
|
|
Ayer, Massachusetts, USA
Offline
Edison Member
Karma: 28
Posts: 1147
|
 |
« Reply #12 on: October 27, 2012, 09:11:15 am » |
Hi all, I'm updating my AtomicBlock library for the Due, the update contains versions for 'ARM' and the 'Cortex M3' variant. However I can't find any defines to conditionally decide which to use.
Is there a macro like _TARGET_ARCH_xx or similar?
Looking at the current GCC sources, there doesn't appear to any single macro that completely identifies each chip, rather there are a bunch of feature macros defined (i.e. thumb/thumb2 instruction sets, whether it has DSP multiply, etc.). I believe the Arduino IDE defines things like __MK20DX128__ and __SAM3X8E__.
|
|
|
|
|
Logged
|
|
|
|
|
|