From f58ba3a64e94d5f6fa414f3e1bb4d7c1e2ddb46e Mon Sep 17 00:00:00 2001 From: Dave Johnson Date: Sat, 23 Sep 2017 21:25:28 -0700 Subject: [PATCH] Improve AVR arch detection Replace ARDUINO_ARCH_AVR with __AVR__ to better detect architecture for non-Arduino dev environments. Resolves compile failure in PIO for 8-bit Teensduino targets More info: https://forum.pjrc.com/threads/33234-Using-Teensyduino-Selecting-Teensy-3-2-3-1-board-has-incorrect-platform-define http://www.atmel.com/webdoc/avrlibcreferencemanual/using_tools_1using_avr_gcc_mach_opt.html --- Marlin/src/HAL/HAL.h | 4 ++-- Marlin/src/HAL/HAL_AVR/HAL_AVR.cpp | 4 ++-- Marlin/src/HAL/HAL_AVR/HAL_AVR.h | 2 +- Marlin/src/HAL/HAL_AVR/HAL_spi_AVR.cpp | 6 +++--- Marlin/src/HAL/HAL_AVR/MarlinSerial.cpp | 2 +- Marlin/src/HAL/HAL_AVR/persistent_store_impl.cpp | 4 ++-- Marlin/src/HAL/HAL_AVR/servo_AVR.cpp | 4 ++-- Marlin/src/HAL/HAL_AVR/watchdog_AVR.cpp | 4 ++-- Marlin/src/HAL/HAL_DUE/persistent_store_impl.cpp | 2 +- Marlin/src/HAL/HAL_SanityCheck.h | 2 +- Marlin/src/HAL/HAL_endstop_interrupts.h | 2 +- Marlin/src/HAL/HAL_pinsDebug.h | 2 +- Marlin/src/HAL/HAL_spi_pins.h | 2 +- Marlin/src/HAL/servo.h | 2 +- Marlin/src/HAL/servo_private.h | 2 +- Marlin/src/core/serial.h | 2 +- Marlin/src/inc/MarlinConfig.h | 2 +- Marlin/src/module/delta.cpp | 2 +- Marlin/src/module/delta.h | 2 +- Marlin/src/module/stepper.cpp | 4 ++-- Marlin/src/module/stepper.h | 2 +- Marlin/src/module/temperature.cpp | 2 +- 22 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Marlin/src/HAL/HAL.h b/Marlin/src/HAL/HAL.h index 897096ab16..37d5590a11 100644 --- a/Marlin/src/HAL/HAL.h +++ b/Marlin/src/HAL/HAL.h @@ -23,7 +23,7 @@ * * Supports platforms : * ARDUINO_ARCH_SAM : For Arduino Due and other boards based on Atmel SAM3X8E - * ARDUINO_ARCH_AVR : For all Atmel AVR boards + * __AVR__ : For all Atmel AVR boards */ #ifndef _HAL_H @@ -77,7 +77,7 @@ void spiRead(uint8_t* buf, uint16_t nbyte); /** Write token and then write from 512 byte buffer to SPI (for SD card) */ void spiSendBlock(uint8_t token, const uint8_t* buf); -#ifdef ARDUINO_ARCH_AVR +#ifdef __AVR__ #include "HAL_AVR/HAL_AVR.h" #elif defined(ARDUINO_ARCH_SAM) #define CPU_32_BIT diff --git a/Marlin/src/HAL/HAL_AVR/HAL_AVR.cpp b/Marlin/src/HAL/HAL_AVR/HAL_AVR.cpp index 92e8fdf498..28d55e9bba 100644 --- a/Marlin/src/HAL/HAL_AVR/HAL_AVR.cpp +++ b/Marlin/src/HAL/HAL_AVR/HAL_AVR.cpp @@ -23,11 +23,11 @@ /** * Description: HAL for AVR * - * For ARDUINO_ARCH_AVR + * For __AVR__ */ -#ifdef ARDUINO_ARCH_AVR +#ifdef __AVR__ // -------------------------------------------------------------------------- // Includes diff --git a/Marlin/src/HAL/HAL_AVR/HAL_AVR.h b/Marlin/src/HAL/HAL_AVR/HAL_AVR.h index 5a3d2011a9..cc0a2946ba 100644 --- a/Marlin/src/HAL/HAL_AVR/HAL_AVR.h +++ b/Marlin/src/HAL/HAL_AVR/HAL_AVR.h @@ -22,7 +22,7 @@ /** * Description: HAL for AVR * - * For ARDUINO_ARCH_AVR + * For __AVR__ */ diff --git a/Marlin/src/HAL/HAL_AVR/HAL_spi_AVR.cpp b/Marlin/src/HAL/HAL_AVR/HAL_spi_AVR.cpp index b0f0f45a44..bbe32caf44 100644 --- a/Marlin/src/HAL/HAL_AVR/HAL_spi_AVR.cpp +++ b/Marlin/src/HAL/HAL_AVR/HAL_spi_AVR.cpp @@ -28,10 +28,10 @@ /** * Description: HAL for AVR - SPI functions * - * For ARDUINO_ARCH_AVR + * For __AVR__ */ -#ifdef ARDUINO_ARCH_AVR +#ifdef __AVR__ // -------------------------------------------------------------------------- // Includes @@ -210,4 +210,4 @@ void spiBegin (void) { #endif // SOFTWARE_SPI -#endif // ARDUINO_ARCH_AVR +#endif // __AVR__ diff --git a/Marlin/src/HAL/HAL_AVR/MarlinSerial.cpp b/Marlin/src/HAL/HAL_AVR/MarlinSerial.cpp index 6c82379e1f..6e6430f77a 100644 --- a/Marlin/src/HAL/HAL_AVR/MarlinSerial.cpp +++ b/Marlin/src/HAL/HAL_AVR/MarlinSerial.cpp @@ -28,7 +28,7 @@ * Modified 28 September 2010 by Mark Sproul * Modified 14 February 2016 by Andreas Hardtung (added tx buffer) */ -#ifdef ARDUINO_ARCH_AVR +#ifdef __AVR__ #include "MarlinSerial.h" #include "../../Marlin.h" diff --git a/Marlin/src/HAL/HAL_AVR/persistent_store_impl.cpp b/Marlin/src/HAL/HAL_AVR/persistent_store_impl.cpp index ff26673fb4..b15945e7de 100644 --- a/Marlin/src/HAL/HAL_AVR/persistent_store_impl.cpp +++ b/Marlin/src/HAL/HAL_AVR/persistent_store_impl.cpp @@ -1,4 +1,4 @@ -#ifdef ARDUINO_ARCH_AVR +#ifdef __AVR__ #include "../persistent_store_api.h" @@ -52,4 +52,4 @@ void read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) { } #endif // EEPROM_SETTINGS -#endif // ARDUINO_ARCH_AVR +#endif // __AVR__ diff --git a/Marlin/src/HAL/HAL_AVR/servo_AVR.cpp b/Marlin/src/HAL/HAL_AVR/servo_AVR.cpp index f6d808fde9..6fc2a3fa7e 100644 --- a/Marlin/src/HAL/HAL_AVR/servo_AVR.cpp +++ b/Marlin/src/HAL/HAL_AVR/servo_AVR.cpp @@ -51,7 +51,7 @@ * */ -#ifdef ARDUINO_ARCH_AVR +#ifdef __AVR__ #include "../../inc/MarlinConfig.h" @@ -215,4 +215,4 @@ void finISR(timer16_Sequence_t timer) { #endif // HAS_SERVOS -#endif // ARDUINO_ARCH_AVR +#endif // __AVR__ diff --git a/Marlin/src/HAL/HAL_AVR/watchdog_AVR.cpp b/Marlin/src/HAL/HAL_AVR/watchdog_AVR.cpp index 0de550eb92..78dc943ead 100644 --- a/Marlin/src/HAL/HAL_AVR/watchdog_AVR.cpp +++ b/Marlin/src/HAL/HAL_AVR/watchdog_AVR.cpp @@ -20,7 +20,7 @@ * */ -#ifdef ARDUINO_ARCH_AVR +#ifdef __AVR__ #include "../../inc/MarlinConfig.h" @@ -58,4 +58,4 @@ void watchdog_init() { #endif // WATCHDOG_RESET_MANUAL #endif // USE_WATCHDOG -#endif // ARDUINO_ARCH_AVR +#endif // __AVR__ diff --git a/Marlin/src/HAL/HAL_DUE/persistent_store_impl.cpp b/Marlin/src/HAL/HAL_DUE/persistent_store_impl.cpp index 2a1caffb63..26a53ee111 100644 --- a/Marlin/src/HAL/HAL_DUE/persistent_store_impl.cpp +++ b/Marlin/src/HAL/HAL_DUE/persistent_store_impl.cpp @@ -52,4 +52,4 @@ void read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) { } #endif // EEPROM_SETTINGS -#endif // ARDUINO_ARCH_AVR +#endif // __AVR__ diff --git a/Marlin/src/HAL/HAL_SanityCheck.h b/Marlin/src/HAL/HAL_SanityCheck.h index 26a3e88489..2515e0b709 100644 --- a/Marlin/src/HAL/HAL_SanityCheck.h +++ b/Marlin/src/HAL/HAL_SanityCheck.h @@ -22,7 +22,7 @@ #ifndef HAL_SANITYCHECK_H -#ifdef ARDUINO_ARCH_AVR +#ifdef __AVR__ #include "HAL_AVR/SanityCheck_AVR_8_bit.h" #elif defined(ARDUINO_ARCH_SAM) #include "HAL_DUE/SanityCheck_Due.h" diff --git a/Marlin/src/HAL/HAL_endstop_interrupts.h b/Marlin/src/HAL/HAL_endstop_interrupts.h index eee6c5aca8..85d0106334 100644 --- a/Marlin/src/HAL/HAL_endstop_interrupts.h +++ b/Marlin/src/HAL/HAL_endstop_interrupts.h @@ -34,7 +34,7 @@ FORCE_INLINE void endstop_ISR_worker( void ) { // One ISR for all EXT-Interrupts void endstop_ISR(void) { endstop_ISR_worker(); } -#ifdef ARDUINO_ARCH_AVR +#ifdef __AVR__ #include "HAL_AVR/endstop_interrupts.h" diff --git a/Marlin/src/HAL/HAL_pinsDebug.h b/Marlin/src/HAL/HAL_pinsDebug.h index 0f28b34d5f..53d718f6f1 100644 --- a/Marlin/src/HAL/HAL_pinsDebug.h +++ b/Marlin/src/HAL/HAL_pinsDebug.h @@ -23,7 +23,7 @@ #ifndef HAL_PINSDEBUG_H #define HAL_PINSDEBUG_H -#ifdef ARDUINO_ARCH_AVR +#ifdef __AVR__ #include "HAL_AVR/pinsDebug_AVR_8_bit.h" #elif defined(ARDUINO_ARCH_SAM) #include "HAL_DUE/HAL_pinsDebug_Due.h" diff --git a/Marlin/src/HAL/HAL_spi_pins.h b/Marlin/src/HAL/HAL_spi_pins.h index a041f33a5d..fe220a1669 100644 --- a/Marlin/src/HAL/HAL_spi_pins.h +++ b/Marlin/src/HAL/HAL_spi_pins.h @@ -29,7 +29,7 @@ #elif defined(IS_32BIT_TEENSY) #include "HAL_TEENSY35_36/spi_pins.h" -#elif defined(ARDUINO_ARCH_AVR) +#elif defined(__AVR__) #include "HAL_AVR/spi_pins.h" #elif defined(TARGET_LPC1768) diff --git a/Marlin/src/HAL/servo.h b/Marlin/src/HAL/servo.h index ba22835034..879d18cc28 100644 --- a/Marlin/src/HAL/servo.h +++ b/Marlin/src/HAL/servo.h @@ -78,7 +78,7 @@ #else #include - #if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_SAM) + #if defined(__AVR__) || defined(ARDUINO_ARCH_SAM) // we're good to go #else #error "This library only supports boards with an AVR or SAM3X processor." diff --git a/Marlin/src/HAL/servo_private.h b/Marlin/src/HAL/servo_private.h index 9b85b9cf7c..7e8cd5f4f4 100644 --- a/Marlin/src/HAL/servo_private.h +++ b/Marlin/src/HAL/servo_private.h @@ -45,7 +45,7 @@ #include // Architecture specific include -#ifdef ARDUINO_ARCH_AVR +#ifdef __AVR__ #include "HAL_AVR/ServoTimers.h" #elif defined(ARDUINO_ARCH_SAM) #include "HAL_DUE/ServoTimers.h" diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index 81c35a75e1..8fff69d890 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -27,7 +27,7 @@ //todo: HAL: breaks encapsulation // For AVR only, define a serial interface based on configuration -#ifdef ARDUINO_ARCH_AVR +#ifdef __AVR__ #ifdef USBCON #include "HardwareSerial.h" #if ENABLED(BLUETOOTH) diff --git a/Marlin/src/inc/MarlinConfig.h b/Marlin/src/inc/MarlinConfig.h index 6c038274c6..ada346a651 100644 --- a/Marlin/src/inc/MarlinConfig.h +++ b/Marlin/src/inc/MarlinConfig.h @@ -31,7 +31,7 @@ #include "../../Configuration_adv.h" #include "../HAL/HAL.h" #include "../pins/pins.h" -#if defined(ARDUINO_ARCH_AVR) && !defined(USBCON) +#if defined(__AVR__) && !defined(USBCON) #define HardwareSerial_h // trick to disable the standard HWserial #endif #include "Conditionals_post.h" diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index 3ca0426fdb..c75def2902 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -88,7 +88,7 @@ void recalc_delta_settings(float radius, float diagonal_rod) { * (see above) */ -#if ENABLED(DELTA_FAST_SQRT) && defined(ARDUINO_ARCH_AVR) +#if ENABLED(DELTA_FAST_SQRT) && defined(__AVR__) /** * Fast inverse sqrt from Quake III Arena * See: https://en.wikipedia.org/wiki/Fast_inverse_square_root diff --git a/Marlin/src/module/delta.h b/Marlin/src/module/delta.h index 24fa5c3595..9b198b32a6 100644 --- a/Marlin/src/module/delta.h +++ b/Marlin/src/module/delta.h @@ -63,7 +63,7 @@ void recalc_delta_settings(float radius, float diagonal_rod); * (see above) */ -#if ENABLED(DELTA_FAST_SQRT) && defined(ARDUINO_ARCH_AVR) +#if ENABLED(DELTA_FAST_SQRT) && defined(__AVR__) /** * Fast inverse sqrt from Quake III Arena * See: https://en.wikipedia.org/wiki/Fast_inverse_square_root diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 74dffe732c..7cfc0f630d 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -46,7 +46,7 @@ #include "stepper.h" -#ifdef ARDUINO_ARCH_AVR +#ifdef __AVR__ #include "speed_lookuptable.h" #endif @@ -1139,7 +1139,7 @@ void Stepper::init() { E_AXIS_INIT(4); #endif - #ifdef ARDUINO_ARCH_AVR + #ifdef __AVR__ // waveform generation = 0100 = CTC SET_WGM(1, CTC_OCRnA); diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index 81c8f04f9b..01c979b567 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -45,7 +45,7 @@ #include "stepper_indirection.h" -#ifdef ARDUINO_ARCH_AVR +#ifdef __AVR__ #include "speed_lookuptable.h" #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 97f5824613..5aed0302aa 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1081,7 +1081,7 @@ void Temperature::init() { #endif // todo: HAL: fix abstraction - #ifdef ARDUINO_ARCH_AVR + #ifdef __AVR__ // Use timer0 for temperature measurement // Interleave temperature interrupt with millies interrupt OCR0B = 128;