Go Down

Topic: Determine device at build time? (Read 1 time) previous topic - next topic

Docedison

#15
Feb 18, 2013, 05:43 am Last Edit: Feb 18, 2013, 05:54 am by Docedison Reason: 1
Off Topic...
Comment on krupski's tag line...
Quote
Wouldn't it be easier to make assault and murder illegal rather than trying to have a law against every and any type of weapon?

What a concept.. Think We can Sell it? God didn't... "Thou Shalt Not Kill" is present in one form or another in all the mainstream religions... Or So I've Been Told.

Robert Khayyam Johnson Sr.

My deep personal belief is that any references to guns is best left in forums devoted to that purpose, they serve little purpose in this forum. IMNSHO.
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

westfw

Note that current trends in the Arduino core and etc are AWAY from checking for specific cpu types, and toward checking for specific features that you're using instead.
So instead of
Code: [Select]
#if defined(__AVR_ATmega1280__)
// m1280 has more timers to initialize
sbi(TCCR3B, CS31); // set timer 3 prescale factor to 64
sbi(TCCR3B, CS30);
sbi(TCCR3A, WGM30); // put timer 3 in 8-bit phase correct pwm mode
sbi(TCCR4B, CS41); // set timer 4 prescale factor to 64
sbi(TCCR4B, CS40);
sbi(TCCR4A, WGM40); // put timer 4 in 8-bit phase correct pw
#endif


One would check whether the individual timers instead:
Code: [Select]
#if defined(TCCR3B) && defined(CS31) && defined(WGM30)
sbi(TCCR3B, CS31);
sbi(TCCR3B, CS30);
sbi(TCCR3A, WGM30);
#endif

#if defined(TCCR4B) && defined(CS41) && defined(WGM40)
sbi(TCCR4B, CS41);
sbi(TCCR4B, CS40);
sbi(TCCR4A, WGM40);
#endif

this way, you can compile on essentially similar cpus without having to go and find all the places where the code checks for CPU type.  (m328 vs m328p, or m1280 vs m2560, for instance!)
Code: [Select]
#define RAMEND      0x4FF
Exactly!  It's much better to check for having more than a minimum amount of RAM, than to make the size of an array dependent on CPU type.
Some things are documented here: http://www.nongnu.org/avr-libc/user-manual/group__avr__io.html


Krupski


Off Topic...
Comment on krupski's tag line...
Quote
Wouldn't it be easier to make assault and murder illegal rather than trying to have a law against every and any type of weapon?

What a concept.. Think We can Sell it? God didn't... "Thou Shalt Not Kill" is present in one form or another in all the mainstream religions... Or So I've Been Told.

Robert Khayyam Johnson Sr.

My deep personal belief is that any references to guns is best left in forums devoted to that purpose, they serve little purpose in this forum. IMNSHO.


Who said anything about guns?
Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Go Up