What's the best way to test for the chip/device being compiled & maybe provide for alternate code for programs on the the teensy 3.0?
I saw some tests in https://github.com/triffid/Teacup_Firmware/blob/master/arduino.h
Here are some ARM-related #defines from a teensy3 compile:
If you've got verbose compiler output on in Arduino, compiling the code below for teensy 3.0 doesn't pick up on the _mk20dx128_h_ and shows the default warning.
I saw some tests in https://github.com/triffid/Teacup_Firmware/blob/master/arduino.h
Here are some ARM-related #defines from a teensy3 compile:
Code:
f$ /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I. -I/Applications/Arduino.app/Contents/Resources/Java/hardware/teensy/cores/teensy3 -dM -E main.cpp |egrep -i "ARM|mk|cortex"
#define ARM_DWT_CYCCNT *(volatile uint32_t *)0xE0001004
#define __ARMEL__ 1
#define __ARM_FEATURE_UNALIGNED 1
#define ARM_DEMCR *(volatile uint32_t *)0xE000EDFC
#define ARM_DWT_CTRL *(volatile uint32_t *)0xE0001000
#define __ARM_PCS 1
#define _EXPARM(name,proto) (* name) proto
#define IRQ_RTC_ALARM 28
#define __arm__ 1
#define ARM_DWT_CTRL_CYCCNTENA (1 << 0)
#define __ARM_ARCH_7EM__ 1
#define ARM_DEMCR_TRCENA (1 << 24)
#define __ARM_ARCH_EXT_IDIV__ 1
#define __ARM_EABI__ 1
#define _mk20dx128_h_
#define __ARM_FEATURE_DSP 1
If you've got verbose compiler output on in Arduino, compiling the code below for teensy 3.0 doesn't pick up on the _mk20dx128_h_ and shows the default warning.
Code:
/* LED Blink, Teensyduino Tutorial #1
http://www.pjrc.com/teensy/tutorial.html -- modified for compiler/processor ifdefs
This example code is in the public domain.
*/
#if defined __AVR__
# if defined (__AVR_AT90USB1286__) && defined (CORE_TEENSY) // teensy++ 2.0
# define HARDWIRED_LED 6
# endif
# if defined (__AVR_ATmega32U4__) && defined (CORE_TEENSY) // teensy 2.0
# define HARDWIRED_LED 11
# endif
#ifndef HARDWIRED_LED
# warning Assuming HARDWIRED_LED as LED_BUILTIN for most arduinos
# define HARDWIRED_LED LED_BUILTIN
# endif
# endif
#if defined (__ARMEL__)
# if (defined (_mk20dx128_h_) || defined (__MK20DX128__)) && defined (CORE_TEENSY) // Teensy 3.0
# define HARDWIRED_LED 13
# else
# warning Assuming HARDWIRED_LED as 13 for an __ARMEL__
# define HARDWIRED_LED 13
# endif
#endif
#ifndef HARDWIRED_LED
# error Unknown processor
#endif
#ifdef CORE_TEENSY
#warning CORE_TEENSY defined
#endif
const int ledPin = HARDWIRED_LED; // Teensy has LED on 11, Teensy++ on 6
// the setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output.
pinMode(ledPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the board has power
void loop() {
digitalWrite(ledPin, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(1000); // wait for a second
}
Last edited: