From e85eca2630db50574f3829aa9d58237d7562d38f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 2 Aug 2019 07:22:07 -0500 Subject: [PATCH] HAL cleanup, Teensy 3.1 platform --- .travis.yml | 1 + Marlin/Configuration.h | 1 - .../src/HAL/HAL_DUE/EepromEmulation_Due.cpp | 2 +- Marlin/src/HAL/HAL_TEENSY31_32/HAL.h | 8 +- .../HAL_TEENSY31_32/persistent_store_impl.cpp | 14 +-- .../HAL_TEENSY35_36/persistent_store_impl.cpp | 50 -------- Marlin/src/HAL/HAL_TEENSY35_36/pinsDebug.h | 5 +- .../shared/{I2cEeprom.cpp => eeprom_i2c.cpp} | 0 .../shared/{SpiEeprom.cpp => eeprom_spi.cpp} | 0 Marlin/src/pins/stm32/pins_JGAURORA_A5S_A1.h | 14 +-- buildroot/share/tests/teensy31-tests | 116 ++++++++++++++++++ platformio.ini | 13 ++ 12 files changed, 146 insertions(+), 78 deletions(-) delete mode 100644 Marlin/src/HAL/HAL_TEENSY35_36/persistent_store_impl.cpp rename Marlin/src/HAL/shared/{I2cEeprom.cpp => eeprom_i2c.cpp} (100%) rename Marlin/src/HAL/shared/{SpiEeprom.cpp => eeprom_spi.cpp} (100%) create mode 100755 buildroot/share/tests/teensy31-tests diff --git a/.travis.yml b/.travis.yml index ad11d95e5..18f6e22b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ env: - TEST_PLATFORM="LPC1768" - TEST_PLATFORM="LPC1769" - TEST_PLATFORM="STM32F1" + - TEST_PLATFORM="teensy31" - TEST_PLATFORM="teensy35" - TEST_PLATFORM="linux_native" - TEST_PLATFORM="esp32" diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index de74e057f..676d8bce6 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -461,7 +461,6 @@ #define PID_MAX BANG_MAX // Limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current #define PID_K1 0.95 // Smoothing factor within any PID loop #if ENABLED(PIDTEMP) - //#define MIN_POWER 0 //#define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM) //#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM) //#define PID_DEBUG // Sends debug data to the serial port. diff --git a/Marlin/src/HAL/HAL_DUE/EepromEmulation_Due.cpp b/Marlin/src/HAL/HAL_DUE/EepromEmulation_Due.cpp index 73421c3a3..231e4cc04 100644 --- a/Marlin/src/HAL/HAL_DUE/EepromEmulation_Due.cpp +++ b/Marlin/src/HAL/HAL_DUE/EepromEmulation_Due.cpp @@ -31,12 +31,12 @@ #ifdef ARDUINO_ARCH_SAM -#include "../shared/persistent_store_api.h" #include "../../inc/MarlinConfig.h" #if ENABLED(EEPROM_SETTINGS) && NONE(I2C_EEPROM, SPI_EEPROM) #include "../shared/Marduino.h" +#include "../shared/persistent_store_api.h" #define EEPROMSize 4096 #define PagesPerGroup 128 diff --git a/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h b/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h index 0dbfa284e..18e53a33e 100644 --- a/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h @@ -19,19 +19,17 @@ * along with this program. If not, see . * */ +#pragma once /** * Description: HAL for Teensy 3.5 and Teensy 3.6 */ -#pragma once - #define CPU_32_BIT #include "../shared/Marduino.h" - -#include "../math_32bit.h" -#include "../HAL_SPI.h" +#include "../shared/math_32bit.h" +#include "../shared/HAL_SPI.h" #include "fastio_Teensy.h" #include "watchdog_Teensy.h" diff --git a/Marlin/src/HAL/HAL_TEENSY31_32/persistent_store_impl.cpp b/Marlin/src/HAL/HAL_TEENSY31_32/persistent_store_impl.cpp index 8622c947f..2a33af66c 100644 --- a/Marlin/src/HAL/HAL_TEENSY31_32/persistent_store_impl.cpp +++ b/Marlin/src/HAL/HAL_TEENSY31_32/persistent_store_impl.cpp @@ -24,13 +24,10 @@ #include "../shared/persistent_store_api.h" -namespace HAL { -namespace PersistentStore { +bool PersistentStore::access_start() { return true; } +bool PersistentStore::access_finish() { return true; } -bool access_start() { return true; } -bool access_finish() { return true; } - -bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) { +bool PersistentStore::write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) { while (size--) { uint8_t * const p = (uint8_t * const)pos; uint8_t v = *value; @@ -50,7 +47,7 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) { return false; } -bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) { +bool PersistentStore::read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) { do { uint8_t c = eeprom_read_byte((uint8_t*)pos); if (writing) *value = c; @@ -61,8 +58,5 @@ bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const boo return false; } -} // PersistentStore -} // HAL - #endif // EEPROM_SETTINGS #endif // __MK20DX256__ diff --git a/Marlin/src/HAL/HAL_TEENSY35_36/persistent_store_impl.cpp b/Marlin/src/HAL/HAL_TEENSY35_36/persistent_store_impl.cpp deleted file mode 100644 index 29b4653b3..000000000 --- a/Marlin/src/HAL/HAL_TEENSY35_36/persistent_store_impl.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#if defined(__MK64FX512__) || defined(__MK66FX1M0__) - -#include "../../inc/MarlinConfig.h" - -#if ENABLED(EEPROM_SETTINGS) - -#include "../shared/persistent_store_api.h" - -namespace HAL { -namespace PersistentStore { - -bool access_start() { return true; } -bool access_finish() { return true; } - -bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) { - while (size--) { - uint8_t * const p = (uint8_t * const)pos; - uint8_t v = *value; - // EEPROM has only ~100,000 write cycles, - // so only write bytes that have changed! - if (v != eeprom_read_byte(p)) { - eeprom_write_byte(p, v); - if (eeprom_read_byte(p) != v) { - SERIAL_ECHO_MSG(MSG_ERR_EEPROM_WRITE); - return true; - } - } - crc16(crc, &v, 1); - pos++; - value++; - }; - return false; -} - -bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) { - do { - uint8_t c = eeprom_read_byte((uint8_t*)pos); - if (writing) *value = c; - crc16(crc, &c, 1); - pos++; - value++; - } while (--size); - return false; -} - -} // PersistentStore -} // HAL - -#endif // EEPROM_SETTINGS -#endif // __MK64FX512__ || __MK66FX1M0__ diff --git a/Marlin/src/HAL/HAL_TEENSY35_36/pinsDebug.h b/Marlin/src/HAL/HAL_TEENSY35_36/pinsDebug.h index e6dcb2996..db750cf6e 100644 --- a/Marlin/src/HAL/HAL_TEENSY35_36/pinsDebug.h +++ b/Marlin/src/HAL/HAL_TEENSY35_36/pinsDebug.h @@ -16,8 +16,7 @@ * along with this program. If not, see . * */ - -#ifndef HAL_PINSDEBUG_TEENSY_H +#pragma once #define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS #define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin @@ -103,5 +102,3 @@ bool HAL_pwm_status(int8_t pin) { } static void HAL_pwm_details(uint8_t pin) { /* TODO */ } - -#endif diff --git a/Marlin/src/HAL/shared/I2cEeprom.cpp b/Marlin/src/HAL/shared/eeprom_i2c.cpp similarity index 100% rename from Marlin/src/HAL/shared/I2cEeprom.cpp rename to Marlin/src/HAL/shared/eeprom_i2c.cpp diff --git a/Marlin/src/HAL/shared/SpiEeprom.cpp b/Marlin/src/HAL/shared/eeprom_spi.cpp similarity index 100% rename from Marlin/src/HAL/shared/SpiEeprom.cpp rename to Marlin/src/HAL/shared/eeprom_spi.cpp diff --git a/Marlin/src/pins/stm32/pins_JGAURORA_A5S_A1.h b/Marlin/src/pins/stm32/pins_JGAURORA_A5S_A1.h index 6bc993845..77730bc41 100644 --- a/Marlin/src/pins/stm32/pins_JGAURORA_A5S_A1.h +++ b/Marlin/src/pins/stm32/pins_JGAURORA_A5S_A1.h @@ -39,13 +39,13 @@ // #define MCU_STM32F103ZE // not yet required // Enable EEPROM Emulation for this board, so that we don't overwrite factory data -// #define I2C_EEPROM // AT24C64 -// #define E2END 0x7FFF // 64KB -// #define FLASH_EEPROM_EMULATION 1 -// #define E2END 0xFFF // 4KB -// #define E2END uint32(EEPROM_START_ADDRESS + (EEPROM_PAGE_SIZE * 2) - 1) -// #define EEPROM_CHITCHAT -// #define DEBUG_EEPROM_READWRITE +//#define I2C_EEPROM // AT24C64 +//#define E2END 0x7FFF // 64KB +//#define FLASH_EEPROM_EMULATION +//#define E2END 0xFFF // 4KB +//#define E2END uint32(EEPROM_START_ADDRESS + (EEPROM_PAGE_SIZE * 2) - 1) +//#define EEPROM_CHITCHAT +//#define DEBUG_EEPROM_READWRITE // // Limit Switches diff --git a/buildroot/share/tests/teensy31-tests b/buildroot/share/tests/teensy31-tests new file mode 100755 index 000000000..149308cb6 --- /dev/null +++ b/buildroot/share/tests/teensy31-tests @@ -0,0 +1,116 @@ +#!/usr/bin/env bash +# +# Build tests for Teensy 3.1/3.2 (ARM Cortex-M4) +# + +# exit on first failure +set -e + +backup_ramps + +restore_configs +opt_set MOTHERBOARD BOARD_TEENSY31_32 +exec_test $1 $2 "Teensy3.1 with default config" + +# +# Test as many features together as possible +# +restore_configs +opt_set MOTHERBOARD BOARD_TEENSY31_32 +opt_set EXTRUDERS 2 +opt_set TEMP_SENSOR_0 1 +opt_set TEMP_SENSOR_1 5 +opt_set TEMP_SENSOR_BED 1 +opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LCD_INFO_MENU SDSUPPORT SDCARD_SORT_ALPHA \ + FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY CALIBRATION_GCODE BAUD_RATE_GCODE \ + FIX_MOUNTED_PROBE Z_SAFE_HOMING AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ + BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \ + PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT M100_FREE_MEMORY_WATCHER \ + ADVANCED_PAUSE_FEATURE ARC_SUPPORT BEZIER_CURVE_SUPPORT EXPERIMENTAL_I2CBUS EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES PARK_HEAD_ON_PAUSE \ + PHOTO_GCODE PHOTO_POSITION PHOTO_SWITCH_POSITION PHOTO_SWITCH_MS PHOTO_DELAY_MS PHOTO_RETRACT_MM \ + HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT +opt_set I2C_SLAVE_ADDRESS 63 +opt_set GRID_MAX_POINTS_X 16 +exec_test $1 $2 "Teensy3.1 with many features" + +# +# Test a Sled Z Probe with Linear leveling +# +restore_configs +opt_set MOTHERBOARD BOARD_TEENSY31_32 +opt_enable EEPROM_SETTINGS Z_PROBE_SLED AUTO_BED_LEVELING_LINEAR DEBUG_LEVELING_FEATURE GCODE_MACROS +exec_test $1 $2 "Sled Z Probe with Linear leveling" + +# +# Test a Servo Probe +# +# restore_configs +# opt_set MOTHERBOARD BOARD_TEENSY31_32 +# opt_enable Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE \ +# AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE EEPROM_SETTINGS +# opt_set NUM_SERVOS 1 +# exec_test $1 $2 "Servo Probe" +# +# ...with AUTO_BED_LEVELING_3POINT, DEBUG_LEVELING_FEATURE, EEPROM_SETTINGS, EEPROM_CHITCHAT, EXTENDED_CAPABILITIES_REPORT, and AUTO_REPORT_TEMPERATURES +# +# opt_enable AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE EEPROM_SETTINGS \ +# EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES +# exec_test $1 $2 "...with AUTO_BED_LEVELING_3POINT, DEBUG_LEVELING_FEATURE, EEPROM_SETTINGS, EEPROM_CHITCHAT, EXTENDED_CAPABILITIES_REPORT, and AUTO_REPORT_TEMPERATURES" + +# +# Test MAGNETIC_PARKING_EXTRUDER with LCD +# +restore_configs +opt_set MOTHERBOARD BOARD_TEENSY31_32 +opt_set EXTRUDERS 2 +opt_set TEMP_SENSOR_1 1 +opt_enable MAGNETIC_PARKING_EXTRUDER ULTIMAKERCONTROLLER +exec_test $1 $2 "MAGNETIC_PARKING_EXTRUDER with LCD" + +# +# Mixing Extruder +# +restore_configs +opt_set MOTHERBOARD BOARD_TEENSY31_32 +opt_enable MIXING_EXTRUDER DIRECT_MIXING_IN_G1 GRADIENT_MIX GRADIENT_VTOOL REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER +opt_set MIXING_STEPPERS 2 +exec_test $1 $2 "Mixing Extruder" + +# +# Test SWITCHING_EXTRUDER +# +# restore_configs +# opt_set MOTHERBOARD BOARD_TEENSY31_32 +# opt_set EXTRUDERS 2 +# opt_set NUM_SERVOS 1 +# opt_enable SWITCHING_EXTRUDER ULTIMAKERCONTROLLER +# exec_test $1 $2 "SWITCHING_EXTRUDER" +# +# Enable COREXY +# +restore_configs +opt_set MOTHERBOARD BOARD_TEENSY31_32 +opt_enable COREXY +exec_test $1 $2 "COREXY" + +# +# Enable COREXZ +# +restore_configs +opt_set MOTHERBOARD BOARD_TEENSY31_32 +opt_enable COREXZ +exec_test $1 $2 "COREXZ" + +# +# Enable Z_DUAL_STEPPER_DRIVERS, Z_DUAL_ENDSTOPS +# +restore_configs +opt_set MOTHERBOARD BOARD_TEENSY31_32 +opt_enable Z_DUAL_STEPPER_DRIVERS Z_DUAL_ENDSTOPS +pins_set ramps/RAMPS X_MAX_PIN -1 +opt_add Z2_MAX_PIN 2 +opt_enable USE_XMAX_PLUG +exec_test $1 $2 "Z_DUAL_STEPPER_DRIVERS, Z_DUAL_ENDSTOPS" + +# Clean up +restore_configs diff --git a/platformio.ini b/platformio.ini index 1a2e0fe2e..0c7c8d403 100644 --- a/platformio.ini +++ b/platformio.ini @@ -530,6 +530,19 @@ lib_ignore = Adafruit NeoPixel, c1921b4, TMC26XStepper, SailfishLCD, SailfishRGB src_filter = ${common.default_src_filter} + monitor_speed = 250000 +# +# Teensy 3.1 / 3.2 (ARM Cortex-M4) +# +[env:teensy31] +platform = teensy +framework = arduino +board = teensy31 +build_flags = ${common.build_flags} +lib_deps = ${common.lib_deps} +lib_ignore = Adafruit NeoPixel +src_filter = ${common.default_src_filter} + +monitor_speed = 250000 + # # Teensy 3.5 / 3.6 (ARM Cortex-M4) #