diff --git a/Marlin/pins_ALLIGATOR_R2.h b/Marlin/pins_ALLIGATOR_R2.h
new file mode 100644
index 000000000..1dcdaa324
--- /dev/null
+++ b/Marlin/pins_ALLIGATOR_R2.h
@@ -0,0 +1,159 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * Alligator Board R2
+ * http://www.3dartists.org/
+ */
+
+#ifndef __SAM3X8E__
+ #error "Oops! Make sure you have 'Arduino Due' selected from the 'Tools -> Boards' menu."
+#endif
+
+#define BOARD_NAME "Alligator Board R2"
+
+//
+// Servos
+//
+#define SERVO0_PIN 36
+#define SERVO1_PIN 40
+#define SERVO2_PIN 41
+#define SERVO3_PIN -1
+
+//
+// Limit Switches
+//
+#define X_MIN_PIN 33 // PC1
+#define X_MAX_PIN 34 // PC2
+#define Y_MIN_PIN 35 // PC3
+#define Y_MAX_PIN 37 // PC5
+#define Z_MIN_PIN 38 // PC6
+#define Z_MAX_PIN 39 // PC7
+
+//
+// Steppers
+//
+#define X_STEP_PIN 96 // PB24
+#define X_DIR_PIN 2 // PB25
+#define X_ENABLE_PIN 24 // PA15, motor RESET pin
+
+#define Y_STEP_PIN 94 // PB22
+#define Y_DIR_PIN 95 // PB23
+#define Y_ENABLE_PIN 24 // PA15, motor RESET pin
+
+#define Z_STEP_PIN 98 // PC27
+#define Z_DIR_PIN 3 // PC28
+#define Z_ENABLE_PIN 24 // PA15, motor RESET pin
+
+#define E0_STEP_PIN 5 // PC25
+#define E0_DIR_PIN 4 // PC26
+#define E0_ENABLE_PIN 24 // PA15, motor RESET pin
+
+#define E1_STEP_PIN 28 // PD3 on piggy
+#define E1_DIR_PIN 27 // PD2 on piggy
+#define E1_ENABLE_PIN 24 // PA15, motor RESET pin
+
+#define E2_STEP_PIN 11 // PD7 on piggy
+#define E2_DIR_PIN 29 // PD6 on piggy
+#define E2_ENABLE_PIN 24 // PA15, motor RESET pin
+
+#define E3_STEP_PIN 30 // PD9 on piggy
+#define E3_DIR_PIN 12 // PD8 on piggy
+#define E3_ENABLE_PIN 24 // PA15, motor RESET pin
+
+// Microstepping pins - Mapping not from fastio.h (?)
+#define X_MS1_PIN 99 // PC10
+#define Y_MS1_PIN 10 // PC29
+#define Z_MS1_PIN 44 // PC19
+#define E0_MS1_PIN 45 // PC18
+
+//#define MOTOR_FAULT_PIN 22 // PB26 , motor X-Y-Z-E0 motor FAULT
+
+//
+// Temperature Sensors
+//
+#define TEMP_0_PIN 1 // Analog Input (PA24)
+#define TEMP_1_PIN 2 // Analog Input (PA23 on piggy)
+#define TEMP_2_PIN 3 // Analog Input (PA22 on piggy)
+#define TEMP_3_PIN 4 // Analog Input (PA6 on piggy)
+#define TEMP_BED_PIN 0 // Analog Input (PA16)
+
+//
+// Heaters / Fans
+//
+// Note that on the Due pin A0 on the board is channel 2 on the ARM chip
+#define HEATER_0_PIN 68 // PA1
+#define HEATER_1_PIN 8 // PC22 on piggy
+#define HEATER_2_PIN 9 // PC21 on piggy
+#define HEATER_3_PIN 97 // PC20 on piggy
+#define HEATER_BED_PIN 69 // PA0
+
+#define FAN_PIN 92 // PA5
+#define FAN1_PIN 31 // PA7
+
+//
+// Misc. Functions
+//
+#define SDSS 77 // PA28
+#define SD_DETECT_PIN 87 // PA29
+#define LED_RED_PIN 40 // PC8
+#define LED_GREEN_PIN 41 // PC9
+
+#define EXP_VOLTAGE_LEVEL_PIN 65
+
+#define SPI_CHAN_DAC 1
+
+#define DAC0_SYNC 53 // PB14
+#define DAC1_SYNC 6 // PC24
+
+// 64K SPI EEPROM
+#define SPI_EEPROM
+#define SPI_CHAN_EEPROM1 2
+#define SPI_EEPROM1_CS 25 // PD0
+
+// 2K SPI EEPROM
+#define SPI_EEPROM2_CS 26 // PD1
+
+// FLASH SPI
+// 32Mb
+#define SPI_FLASH_CS 23 // PA14
+
+//
+// LCD / Controller
+//
+#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
+
+ #define LCD_PINS_RS 18
+ #define LCD_PINS_ENABLE 15
+ #define LCD_PINS_D4 19
+ #define BEEPER_PIN 64
+
+ #define BTN_EN1 14
+ #define BTN_EN2 16
+ #define BTN_ENC 17
+
+ #if UI_VOLTAGE_LEVEL != 1
+ #undef UI_VOLTAGE_LEVEL
+ #define UI_VOLTAGE_LEVEL 1
+ #endif
+
+#endif // REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
diff --git a/Marlin/pins_DUE3DOM.h b/Marlin/pins_DUE3DOM.h
new file mode 100644
index 000000000..2ed273111
--- /dev/null
+++ b/Marlin/pins_DUE3DOM.h
@@ -0,0 +1,164 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * DUE3DOM pin assignments
+ */
+
+#ifndef __SAM3X8E__
+ #error "Oops! Make sure you have 'Arduino Due' selected from the 'Tools -> Boards' menu."
+#endif
+
+#define BOARD_NAME "DUE3DOM"
+
+//
+// Servos
+//
+#define SERVO0_PIN 5
+#define SERVO1_PIN 6
+#define SERVO2_PIN 13
+#define SERVO3_PIN -1
+
+//
+// Limit Switches
+//
+#define X_MIN_PIN 38
+#define X_MAX_PIN 36
+#define Y_MIN_PIN 34
+#define Y_MAX_PIN 32
+#define Z_MIN_PIN 30
+#define Z_MAX_PIN 28
+
+//
+// Steppers
+//
+#define X_STEP_PIN 2
+#define X_DIR_PIN 3
+#define X_ENABLE_PIN 22
+
+#define Y_STEP_PIN 17
+#define Y_DIR_PIN 16
+#define Y_ENABLE_PIN 26
+
+#define Z_STEP_PIN 61 // Z1 STP
+#define Z_DIR_PIN 60 // Z1 DIR
+#define Z_ENABLE_PIN 15 // Z1 ENA
+
+#define E0_STEP_PIN 64 // Z2 STP
+#define E0_DIR_PIN 63 // Z2 DIR
+#define E0_ENABLE_PIN 62 // Z2 ENA
+
+#define E1_STEP_PIN 51 // E1 STP
+#define E1_DIR_PIN 53 // E1 DIR
+#define E1_ENABLE_PIN 65 // E1 ENA
+
+#define E2_STEP_PIN 24 // E2 STP
+#define E2_DIR_PIN 23 // E2 DIR
+#define E2_ENABLE_PIN 49 // E2 ENA
+
+//
+// Temperature Sensors
+//
+#define TEMP_0_PIN 0 // Analog Input (HOTEND0 thermistor)
+#define TEMP_1_PIN 2 // Analog Input (HOTEND1 thermistor)
+#define TEMP_2_PIN 5 // Analog Input (unused)
+#define TEMP_BED_PIN 1 // Analog Input (BED thermistor)
+
+// SPI for Max6675 or Max31855 Thermocouple
+#if DISABLED(SDSUPPORT)
+ #define MAX6675_SS -1
+#else
+ #define MAX6675_SS -1
+#endif
+
+//
+// Heaters / Fans
+//
+#define HEATER_0_PIN 7 // HOTEND0 MOSFET
+#define HEATER_1_PIN 8 // HOTEND1 MOSFET
+#define HEATER_BED_PIN 39 // BED MOSFET
+
+#define FAN_PIN 11 // FAN1 header on board - PRINT FAN
+#define FAN1_PIN 9 // FAN2 header on board - CONTROLLER FAN
+#define FAN2_PIN 12 // FAN3 header on board - EXTRUDER0 FAN
+
+//
+// Misc. Functions
+//
+#define SDSS 4
+#define PS_ON_PIN 40
+
+//
+// LCD / Controller
+//
+#if ENABLED(ULTRA_LCD)
+ #define LCD_PINS_RS 42
+ #define LCD_PINS_ENABLE 43
+ #define LCD_PINS_D4 44
+ #define LCD_PINS_D5 45
+ #define LCD_PINS_D6 46
+ #define LCD_PINS_D7 47
+
+ #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER)
+ #define BEEPER_PIN 41
+
+ #define BTN_EN1 50
+ #define BTN_EN2 52
+ #define BTN_ENC 48
+
+ #define SDSS 4
+ #define SD_DETECT_PIN 14
+
+ // RADDS LCD panel
+ #elif ENABLED(RADDS_DISPLAY)
+ #define BEEPER_PIN 41
+
+ #define BTN_EN1 50
+ #define BTN_EN2 52
+ #define BTN_ENC 48
+
+ #define BTN_BACK 71
+
+ #undef SDSS
+ #define SDSS 4
+ #define SD_DETECT_PIN 14
+
+ #elif ENABLED(SSD1306_OLED_I2C_CONTROLLER)
+ #define BTN_EN1 50
+ #define BTN_EN2 52
+ #define BTN_ENC 48
+ #define BEEPER_PIN 41
+ #define LCD_SDSS 4
+ #define SD_DETECT_PIN 14
+
+ #elif ENABLED(SPARK_FULL_GRAPHICS)
+ #define LCD_PINS_D4 29
+ #define LCD_PINS_ENABLE 27
+ #define LCD_PINS_RS 25
+
+ #define BTN_EN1 35
+ #define BTN_EN2 33
+ #define BTN_ENC 37
+
+ #define BEEPER_PIN -1
+ #endif // SPARK_FULL_GRAPHICS
+#endif // ULTRA_LCD
diff --git a/Marlin/pins_DUE3DOM_MINI.h b/Marlin/pins_DUE3DOM_MINI.h
new file mode 100644
index 000000000..71232ad36
--- /dev/null
+++ b/Marlin/pins_DUE3DOM_MINI.h
@@ -0,0 +1,156 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * DUE3DOM MINI pin assignments
+ */
+
+#ifndef __SAM3X8E__
+ #error "Oops! Make sure you have 'Arduino Due' selected from the 'Tools -> Boards' menu."
+#endif
+
+#define BOARD_NAME "DUE3DOM MINI"
+
+//
+// Servos
+//
+#define SERVO0_PIN 5
+#define SERVO1_PIN 6
+#define SERVO2_PIN 8 // 4-pin header FAN0
+#define SERVO3_PIN -1
+
+//
+// Limit Switches
+//
+#define X_MIN_PIN 38
+#define X_MAX_PIN -1
+#define Y_MIN_PIN 34
+#define Y_MAX_PIN -1
+#define Z_MIN_PIN 30
+#define Z_MAX_PIN -1
+
+//
+// Steppers
+//
+#define X_STEP_PIN 17
+#define X_DIR_PIN 16
+#define X_ENABLE_PIN 22
+
+#define Y_STEP_PIN 2
+#define Y_DIR_PIN 3
+#define Y_ENABLE_PIN 26
+
+#define Z_STEP_PIN 64
+#define Z_DIR_PIN 63
+#define Z_ENABLE_PIN 15
+
+#define E0_STEP_PIN 61
+#define E0_DIR_PIN 60
+#define E0_ENABLE_PIN 62
+
+//
+// Temperature Sensors
+//
+#define TEMP_0_PIN 0 // Analog Input (HOTEND0 thermistor)
+#define TEMP_1_PIN 2 // Analog Input (unused)
+#define TEMP_2_PIN 5 // Analog Input (OnBoard thermistor beta 3950)
+#define TEMP_BED_PIN 1 // Analog Input (BED thermistor)
+
+// SPI for Max6675 or Max31855 Thermocouple
+#if DISABLED(SDSUPPORT)
+ #define MAX6675_SS 53
+#else
+ #define MAX6675_SS 53
+#endif
+
+//
+// Heaters / Fans
+//
+#define HEATER_0_PIN 13 // HOTEND0 MOSFET
+#define HEATER_BED_PIN 7 // BED MOSFET
+
+#define FAN_PIN 11 // FAN1 header on board - PRINT FAN
+#define FAN1_PIN 12 // FAN2 header on board - CONTROLLER FAN
+#define FAN2_PIN 9 // FAN3 header on board - EXTRUDER0 FAN
+//#define FAN3_PIN 8 // FAN0 4-pin header on board
+
+//
+// Misc. Functions
+//
+#define SDSS 4
+#define PS_ON_PIN 40
+
+//
+// LCD / Controller
+//
+#if ENABLED(ULTRA_LCD)
+ #define LCD_PINS_RS 42
+ #define LCD_PINS_ENABLE 43
+ #define LCD_PINS_D4 44
+ #define LCD_PINS_D5 45
+ #define LCD_PINS_D6 46
+ #define LCD_PINS_D7 47
+
+ #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER)
+ #define BEEPER_PIN 41
+
+ #define BTN_EN1 50
+ #define BTN_EN2 52
+ #define BTN_ENC 48
+
+ #define SDSS 4
+ #define SD_DETECT_PIN 14
+
+ // RADDS LCD panel
+ #elif ENABLED(RADDS_DISPLAY)
+ #define BEEPER_PIN 41
+
+ #define BTN_EN1 50
+ #define BTN_EN2 52
+ #define BTN_ENC 48
+
+ #define BTN_BACK 71
+
+ #undef SDSS
+ #define SDSS 4
+ #define SD_DETECT_PIN 14
+
+ #elif ENABLED(SSD1306_OLED_I2C_CONTROLLER)
+ #define BTN_EN1 50
+ #define BTN_EN2 52
+ #define BTN_ENC 48
+ #define BEEPER_PIN 41
+ #define LCD_SDSS 4
+ #define SD_DETECT_PIN 14
+
+ #elif ENABLED(SPARK_FULL_GRAPHICS)
+ #define LCD_PINS_D4 29
+ #define LCD_PINS_ENABLE 27
+ #define LCD_PINS_RS 25
+
+ #define BTN_EN1 35
+ #define BTN_EN2 33
+ #define BTN_ENC 37
+
+ #define BEEPER_PIN -1
+ #endif // SPARK_FULL_GRAPHICS
+#endif // ULTRA_LCD
diff --git a/Marlin/pins_RADDS.h b/Marlin/pins_RADDS.h
new file mode 100644
index 000000000..6c6226c85
--- /dev/null
+++ b/Marlin/pins_RADDS.h
@@ -0,0 +1,193 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * RADDS
+ */
+
+#ifndef __SAM3X8E__
+ #error "Oops! Make sure you have 'Arduino Due' selected from the 'Tools -> Boards' menu."
+#endif
+
+#define BOARD_NAME "RADDS"
+
+//
+// Servos
+//
+#define SERVO0_PIN 5
+#define SERVO1_PIN 6
+#define SERVO2_PIN 39
+#define SERVO3_PIN 40
+
+//
+// Limit Switches
+//
+#define X_MIN_PIN 28
+#define X_MAX_PIN 34
+#define Y_MIN_PIN 30
+#define Y_MAX_PIN 36
+#define Z_MIN_PIN 32
+#define Z_MAX_PIN 38
+
+//
+// Steppers
+//
+#define X_STEP_PIN 24
+#define X_DIR_PIN 23
+#define X_ENABLE_PIN 26
+#define X_CS_PIN 25
+
+#define Y_STEP_PIN 17
+#define Y_DIR_PIN 16
+#define Y_ENABLE_PIN 22
+#define Y_CS_PIN 27
+
+#define Z_STEP_PIN 2
+#define Z_DIR_PIN 3
+#define Z_ENABLE_PIN 15
+#define Z_CS_PIN 29
+
+#define E0_STEP_PIN 61
+#define E0_DIR_PIN 60
+#define E0_ENABLE_PIN 62
+#define E0_CS_PIN 31
+
+#define E1_STEP_PIN 64
+#define E1_DIR_PIN 63
+#define E1_ENABLE_PIN 65
+#define E1_CS_PIN 33
+
+#define E2_STEP_PIN 51
+#define E2_DIR_PIN 53
+#define E2_ENABLE_PIN 49
+#define E2_CS_PIN 35
+
+// For Extension Board V2
+// http://doku.radds.org/dokumentation/extension-board
+//#define E3_STEP_PIN 35
+//#define E3_DIR_PIN 33
+//#define E3_ENABLE_PIN 37
+//#define E3_CS_PIN 6
+
+//#define Z2_STEP_PIN 29
+//#define Z2_DIR_PIN 27
+//#define Z2_ENABLE_PIN 31
+//#define Z2_CS_PIN 39
+
+// Microstepping pins - Mapping not from fastio.h (?)
+//#define E3_MS1_PIN 67
+//#define E3_MS2_PIN 68
+//#define E3_MS3_PIN 69
+//#define Z2_MS1_PIN 67 // shared with E3_MS1_PIN
+//#define Z2_MS2_PIN 68 // shared with E3_MS2_PIN
+//#define Z2_MS3_PIN 69 // shared with E3_MS3_PIN
+
+//
+// Temperature Sensors
+//
+#define TEMP_0_PIN 0 // Analog Input
+#define TEMP_1_PIN 1 // Analog Input
+#define TEMP_2_PIN 2 // Analog Input
+#define TEMP_3_PIN 3 // Analog Input
+#define TEMP_BED_PIN 4 // Analog Input
+
+// SPI for Max6675 or Max31855 Thermocouple
+#if DISABLED(SDSUPPORT)
+ #define MAX6675_SS 53
+#else
+ #define MAX6675_SS 49
+#endif
+
+//
+// Heaters / Fans
+//
+#define HEATER_0_PIN 13
+#define HEATER_1_PIN 12
+#define HEATER_2_PIN 11
+#define HEATER_BED_PIN 7 // BED
+
+#define FAN_PIN 9
+#define FAN1_PIN 8
+
+//
+// Misc. Functions
+//
+#define SDSS 4
+#define PS_ON_PIN 40
+
+#define I2C_EEPROM
+
+//
+// LCD / Controller
+//
+#if ENABLED(ULTRA_LCD)
+ // RADDS LCD panel
+ #if ENABLED(RADDS_DISPLAY)
+ #define LCD_PINS_RS 42
+ #define LCD_PINS_ENABLE 43
+ #define LCD_PINS_D4 44
+ #define LCD_PINS_D5 45
+ #define LCD_PINS_D6 46
+ #define LCD_PINS_D7 47
+
+ #define BEEPER_PIN 41
+
+ #define BTN_EN1 50
+ #define BTN_EN2 52
+ #define BTN_ENC 48
+
+ #define BTN_BACK 71
+
+ #undef SDSS
+ #define SDSS 10
+ #define SD_DETECT_PIN 14
+
+ #elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
+ #define LCD_PINS_RS 46
+ #define LCD_PINS_ENABLE 47
+ #define LCD_PINS_D4 44
+
+ #define BEEPER_PIN 41
+
+ #define BTN_EN1 50
+ #define BTN_EN2 52
+ #define BTN_ENC 48
+
+ #elif ENABLED(SSD1306_OLED_I2C_CONTROLLER)
+ #define BTN_EN1 50
+ #define BTN_EN2 52
+ #define BTN_ENC 48
+ #define BEEPER_PIN 41
+ #define LCD_SDSS 10
+ #define SD_DETECT_PIN 14
+
+ #elif ENABLED(SPARK_FULL_GRAPHICS)
+ #define LCD_PINS_D4 29
+ #define LCD_PINS_ENABLE 27
+ #define LCD_PINS_RS 25
+
+ #define BTN_EN1 35
+ #define BTN_EN2 33
+ #define BTN_ENC 37
+
+ #endif // SPARK_FULL_GRAPHICS
+#endif // ULTRA_LCD
diff --git a/Marlin/pins_RAMPS4DUE.h b/Marlin/pins_RAMPS4DUE.h
new file mode 100644
index 000000000..5f4cbc481
--- /dev/null
+++ b/Marlin/pins_RAMPS4DUE.h
@@ -0,0 +1,62 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * Arduino Mega or Due with RAMPS4DUE pin assignments
+ *
+ * Applies to the following boards:
+ *
+ * RAMPS4DUE_EFB (Hotend, Fan, Bed)
+ * RAMPS4DUE_EEB (Hotend0, Hotend1, Bed)
+ * RAMPS4DUE_EFF (Hotend, Fan0, Fan1)
+ * RAMPS4DUE_EEF (Hotend0, Hotend1, Fan)
+ * RAMPS4DUE_SF (Spindle, Controller Fan)
+ *
+ * Differences between
+ * RAMPS_14 | RAMPS4DUE
+ * A13 | A9/D63 (shares the same pin with AUX2_4PIN)
+ * A14 | A10/D64 (shares the same pin with AUX2_5PIN)
+ * A15 | NC
+ */
+
+#if !defined(__SAM3X8E__) && !defined(__AVR_ATmega2560__)
+ #error "Oops! Make sure you have 'Arduino Due' or 'Arduino Mega' selected from the 'Tools -> Boards' menu."
+#endif
+
+#ifndef BOARD_NAME
+ #define BOARD_NAME "RAMPS4DUE"
+#endif
+
+#define IS_RAMPS4DUE
+#include "pins_RAMPS.h"
+
+//
+// Temperature Sensors
+//
+#undef TEMP_0_PIN
+#define TEMP_0_PIN 9 // Analog Input
+
+#undef TEMP_1_PIN
+#define TEMP_1_PIN -1 // Analog Input
+
+#undef TEMP_BED_PIN
+#define TEMP_BED_PIN 10 // Analog Input
diff --git a/Marlin/pins_RAMPS_DUO.h b/Marlin/pins_RAMPS_DUO.h
new file mode 100644
index 000000000..264cf4167
--- /dev/null
+++ b/Marlin/pins_RAMPS_DUO.h
@@ -0,0 +1,123 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * Arduino Mega or Due with RAMPS Duo pin assignments
+ *
+ * Applies to the following boards:
+ *
+ * RAMPS_DUO_EFB (Hotend, Fan, Bed)
+ * RAMPS_DUO_EEB (Hotend0, Hotend1, Bed)
+ * RAMPS_DUO_EFF (Hotend, Fan0, Fan1)
+ * RAMPS_DUO_EEF (Hotend0, Hotend1, Fan)
+ * RAMPS_DUO_SF (Spindle, Controller Fan)
+ *
+ * Differences between
+ * RAMPS_14 | RAMPS_DUO
+ * A9/D63 | A12/D66
+ * A10/D64 | A13/D67
+ * A11/D65 | A14/D68
+ * A12/D66 | A15/D69
+ * A13 | A9
+ * A14 | A10
+ * A15 | A11
+ */
+
+#if !defined(__SAM3X8E__) && !defined(__AVR_ATmega2560__)
+ #error "Oops! Make sure you have 'Arduino Due' or 'Arduino Mega' selected from the 'Tools -> Boards' menu."
+#endif
+
+#ifndef BOARD_NAME
+ #define BOARD_NAME "RAMPS Duo"
+#endif
+
+#define IS_RAMPS_DUO
+#include "pins_RAMPS.h"
+
+//
+// Temperature Sensors
+//
+#undef TEMP_0_PIN
+#define TEMP_0_PIN 9 // Analog Input
+
+#undef TEMP_1_PIN
+#define TEMP_1_PIN 11 // Analog Input
+
+#undef TEMP_BED_PIN
+#define TEMP_BED_PIN 10 // Analog Input
+
+// SPI for Max6675 or Max31855 Thermocouple
+#undef MAX6675_SS
+#if DISABLED(SDSUPPORT)
+ #define MAX6675_SS 69 // Do not use pin 53 if there is even the remote possibility of using Display/SD card
+#else
+ #define MAX6675_SS 69 // Do not use pin 49 as this is tied to the switch inside the SD card socket to detect if there is an SD card present
+#endif
+
+//
+// LCD / Controller
+//
+#if ENABLED(ULTRA_LCD)
+ #if ENABLED(NEWPANEL) && ENABLED(PANEL_ONE)
+ #undef LCD_PINS_D4
+ #define LCD_PINS_D4 68
+
+ #undef LCD_PINS_D5
+ #define LCD_PINS_D5 69
+
+ #undef LCD_PINS_D7
+ #define LCD_PINS_D7 67
+ #endif
+
+ #if ENABLED(NEWPANEL)
+ #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
+ #undef BTN_EN1
+ #define BTN_EN1 67
+
+ #undef BTN_ENC
+ #define BTN_ENC 66
+ #elif ENABLED(MINIPANEL)
+ #undef DOGLCD_CS
+ #define DOGLCD_CS 69
+
+ #undef LCD_BACKLIGHT_PIN
+ #define LCD_BACKLIGHT_PIN 68 // backlight LED on A14/D68
+
+ #undef KILL_PIN
+ #define KILL_PIN 67
+
+ #undef BTN_EN2
+ #define BTN_EN2 66
+ #else
+ #if ENABLED(REPRAPWORLD_KEYPAD)
+ #undef BTN_EN1
+ #define BTN_EN1 67 // encoder
+
+ #undef BTN_ENC
+ #define BTN_ENC 66 // enter button
+ #elif ENABLED(PANEL_ONE)
+ #undef BTN_EN2
+ #define BTN_EN2 66 // AUX2 PIN 4
+ #endif
+ #endif
+ #endif // NEWPANEL
+#endif // ULTRA_LCD
diff --git a/Marlin/pins_RAMPS_FD.h b/Marlin/pins_RAMPS_FD.h
new file mode 100644
index 000000000..5cbf7fb19
--- /dev/null
+++ b/Marlin/pins_RAMPS_FD.h
@@ -0,0 +1,148 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * RAMPS-FD
+ *
+ * No EEPROM
+ * Use 4k7 thermistor tables
+ */
+
+#ifndef __SAM3X8E__
+ #error "Oops! Make sure you have 'Arduino Due' selected from the 'Tools -> Boards' menu."
+#endif
+
+#ifndef BOARD_NAME
+ #define BOARD_NAME "RAMPS-FD"
+#endif
+
+#define INVERTED_HEATER_PINS
+#define INVERTED_BED_PINS
+#define INVERTED_FAN_PINS
+
+//
+// Servos
+//
+#define SERVO0_PIN 7
+#define SERVO1_PIN 6
+#define SERVO2_PIN 5
+#define SERVO3_PIN 3
+
+//
+// Limit Switches
+//
+#define X_MIN_PIN 22
+#define X_MAX_PIN 30
+#define Y_MIN_PIN 24
+#define Y_MAX_PIN 38
+#define Z_MIN_PIN 26
+#define Z_MAX_PIN 34
+
+//
+// Steppers
+//
+#define X_STEP_PIN 63
+#define X_DIR_PIN 62
+#define X_ENABLE_PIN 48
+#define X_CS_PIN 68
+
+#define Y_STEP_PIN 65
+#define Y_DIR_PIN 64
+#define Y_ENABLE_PIN 46
+#define Y_CS_PIN 60
+
+#define Z_STEP_PIN 67
+#define Z_DIR_PIN 66
+#define Z_ENABLE_PIN 44
+#define Z_CS_PIN 58
+
+#define E0_STEP_PIN 36
+#define E0_DIR_PIN 28
+#define E0_ENABLE_PIN 42
+#define E0_CS_PIN 67
+
+#define E1_STEP_PIN 43
+#define E1_DIR_PIN 41
+#define E1_ENABLE_PIN 39
+#define E1_CS_PIN 61
+
+#define E2_STEP_PIN 32
+#define E2_DIR_PIN 47
+#define E2_ENABLE_PIN 45
+#define E2_CS_PIN 59
+
+//
+// Temperature Sensors
+//
+#define TEMP_0_PIN 1 // Analog Input
+#define TEMP_1_PIN 2 // Analog Input
+#define TEMP_2_PIN 3 // Analog Input
+#define TEMP_BED_PIN 0 // Analog Input
+
+// SPI for Max6675 or Max31855 Thermocouple
+#if DISABLED(SDSUPPORT)
+ #define MAX6675_SS 53
+#else
+ #define MAX6675_SS 49
+#endif
+
+//
+// Heaters / Fans
+//
+#define HEATER_0_PIN 9
+#define HEATER_1_PIN 10
+#define HEATER_2_PIN 11
+#define HEATER_BED_PIN 8 // BED
+
+#define FAN_PIN 12
+#define CONTROLLER_FAN_PIN -1
+
+//
+// Misc. Functions
+//
+#define SDSS 4
+#define LED_PIN 13
+
+//
+// LCD / Controller
+//
+#if ENABLED(ULTRA_LCD)
+ #if ENABLED(NEWPANEL)
+ // ramps-fd lcd adaptor
+ #define LCD_PINS_RS 16
+ #define LCD_PINS_ENABLE 17
+ #define LCD_PINS_D4 23
+ #define LCD_PINS_D5 25
+ #define LCD_PINS_D6 27
+ #define LCD_PINS_D7 29
+
+ #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER)
+ #define BEEPER_PIN 37
+
+ #define BTN_EN1 33
+ #define BTN_EN2 31
+ #define BTN_ENC 35
+
+ #define SD_DETECT_PIN 49
+ #endif
+ #endif
+#endif // ULTRA_LCD
diff --git a/Marlin/pins_RAMPS_FD_V2.h b/Marlin/pins_RAMPS_FD_V2.h
new file mode 100644
index 000000000..07a10865e
--- /dev/null
+++ b/Marlin/pins_RAMPS_FD_V2.h
@@ -0,0 +1,38 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * RAMPS-FD v2
+ *
+ * EEPROM supported
+ * Use 1k thermistor tables
+ */
+
+#define BOARD_NAME "RAMPS-FD v2"
+
+#include "pins_RAMPS_FD.h"
+
+#undef INVERTED_HEATER_PINS
+#undef INVERTED_BED_PINS
+#undef INVERTED_FAN_PINS
+
+#define I2C_EEPROM
diff --git a/Marlin/pins_RAMPS_SMART.h b/Marlin/pins_RAMPS_SMART.h
new file mode 100644
index 000000000..e7abd24ae
--- /dev/null
+++ b/Marlin/pins_RAMPS_SMART.h
@@ -0,0 +1,113 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * Arduino Due with RAMPS-SMART pin assignments
+ *
+ * Applies to the following boards:
+ *
+ * RAMPS_SMART_EFB (Hotend, Fan, Bed)
+ * RAMPS_SMART_EEB (Hotend0, Hotend1, Bed)
+ * RAMPS_SMART_EFF (Hotend, Fan0, Fan1)
+ * RAMPS_SMART_EEF (Hotend0, Hotend1, Fan)
+ * RAMPS_SMART_SF (Spindle, Controller Fan)
+ *
+ * Differences between
+ * RAMPS_14 | RAMPS-SMART
+ * NONE | D16 (Additional AUX-3 pin(AUX3_2PIN), shares the same pin with AUX4_18PIN)
+ * NONE | D17 (Additional AUX-3 pin(AUX3_1PIN), shares the same pin with AUX4_17PIN)
+ * D0 | NONE
+ * D1 | NONE
+ * A3/D57 | NONE
+ * A4/D58 | NONE
+ * A5/D59 | A3/D57
+ * A9/D63 | A4/D58
+ * A10/D64 | A5/D59
+ * A11/D65 | D66
+ * A12/D66 | D67
+ * A13 | A9
+ * A14 | A10
+ * A15 | A11
+ */
+
+#ifndef __SAM3X8E__
+ #error "Oops! Make sure you have 'Arduino Due' selected from the 'Tools -> Boards' menu."
+#endif
+
+#ifndef BOARD_NAME
+ #define BOARD_NAME "RAMPS-SMART"
+#endif
+
+#define IS_RAMPS_SMART
+#include "pins_RAMPS.h"
+
+//
+// Temperature Sensors
+//
+#undef TEMP_0_PIN
+#define TEMP_0_PIN 9 // Analog Input
+
+#undef TEMP_1_PIN
+#define TEMP_1_PIN 10 // Analog Input
+
+#undef TEMP_BED_PIN
+#define TEMP_BED_PIN 11 // Analog Input
+
+// SPI for Max6675 or Max31855 Thermocouple
+#if DISABLED(SDSUPPORT)
+ #undef MAX6675_SS
+ #define MAX6675_SS 67 // Do not use pin 53 if there is even the remote possibility of using Display/SD card
+#else
+ #undef MAX6675_SS
+ #define MAX6675_SS 67 // Do not use pin 49 as this is tied to the switch inside the SD card socket to detect if there is an SD card present
+#endif
+
+//
+// LCD / Controller
+//
+// Support for AZSMZ 12864 LCD with SD Card 3D printer smart controller control panel (not tested)
+#if ENABLED(VIKI2)
+ #undef BEEPER_PIN
+ #define BEEPER_PIN 66
+
+ // Pins for DOGM SPI LCD Support
+ #undef DOGLCD_A0
+ #define DOGLCD_A0 59
+
+ #undef DOGLCD_A0
+ #define DOGLCD_CS 44
+
+ #undef BTN_EN1
+ #define BTN_EN1 58
+
+ #undef BTN_EN2
+ #define BTN_EN2 40
+
+ #undef BTN_ENC
+ #define BTN_ENC 67
+
+ #undef SD_DETECT_PIN
+ #define SD_DETECT_PIN 49 // Pin 49 for display sd interface, 72 for easy adapter board
+
+ #undef KILL_PIN
+ #define KILL_PIN 42
+#endif
diff --git a/Marlin/src/HAL/HAL_DUE/HAL_Due.cpp b/Marlin/src/HAL/HAL_DUE/HAL_Due.cpp
new file mode 100644
index 000000000..2612e28c8
--- /dev/null
+++ b/Marlin/src/HAL/HAL_DUE/HAL_Due.cpp
@@ -0,0 +1,124 @@
+/* **************************************************************************
+
+ Marlin 3D Printer Firmware
+ Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+****************************************************************************/
+
+
+/**
+ * Description: HAL for Arduino Due and compatible (SAM3X8E)
+ *
+ * For ARDUINO_ARCH_SAM
+ */
+
+#ifdef ARDUINO_ARCH_SAM
+
+// --------------------------------------------------------------------------
+// Includes
+// --------------------------------------------------------------------------
+
+#include "../HAL.h"
+
+#include
+
+// --------------------------------------------------------------------------
+// Externals
+// --------------------------------------------------------------------------
+
+// --------------------------------------------------------------------------
+// Local defines
+// --------------------------------------------------------------------------
+
+// --------------------------------------------------------------------------
+// Types
+// --------------------------------------------------------------------------
+
+// --------------------------------------------------------------------------
+// Variables
+// --------------------------------------------------------------------------
+
+// --------------------------------------------------------------------------
+// Public Variables
+// --------------------------------------------------------------------------
+
+uint16_t HAL_adc_result;
+
+// --------------------------------------------------------------------------
+// Private Variables
+// --------------------------------------------------------------------------
+
+// --------------------------------------------------------------------------
+// Function prototypes
+// --------------------------------------------------------------------------
+
+// --------------------------------------------------------------------------
+// Private functions
+// --------------------------------------------------------------------------
+
+// --------------------------------------------------------------------------
+// Public functions
+// --------------------------------------------------------------------------
+
+// disable interrupts
+void cli(void) { noInterrupts(); }
+
+// enable interrupts
+void sei(void) { interrupts(); }
+
+void HAL_clear_reset_source(void) { }
+
+uint8_t HAL_get_reset_source (void) {
+ switch ((RSTC->RSTC_SR >> 8) & 7) {
+ case 0: return RST_POWER_ON; break;
+ case 1: return RST_BACKUP; break;
+ case 2: return RST_WATCHDOG; break;
+ case 3: return RST_SOFTWARE; break;
+ case 4: return RST_EXTERNAL; break;
+ default:
+ return 0;
+ }
+}
+
+void _delay_ms(int delay_ms) {
+ //todo: port for Due?
+ delay (delay_ms);
+}
+
+extern "C" {
+ extern unsigned int _ebss; // end of bss section
+}
+
+// return free memory between end of heap (or end bss) and whatever is current
+int freeMemory() {
+ int free_memory, heap_end = (int)_sbrk(0);
+ return (int)&free_memory - (heap_end ? heap_end : (int)&_ebss);
+}
+
+// --------------------------------------------------------------------------
+// ADC
+// --------------------------------------------------------------------------
+
+void HAL_adc_start_conversion (uint8_t adc_pin) {
+ HAL_adc_result = analogRead(adc_pin);
+}
+
+uint16_t HAL_adc_get_result(void) {
+ // nop
+ return HAL_adc_result;
+}
+
+#endif // ARDUINO_ARCH_SAM
diff --git a/Marlin/src/HAL/HAL_DUE/HAL_Due.h b/Marlin/src/HAL/HAL_DUE/HAL_Due.h
new file mode 100644
index 000000000..6280cbab9
--- /dev/null
+++ b/Marlin/src/HAL/HAL_DUE/HAL_Due.h
@@ -0,0 +1,169 @@
+/**
+ * Marlin 3D Printer Firmware
+ *
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
+ * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * Description: HAL for Arduino Due and compatible (SAM3X8E)
+ *
+ * For ARDUINO_ARCH_SAM
+ */
+
+#ifndef _HAL_DUE_H
+#define _HAL_DUE_H
+
+// --------------------------------------------------------------------------
+// Includes
+// --------------------------------------------------------------------------
+
+#include
+
+#include "Arduino.h"
+
+#include "fastio_Due.h"
+#include "watchdog_Due.h"
+
+#include "HAL_timers_Due.h"
+
+// --------------------------------------------------------------------------
+// Defines
+// --------------------------------------------------------------------------
+
+#if SERIAL_PORT == -1
+ #define MYSERIAL SerialUSB
+#elif SERIAL_PORT == 0
+ #define MYSERIAL Serial
+#elif SERIAL_PORT == 1
+ #define MYSERIAL Serial1
+#elif SERIAL_PORT == 2
+ #define MYSERIAL Serial2
+#elif SERIAL_PORT == 3
+ #define MYSERIAL Serial3
+#endif
+
+#define _BV(bit) (1 << (bit))
+
+#ifndef analogInputToDigitalPin
+ #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
+#endif
+
+#define CRITICAL_SECTION_START uint32_t primask = __get_PRIMASK(); __disable_irq();
+#define CRITICAL_SECTION_END if (!primask) __enable_irq();
+
+// On AVR this is in math.h?
+#define square(x) ((x)*(x))
+
+#ifndef strncpy_P
+ #define strncpy_P(dest, src, num) strncpy((dest), (src), (num))
+#endif
+
+// Fix bug in pgm_read_ptr
+#undef pgm_read_ptr
+#define pgm_read_ptr(addr) (*(addr))
+
+#define RST_POWER_ON 1
+#define RST_EXTERNAL 2
+#define RST_BROWN_OUT 4
+#define RST_WATCHDOG 8
+#define RST_JTAG 16
+#define RST_SOFTWARE 32
+#define RST_BACKUP 64
+
+// --------------------------------------------------------------------------
+// Types
+// --------------------------------------------------------------------------
+
+
+// --------------------------------------------------------------------------
+// Public Variables
+// --------------------------------------------------------------------------
+
+/** result of last ADC conversion */
+extern uint16_t HAL_adc_result;
+
+// --------------------------------------------------------------------------
+// Public functions
+// --------------------------------------------------------------------------
+
+// Disable interrupts
+void cli(void);
+
+// Enable interrupts
+void sei(void);
+
+/** clear reset reason */
+void HAL_clear_reset_source (void);
+
+/** reset reason */
+uint8_t HAL_get_reset_source (void);
+
+void _delay_ms(int delay);
+
+int freeMemory(void);
+
+// SPI: Extended functions which take a channel number (hardware SPI only)
+/** Write single byte to specified SPI channel */
+void spiSend(uint32_t chan, byte b);
+/** Write buffer to specified SPI channel */
+void spiSend(uint32_t chan, const uint8_t* buf, size_t n);
+/** Read single byte from specified SPI channel */
+uint8_t spiRec(uint32_t chan);
+
+
+// EEPROM
+void eeprom_write_byte(unsigned char *pos, unsigned char value);
+unsigned char eeprom_read_byte(unsigned char *pos);
+void eeprom_read_block (void *__dst, const void *__src, size_t __n);
+void eeprom_update_block (const void *__src, void *__dst, size_t __n);
+
+
+// ADC
+
+#define HAL_ANALOG_SELECT(pin)
+
+inline void HAL_adc_init(void) {}//todo
+
+#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
+#define HAL_READ_ADC HAL_adc_result
+
+
+void HAL_adc_start_conversion (uint8_t adc_pin);
+
+uint16_t HAL_adc_get_result(void);
+
+//
+uint16_t HAL_getAdcReading(uint8_t chan);
+
+void HAL_startAdcConversion(uint8_t chan);
+uint8_t HAL_pinToAdcChannel(int pin);
+
+uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
+//uint16_t HAL_getAdcSuperSample(uint8_t chan);
+
+void HAL_enable_AdcFreerun(void);
+//void HAL_disable_AdcFreerun(uint8_t chan);
+
+
+// --------------------------------------------------------------------------
+//
+// --------------------------------------------------------------------------
+
+#endif // _HAL_DUE_H
+
diff --git a/Marlin/src/HAL/HAL_DUE/HAL_spi_Due.cpp b/Marlin/src/HAL/HAL_DUE/HAL_spi_Due.cpp
new file mode 100644
index 000000000..2a7aa8070
--- /dev/null
+++ b/Marlin/src/HAL/HAL_DUE/HAL_spi_Due.cpp
@@ -0,0 +1,336 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * Software SPI functions originally from Arduino Sd2Card Library
+ * Copyright (C) 2009 by William Greiman
+ */
+
+/**
+ * Description: HAL for Arduino Due and compatible (SAM3X8E)
+ *
+ * For ARDUINO_ARCH_SAM
+ */
+
+#ifdef ARDUINO_ARCH_SAM
+
+// --------------------------------------------------------------------------
+// Includes
+// --------------------------------------------------------------------------
+
+#include "../../../MarlinConfig.h"
+
+// --------------------------------------------------------------------------
+// Public Variables
+// --------------------------------------------------------------------------
+
+
+// --------------------------------------------------------------------------
+// Public functions
+// --------------------------------------------------------------------------
+
+#if ENABLED(SOFTWARE_SPI)
+ // --------------------------------------------------------------------------
+ // software SPI
+ // --------------------------------------------------------------------------
+ // bitbanging transfer
+ // run at ~100KHz (necessary for init)
+ static uint8_t spiTransfer(uint8_t b) { // using Mode 0
+ for (int bits = 0; bits < 8; bits++) {
+ if (b & 0x80) {
+ WRITE(MOSI_PIN, HIGH);
+ }
+ else {
+ WRITE(MOSI_PIN, LOW);
+ }
+ b <<= 1;
+
+ WRITE(SCK_PIN, HIGH);
+ delayMicroseconds(5U);
+
+ if (READ(MISO_PIN)) {
+ b |= 1;
+ }
+ WRITE(SCK_PIN, LOW);
+ delayMicroseconds(5U);
+ }
+ return b;
+ }
+
+ void spiBegin() {
+ SET_OUTPUT(SS_PIN);
+ WRITE(SS_PIN, HIGH);
+ SET_OUTPUT(SCK_PIN);
+ SET_INPUT(MISO_PIN);
+ SET_OUTPUT(MOSI_PIN);
+ }
+
+ void spiInit(uint8_t spiRate) {
+ UNUSED(spiRate);
+ WRITE(SS_PIN, HIGH);
+ WRITE(MOSI_PIN, HIGH);
+ WRITE(SCK_PIN, LOW);
+ }
+
+ uint8_t spiRec() {
+ WRITE(SS_PIN, LOW);
+ uint8_t b = spiTransfer(0xff);
+ WRITE(SS_PIN, HIGH);
+ return b;
+ }
+
+ void spiRead(uint8_t*buf, uint16_t nbyte) {
+ if (nbyte == 0) return;
+ WRITE(SS_PIN, LOW);
+ for (int i = 0; i < nbyte; i++) {
+ buf[i] = spiTransfer(0xff);
+ }
+ WRITE(SS_PIN, HIGH);
+ }
+
+ void spiSend(uint8_t b) {
+ WRITE(SS_PIN, LOW);
+ uint8_t response = spiTransfer(b);
+ UNUSED(response);
+ WRITE(SS_PIN, HIGH);
+ }
+
+ static void spiSend(const uint8_t* buf, size_t n) {
+ uint8_t response;
+ if (n == 0) return;
+ WRITE(SS_PIN, LOW);
+ for (uint16_t i = 0; i < n; i++) {
+ response = spiTransfer(buf[i]);
+ }
+ UNUSED(response);
+ WRITE(SS_PIN, HIGH);
+ }
+
+ void spiSendBlock(uint8_t token, const uint8_t* buf) {
+ uint8_t response;
+
+ WRITE(SS_PIN, LOW);
+ response = spiTransfer(token);
+
+ for (uint16_t i = 0; i < 512; i++) {
+ response = spiTransfer(buf[i]);
+ }
+ UNUSED(response);
+ WRITE(SS_PIN, HIGH);
+ }
+#else
+ // --------------------------------------------------------------------------
+ // hardware SPI
+ // --------------------------------------------------------------------------
+ // 8.4 MHz, 4 MHz, 2 MHz, 1 MHz, 0.5 MHz, 0.329 MHz, 0.329 MHz
+ int spiDueDividors[] = { 10, 21, 42, 84, 168, 255, 255 };
+ bool spiInitMaded = false;
+
+ void spiBegin() {
+ if(spiInitMaded == false) {
+ // Configure SPI pins
+ PIO_Configure(
+ g_APinDescription[SCK_PIN].pPort,
+ g_APinDescription[SCK_PIN].ulPinType,
+ g_APinDescription[SCK_PIN].ulPin,
+ g_APinDescription[SCK_PIN].ulPinConfiguration);
+ PIO_Configure(
+ g_APinDescription[MOSI_PIN].pPort,
+ g_APinDescription[MOSI_PIN].ulPinType,
+ g_APinDescription[MOSI_PIN].ulPin,
+ g_APinDescription[MOSI_PIN].ulPinConfiguration);
+ PIO_Configure(
+ g_APinDescription[MISO_PIN].pPort,
+ g_APinDescription[MISO_PIN].ulPinType,
+ g_APinDescription[MISO_PIN].ulPin,
+ g_APinDescription[MISO_PIN].ulPinConfiguration);
+
+ // set master mode, peripheral select, fault detection
+ SPI_Configure(SPI0, ID_SPI0, SPI_MR_MSTR | SPI_MR_MODFDIS | SPI_MR_PS);
+ SPI_Enable(SPI0);
+
+ #if MB(ALLIGATOR)
+ SET_OUTPUT(DAC0_SYNC);
+ #if EXTRUDERS > 1
+ SET_OUTPUT(DAC1_SYNC);
+ WRITE(DAC1_SYNC, HIGH);
+ #endif
+ SET_OUTPUT(SPI_EEPROM1_CS);
+ SET_OUTPUT(SPI_EEPROM2_CS);
+ SET_OUTPUT(SPI_FLASH_CS);
+ WRITE(DAC0_SYNC, HIGH);
+ WRITE(SPI_EEPROM1_CS, HIGH );
+ WRITE(SPI_EEPROM2_CS, HIGH );
+ WRITE(SPI_FLASH_CS, HIGH );
+ WRITE(SS_PIN, HIGH );
+ #endif // MB(ALLIGATOR)
+
+ PIO_Configure(
+ g_APinDescription[SPI_PIN].pPort,
+ g_APinDescription[SPI_PIN].ulPinType,
+ g_APinDescription[SPI_PIN].ulPin,
+ g_APinDescription[SPI_PIN].ulPinConfiguration);
+ spiInit(1);
+ spiInitMaded = true;
+ }
+ }
+
+ void spiInit(uint8_t spiRate) {
+ if(spiInitMaded == false) {
+ if(spiRate > 6) spiRate = 1;
+
+ #if MB(ALLIGATOR)
+ // Set SPI mode 1, clock, select not active after transfer, with delay between transfers
+ SPI_ConfigureNPCS(SPI0, SPI_CHAN_DAC,
+ SPI_CSR_CSAAT | SPI_CSR_SCBR(spiDueDividors[spiRate]) |
+ SPI_CSR_DLYBCT(1));
+ // Set SPI mode 0, clock, select not active after transfer, with delay between transfers
+ SPI_ConfigureNPCS(SPI0, SPI_CHAN_EEPROM1, SPI_CSR_NCPHA |
+ SPI_CSR_CSAAT | SPI_CSR_SCBR(spiDueDividors[spiRate]) |
+ SPI_CSR_DLYBCT(1));
+ #endif//MB(ALLIGATOR)
+
+ // Set SPI mode 0, clock, select not active after transfer, with delay between transfers
+ SPI_ConfigureNPCS(SPI0, SPI_CHAN, SPI_CSR_NCPHA |
+ SPI_CSR_CSAAT | SPI_CSR_SCBR(spiDueDividors[spiRate]) |
+ SPI_CSR_DLYBCT(1));
+ SPI_Enable(SPI0);
+ spiInitMaded = true;
+ }
+ }
+
+ // Write single byte to SPI
+ void spiSend(byte b) {
+ // write byte with address and end transmission flag
+ SPI0->SPI_TDR = (uint32_t)b | SPI_PCS(SPI_CHAN) | SPI_TDR_LASTXFER;
+ // wait for transmit register empty
+ while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
+ // wait for receive register
+ while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
+ // clear status
+ SPI0->SPI_RDR;
+ //delayMicroseconds(1U);
+ }
+
+ void spiSend(const uint8_t* buf, size_t n) {
+ if (n == 0) return;
+ for (size_t i = 0; i < n - 1; i++) {
+ SPI0->SPI_TDR = (uint32_t)buf[i] | SPI_PCS(SPI_CHAN);
+ while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
+ while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
+ SPI0->SPI_RDR;
+ //delayMicroseconds(1U);
+ }
+ spiSend(buf[n - 1]);
+ }
+
+ void spiSend(uint32_t chan, byte b) {
+ uint8_t dummy_read = 0;
+ // wait for transmit register empty
+ while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
+ // write byte with address and end transmission flag
+ SPI0->SPI_TDR = (uint32_t)b | SPI_PCS(chan) | SPI_TDR_LASTXFER;
+ // wait for receive register
+ while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
+ // clear status
+ while ((SPI0->SPI_SR & SPI_SR_RDRF) == 1)
+ dummy_read = SPI0->SPI_RDR;
+ UNUSED(dummy_read);
+ }
+
+ void spiSend(uint32_t chan, const uint8_t* buf, size_t n) {
+ uint8_t dummy_read = 0;
+ if (n == 0) return;
+ for (int i = 0; i < (int)n - 1; i++) {
+ while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
+ SPI0->SPI_TDR = (uint32_t)buf[i] | SPI_PCS(chan);
+ while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
+ while ((SPI0->SPI_SR & SPI_SR_RDRF) == 1)
+ dummy_read = SPI0->SPI_RDR;
+ UNUSED(dummy_read);
+ }
+ spiSend(chan, buf[n - 1]);
+ }
+
+ // Read single byte from SPI
+ uint8_t spiRec() {
+ // write dummy byte with address and end transmission flag
+ SPI0->SPI_TDR = 0x000000FF | SPI_PCS(SPI_CHAN) | SPI_TDR_LASTXFER;
+ // wait for transmit register empty
+ while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
+
+ // wait for receive register
+ while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
+ // get byte from receive register
+ //delayMicroseconds(1U);
+ return SPI0->SPI_RDR;
+ }
+
+ uint8_t spiRec(uint32_t chan) {
+ uint8_t spirec_tmp;
+ // wait for transmit register empty
+ while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
+ while ((SPI0->SPI_SR & SPI_SR_RDRF) == 1)
+ spirec_tmp = SPI0->SPI_RDR;
+ UNUSED(spirec_tmp);
+
+ // write dummy byte with address and end transmission flag
+ SPI0->SPI_TDR = 0x000000FF | SPI_PCS(chan) | SPI_TDR_LASTXFER;
+
+ // wait for receive register
+ while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
+ // get byte from receive register
+ return SPI0->SPI_RDR;
+ }
+
+ // Read from SPI into buffer
+ void spiRead(uint8_t*buf, uint16_t nbyte) {
+ if (nbyte-- == 0) return;
+
+ for (int i = 0; i < nbyte; i++) {
+ //while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
+ SPI0->SPI_TDR = 0x000000FF | SPI_PCS(SPI_CHAN);
+ while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
+ buf[i] = SPI0->SPI_RDR;
+ //delayMicroseconds(1U);
+ }
+ buf[nbyte] = spiRec();
+ }
+
+ // Write from buffer to SPI
+ void spiSendBlock(uint8_t token, const uint8_t* buf) {
+ SPI0->SPI_TDR = (uint32_t)token | SPI_PCS(SPI_CHAN);
+ while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
+ //while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
+ //SPI0->SPI_RDR;
+ for (int i = 0; i < 511; i++) {
+ SPI0->SPI_TDR = (uint32_t)buf[i] | SPI_PCS(SPI_CHAN);
+ while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
+ while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
+ SPI0->SPI_RDR;
+ //delayMicroseconds(1U);
+ }
+ spiSend(buf[511]);
+ }
+#endif // ENABLED(SOFTWARE_SPI)
+
+#endif // ARDUINO_ARCH_SAM
diff --git a/Marlin/src/HAL/HAL_DUE/HAL_timers_Due.cpp b/Marlin/src/HAL/HAL_DUE/HAL_timers_Due.cpp
new file mode 100644
index 000000000..9a502db00
--- /dev/null
+++ b/Marlin/src/HAL/HAL_DUE/HAL_timers_Due.cpp
@@ -0,0 +1,137 @@
+/**
+ * Marlin 3D Printer Firmware
+ *
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
+ * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * Description: HAL for Arduino Due and compatible (SAM3X8E)
+ *
+ * For ARDUINO_ARCH_SAM
+ */
+
+#ifdef ARDUINO_ARCH_SAM
+
+// --------------------------------------------------------------------------
+// Includes
+// --------------------------------------------------------------------------
+
+#include "../HAL.h"
+
+#include "HAL_timers_Due.h"
+
+// --------------------------------------------------------------------------
+// Externals
+// --------------------------------------------------------------------------
+
+// --------------------------------------------------------------------------
+// Local defines
+// --------------------------------------------------------------------------
+
+#define NUM_HARDWARE_TIMERS 9
+
+#define PRESCALER 2
+// --------------------------------------------------------------------------
+// Types
+// --------------------------------------------------------------------------
+
+
+// --------------------------------------------------------------------------
+// Public Variables
+// --------------------------------------------------------------------------
+
+// --------------------------------------------------------------------------
+// Private Variables
+// --------------------------------------------------------------------------
+
+const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
+ { TC0, 0, TC0_IRQn, 0}, // 0 - [servo timer5]
+ { TC0, 1, TC1_IRQn, 0}, // 1
+ { TC0, 2, TC2_IRQn, 0}, // 2
+ { TC1, 0, TC3_IRQn, 2}, // 3 - stepper
+ { TC1, 1, TC4_IRQn, 15}, // 4 - temperature
+ { TC1, 2, TC5_IRQn, 0}, // 5 - [servo timer3]
+ { TC2, 0, TC6_IRQn, 0}, // 6
+ { TC2, 1, TC7_IRQn, 0}, // 7
+ { TC2, 2, TC8_IRQn, 0}, // 8
+};
+
+// --------------------------------------------------------------------------
+// Function prototypes
+// --------------------------------------------------------------------------
+
+// --------------------------------------------------------------------------
+// Private functions
+// --------------------------------------------------------------------------
+
+// --------------------------------------------------------------------------
+// Public functions
+// --------------------------------------------------------------------------
+
+/*
+ Timer_clock1: Prescaler 2 -> 42MHz
+ Timer_clock2: Prescaler 8 -> 10.5MHz
+ Timer_clock3: Prescaler 32 -> 2.625MHz
+ Timer_clock4: Prescaler 128 -> 656.25kHz
+*/
+
+
+void HAL_timer_start (uint8_t timer_num, uint32_t frequency) {
+ Tc *tc = TimerConfig [timer_num].pTimerRegs;
+ IRQn_Type irq = TimerConfig [timer_num].IRQ_Id;
+ uint32_t channel = TimerConfig [timer_num].channel;
+
+ pmc_set_writeprotect(false);
+ pmc_enable_periph_clk((uint32_t)irq);
+ NVIC_SetPriority (irq, TimerConfig [timer_num].priority);
+
+ TC_Configure (tc, channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK1);
+
+ TC_SetRC(tc, channel, VARIANT_MCK/2/frequency);
+ TC_Start(tc, channel);
+
+ // enable interrupt on RC compare
+ tc->TC_CHANNEL[channel].TC_IER = TC_IER_CPCS;
+
+ NVIC_EnableIRQ(irq);
+}
+
+void HAL_timer_enable_interrupt (uint8_t timer_num) {
+ const tTimerConfig *pConfig = &TimerConfig [timer_num];
+ pConfig->pTimerRegs->TC_CHANNEL [pConfig->channel].TC_IER = TC_IER_CPCS;
+}
+
+void HAL_timer_disable_interrupt (uint8_t timer_num) {
+ const tTimerConfig *pConfig = &TimerConfig [timer_num];
+ pConfig->pTimerRegs->TC_CHANNEL [pConfig->channel].TC_IDR = TC_IDR_CPCS;
+}
+
+#if 0
+ void HAL_timer_set_count (uint8_t timer_num, uint32_t count) {
+ const tTimerConfig *pConfig = &TimerConfig [timer_num];
+ TC_SetRC (pConfig->pTimerRegs, pConfig->channel, count);
+ }
+
+ void HAL_timer_isr_prologue (uint8_t timer_num) {
+ const tTimerConfig *pConfig = &TimerConfig [timer_num];
+ TC_GetStatus (pConfig->pTimerRegs, pConfig->channel);
+ }
+#endif
+
+#endif // ARDUINO_ARCH_SAM
diff --git a/Marlin/src/HAL/HAL_DUE/HAL_timers_Due.h b/Marlin/src/HAL/HAL_DUE/HAL_timers_Due.h
new file mode 100644
index 000000000..c5c1b68fc
--- /dev/null
+++ b/Marlin/src/HAL/HAL_DUE/HAL_timers_Due.h
@@ -0,0 +1,116 @@
+/**
+ * Marlin 3D Printer Firmware
+ *
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * HAL for Arduino Due and compatible (SAM3X8E)
+ *
+ * For ARDUINO_ARCH_SAM
+ */
+
+#ifndef _HAL_TIMERS_DUE_H
+#define _HAL_TIMERS_DUE_H
+
+// --------------------------------------------------------------------------
+// Includes
+// --------------------------------------------------------------------------
+
+#include
+
+// --------------------------------------------------------------------------
+// Defines
+// --------------------------------------------------------------------------
+
+#define FORCE_INLINE __attribute__((always_inline)) inline
+
+#define HAL_TIMER_TYPE uint32_t
+#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
+
+#define STEP_TIMER_NUM 3 // index of timer to use for stepper
+#define TEMP_TIMER_NUM 4 // index of timer to use for temperature
+
+#define HAL_TIMER_RATE ((F_CPU) / 2.0) // frequency of timers peripherals
+#define STEPPER_TIMER_PRESCALE 1.0 // prescaler for setting stepper frequency
+#define HAL_STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE)
+#define HAL_TICKS_PER_US ((HAL_STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per us
+
+#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
+
+#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt (STEP_TIMER_NUM)
+#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt (STEP_TIMER_NUM)
+
+#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt (TEMP_TIMER_NUM)
+#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt (TEMP_TIMER_NUM)
+
+#define HAL_ENABLE_ISRs() do { if (thermalManager.in_temp_isr)DISABLE_TEMPERATURE_INTERRUPT(); else ENABLE_TEMPERATURE_INTERRUPT(); ENABLE_STEPPER_DRIVER_INTERRUPT(); } while(0)
+//
+#define HAL_STEP_TIMER_ISR void TC3_Handler()
+#define HAL_TEMP_TIMER_ISR void TC4_Handler()
+
+// --------------------------------------------------------------------------
+// Types
+// --------------------------------------------------------------------------
+
+typedef struct {
+ Tc *pTimerRegs;
+ uint16_t channel;
+ IRQn_Type IRQ_Id;
+ uint8_t priority;
+} tTimerConfig;
+
+// --------------------------------------------------------------------------
+// Public Variables
+// --------------------------------------------------------------------------
+
+extern const tTimerConfig TimerConfig[];
+
+// --------------------------------------------------------------------------
+// Public functions
+// --------------------------------------------------------------------------
+
+void HAL_timer_start (uint8_t timer_num, uint32_t frequency);
+
+static FORCE_INLINE void HAL_timer_set_count (uint8_t timer_num, uint32_t count) {
+ const tTimerConfig *pConfig = &TimerConfig[timer_num];
+ pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC = count;
+}
+
+static FORCE_INLINE HAL_TIMER_TYPE HAL_timer_get_count (uint8_t timer_num) {
+ const tTimerConfig *pConfig = &TimerConfig[timer_num];
+ return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC;
+}
+
+static FORCE_INLINE uint32_t HAL_timer_get_current_count(uint8_t timer_num) {
+ const tTimerConfig *pConfig = &TimerConfig[timer_num];
+ return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_CV;
+}
+
+void HAL_timer_enable_interrupt(uint8_t timer_num);
+void HAL_timer_disable_interrupt(uint8_t timer_num);
+
+//void HAL_timer_isr_prologue (uint8_t timer_num);
+
+static FORCE_INLINE void HAL_timer_isr_prologue(uint8_t timer_num) {
+ const tTimerConfig *pConfig = &TimerConfig[timer_num];
+ // Reading the status register clears the interrupt flag
+ pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_SR;
+}
+
+#endif // _HAL_TIMERS_DUE_H
diff --git a/Marlin/src/HAL/HAL_DUE/Servo_Due.cpp b/Marlin/src/HAL/HAL_DUE/Servo_Due.cpp
new file mode 100644
index 000000000..66667cee3
--- /dev/null
+++ b/Marlin/src/HAL/HAL_DUE/Servo_Due.cpp
@@ -0,0 +1,161 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/*
+ Copyright (c) 2013 Arduino LLC. All right reserved.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifdef ARDUINO_ARCH_SAM
+
+#include "../../../MarlinConfig.h"
+
+#if HAS_SERVOS
+
+#include
+#include "../servo.h"
+#include "../servo_private.h"
+
+static volatile int8_t Channel[_Nbr_16timers ]; // counter for the servo being pulsed for each timer (or -1 if refresh interval)
+
+//------------------------------------------------------------------------------
+/// Interrupt handler for the TC0 channel 1.
+//------------------------------------------------------------------------------
+void Servo_Handler(timer16_Sequence_t timer, Tc *pTc, uint8_t channel);
+
+#ifdef _useTimer1
+ void HANDLER_FOR_TIMER1(void) { Servo_Handler(_timer1, TC_FOR_TIMER1, CHANNEL_FOR_TIMER1); }
+#endif
+#ifdef _useTimer2
+ void HANDLER_FOR_TIMER2(void) { Servo_Handler(_timer2, TC_FOR_TIMER2, CHANNEL_FOR_TIMER2); }
+#endif
+#ifdef _useTimer3
+ void HANDLER_FOR_TIMER3(void) { Servo_Handler(_timer3, TC_FOR_TIMER3, CHANNEL_FOR_TIMER3); }
+#endif
+#ifdef _useTimer4
+ void HANDLER_FOR_TIMER4(void) { Servo_Handler(_timer4, TC_FOR_TIMER4, CHANNEL_FOR_TIMER4); }
+#endif
+#ifdef _useTimer5
+ void HANDLER_FOR_TIMER5(void) { Servo_Handler(_timer5, TC_FOR_TIMER5, CHANNEL_FOR_TIMER5); }
+#endif
+
+void Servo_Handler(timer16_Sequence_t timer, Tc *tc, uint8_t channel) {
+ // clear interrupt
+ tc->TC_CHANNEL[channel].TC_SR;
+ if (Channel[timer] < 0)
+ tc->TC_CHANNEL[channel].TC_CCR |= TC_CCR_SWTRG; // channel set to -1 indicated that refresh interval completed so reset the timer
+ else if (SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive)
+ digitalWrite(SERVO(timer,Channel[timer]).Pin.nbr, LOW); // pulse this channel low if activated
+
+ Channel[timer]++; // increment to the next channel
+ if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
+ tc->TC_CHANNEL[channel].TC_RA = tc->TC_CHANNEL[channel].TC_CV + SERVO(timer,Channel[timer]).ticks;
+ if (SERVO(timer,Channel[timer]).Pin.isActive) // check if activated
+ digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH); // its an active channel so pulse it high
+ }
+ else {
+ // finished all channels so wait for the refresh period to expire before starting over
+ tc->TC_CHANNEL[channel].TC_RA =
+ tc->TC_CHANNEL[channel].TC_CV < usToTicks(REFRESH_INTERVAL) - 4
+ ? (unsigned int)usToTicks(REFRESH_INTERVAL) // allow a few ticks to ensure the next OCR1A not missed
+ : tc->TC_CHANNEL[channel].TC_CV + 4; // at least REFRESH_INTERVAL has elapsed
+ Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel
+ }
+}
+
+static void _initISR(Tc *tc, uint32_t channel, uint32_t id, IRQn_Type irqn) {
+ pmc_enable_periph_clk(id);
+ TC_Configure(tc, channel,
+ TC_CMR_TCCLKS_TIMER_CLOCK3 | // MCK/32
+ TC_CMR_WAVE | // Waveform mode
+ TC_CMR_WAVSEL_UP_RC ); // Counter running up and reset when equals to RC
+
+ /* 84MHz, MCK/32, for 1.5ms: 3937 */
+ TC_SetRA(tc, channel, 2625); // 1ms
+
+ /* Configure and enable interrupt */
+ NVIC_EnableIRQ(irqn);
+ // TC_IER_CPAS: RA Compare
+ tc->TC_CHANNEL[channel].TC_IER = TC_IER_CPAS;
+
+ // Enables the timer clock and performs a software reset to start the counting
+ TC_Start(tc, channel);
+}
+
+void initISR(timer16_Sequence_t timer) {
+ #ifdef _useTimer1
+ if (timer == _timer1)
+ _initISR(TC_FOR_TIMER1, CHANNEL_FOR_TIMER1, ID_TC_FOR_TIMER1, IRQn_FOR_TIMER1);
+ #endif
+ #ifdef _useTimer2
+ if (timer == _timer2)
+ _initISR(TC_FOR_TIMER2, CHANNEL_FOR_TIMER2, ID_TC_FOR_TIMER2, IRQn_FOR_TIMER2);
+ #endif
+ #ifdef _useTimer3
+ if (timer == _timer3)
+ _initISR(TC_FOR_TIMER3, CHANNEL_FOR_TIMER3, ID_TC_FOR_TIMER3, IRQn_FOR_TIMER3);
+ #endif
+ #ifdef _useTimer4
+ if (timer == _timer4)
+ _initISR(TC_FOR_TIMER4, CHANNEL_FOR_TIMER4, ID_TC_FOR_TIMER4, IRQn_FOR_TIMER4);
+ #endif
+ #ifdef _useTimer5
+ if (timer == _timer5)
+ _initISR(TC_FOR_TIMER5, CHANNEL_FOR_TIMER5, ID_TC_FOR_TIMER5, IRQn_FOR_TIMER5);
+ #endif
+}
+
+void finISR(timer16_Sequence_t timer) {
+ #ifdef _useTimer1
+ TC_Stop(TC_FOR_TIMER1, CHANNEL_FOR_TIMER1);
+ #endif
+ #ifdef _useTimer2
+ TC_Stop(TC_FOR_TIMER2, CHANNEL_FOR_TIMER2);
+ #endif
+ #ifdef _useTimer3
+ TC_Stop(TC_FOR_TIMER3, CHANNEL_FOR_TIMER3);
+ #endif
+ #ifdef _useTimer4
+ TC_Stop(TC_FOR_TIMER4, CHANNEL_FOR_TIMER4);
+ #endif
+ #ifdef _useTimer5
+ TC_Stop(TC_FOR_TIMER5, CHANNEL_FOR_TIMER5);
+ #endif
+}
+
+#endif // HAS_SERVOS
+
+#endif // ARDUINO_ARCH_SAM
+
diff --git a/Marlin/src/HAL/HAL_DUE/endstop_interrupts.h b/Marlin/src/HAL/HAL_DUE/endstop_interrupts.h
new file mode 100644
index 000000000..123519642
--- /dev/null
+++ b/Marlin/src/HAL/HAL_DUE/endstop_interrupts.h
@@ -0,0 +1,75 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ * Endstop Interrupts
+ *
+ * Without endstop interrupts the endstop pins must be polled continually in
+ * the stepper-ISR via endstops.update(), most of the time finding no change.
+ * With this feature endstops.update() is called only when we know that at
+ * least one endstop has changed state, saving valuable CPU cycles.
+ *
+ * This feature only works when all used endstop pins can generate an 'external interrupt'.
+ *
+ * Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'.
+ * (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
+ */
+
+ #ifndef _ENDSTOP_INTERRUPTS_H_
+ #define _ENDSTOP_INTERRUPTS_H_
+
+/**
+ * Endstop interrupts for Due based targets.
+ * On Due, all pins support external interrupt capability.
+ */
+
+void setup_endstop_interrupts(void) {
+ #if HAS_X_MAX
+ attachInterrupt(digitalPinToInterrupt(X_MAX_PIN), endstop_ISR, CHANGE); // assign it
+ #endif
+ #if HAS_X_MIN
+ attachInterrupt(digitalPinToInterrupt(X_MIN_PIN), endstop_ISR, CHANGE);
+ #endif
+ #if HAS_Y_MAX
+ attachInterrupt(digitalPinToInterrupt(Y_MAX_PIN), endstop_ISR, CHANGE);
+ #endif
+ #if HAS_Y_MIN
+ attachInterrupt(digitalPinToInterrupt(Y_MIN_PIN), endstop_ISR, CHANGE);
+ #endif
+ #if HAS_Z_MAX
+ attachInterrupt(digitalPinToInterrupt(Z_MAX_PIN), endstop_ISR, CHANGE);
+ #endif
+ #if HAS_Z_MIN
+ attachInterrupt(digitalPinToInterrupt(Z_MIN_PIN), endstop_ISR, CHANGE);
+ #endif
+ #if HAS_Z2_MAX
+ attachInterrupt(digitalPinToInterrupt(Z2_MAX_PIN), endstop_ISR, CHANGE);
+ #endif
+ #if HAS_Z2_MIN
+ attachInterrupt(digitalPinToInterrupt(Z2_MIN_PIN), endstop_ISR, CHANGE);
+ #endif
+ #if HAS_Z_MIN_PROBE_PIN
+ attachInterrupt(digitalPinToInterrupt(Z_MIN_PROBE_PIN), endstop_ISR, CHANGE);
+ #endif
+}
+
+#endif //_ENDSTOP_INTERRUPTS_H_
diff --git a/Marlin/src/HAL/HAL_DUE/fastio_Due.h b/Marlin/src/HAL/HAL_DUE/fastio_Due.h
new file mode 100644
index 000000000..bc8c14880
--- /dev/null
+++ b/Marlin/src/HAL/HAL_DUE/fastio_Due.h
@@ -0,0 +1,435 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+/**
+ This code contributed by Triffid_Hunter and modified by Kliment
+ why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
+*/
+
+/**
+ * Description: Fast IO functions for Arduino Due and compatible (SAM3X8E)
+ *
+ * For ARDUINO_ARCH_SAM
+ */
+
+#ifndef _FASTIO_DUE_H
+#define _FASTIO_DUE_H
+
+/**
+ utility functions
+*/
+
+#ifndef MASK
+ #define MASK(PIN) (1 << PIN)
+#endif
+
+/**
+ magic I/O routines
+ now you can simply SET_OUTPUT(STEP); WRITE(STEP, 1); WRITE(STEP, 0);
+*/
+
+/// Read a pin
+#define _READ(IO) ((bool)(DIO ## IO ## _WPORT -> PIO_PDSR & (MASK(DIO ## IO ## _PIN))))
+
+/// Write to a pin
+#define _WRITE_VAR(IO, v) do { if (v) {g_APinDescription[IO].pPort->PIO_SODR = g_APinDescription[IO].ulPin; } \
+ else {g_APinDescription[IO].pPort->PIO_CODR = g_APinDescription[IO].ulPin; } \
+ } while (0)
+
+#define _WRITE(IO, v) do { if (v) {DIO ## IO ## _WPORT -> PIO_SODR = MASK(DIO ## IO ##_PIN); } \
+ else {DIO ## IO ## _WPORT -> PIO_CODR = MASK(DIO ## IO ## _PIN); }; \
+ } while (0)
+
+/// toggle a pin
+#define _TOGGLE(IO) _WRITE(IO, !READ(IO))
+
+/// set pin as input
+#define _SET_INPUT(IO) pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
+ PIO_Configure(g_APinDescription[IO].pPort, PIO_INPUT, g_APinDescription[IO].ulPin, 0)
+/// set pin as output
+#define _SET_OUTPUT(IO) PIO_Configure(g_APinDescription[IO].pPort, PIO_OUTPUT_1, \
+ g_APinDescription[IO].ulPin, g_APinDescription[IO].ulPinConfiguration)
+
+/// set pin as input with pullup mode
+#define _PULLUP(IO, v) { pinMode(IO, (v!=LOW ? INPUT_PULLUP : INPUT)); }
+
+/// check if pin is an input
+#define _GET_INPUT(IO)
+/// check if pin is an output
+#define _GET_OUTPUT(IO)
+
+/// check if pin is an timer
+#define _GET_TIMER(IO)
+
+// why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
+
+/// Read a pin wrapper
+#define READ(IO) _READ(IO)
+
+/// Write to a pin wrapper
+#define WRITE_VAR(IO, v) _WRITE_VAR(IO, v)
+#define WRITE(IO, v) _WRITE(IO, v)
+
+/// toggle a pin wrapper
+#define TOGGLE(IO) _TOGGLE(IO)
+
+/// set pin as input wrapper
+#define SET_INPUT(IO) _SET_INPUT(IO)
+/// set pin as input with pullup wrapper
+#define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
+/// set pin as output wrapper
+#define SET_OUTPUT(IO) do{ _SET_OUTPUT(IO); _WRITE(IO, LOW); }while(0)
+
+/// check if pin is an input wrapper
+#define GET_INPUT(IO) _GET_INPUT(IO)
+/// check if pin is an output wrapper
+#define GET_OUTPUT(IO) _GET_OUTPUT(IO)
+
+/// check if pin is an timer wrapper
+#define GET_TIMER(IO) _GET_TIMER(IO)
+
+// Shorthand
+#define OUT_WRITE(IO, v) { SET_OUTPUT(IO); WRITE(IO, v); }
+
+/**
+ ports and functions
+
+ added as necessary or if I feel like it- not a comprehensive list!
+*/
+
+// UART
+#define RXD DIO0
+#define TXD DIO1
+
+// TWI (I2C)
+#define SCL DIO21
+#define SDA DIO20
+
+/**
+pins
+*/
+
+#define DIO0_PIN 8
+#define DIO0_WPORT PIOA
+
+#define DIO1_PIN 9
+#define DIO1_WPORT PIOA
+
+#define DIO2_PIN 25
+#define DIO2_WPORT PIOB
+
+#define DIO3_PIN 28
+#define DIO3_WPORT PIOC
+
+#define DIO4_PIN 26
+#define DIO4_WPORT PIOC
+
+#define DIO5_PIN 25
+#define DIO5_WPORT PIOC
+
+#define DIO6_PIN 24
+#define DIO6_WPORT PIOC
+
+#define DIO7_PIN 23
+#define DIO7_WPORT PIOC
+
+#define DIO8_PIN 22
+#define DIO8_WPORT PIOC
+
+#define DIO9_PIN 21
+#define DIO9_WPORT PIOC
+
+#define DIO10_PIN 29
+#define DIO10_WPORT PIOC
+
+#define DIO11_PIN 7
+#define DIO11_WPORT PIOD
+
+#define DIO12_PIN 8
+#define DIO12_WPORT PIOD
+
+#define DIO13_PIN 27
+#define DIO13_WPORT PIOB
+
+#define DIO14_PIN 4
+#define DIO14_WPORT PIOD
+
+#define DIO15_PIN 5
+#define DIO15_WPORT PIOD
+
+#define DIO16_PIN 13
+#define DIO16_WPORT PIOA
+
+#define DIO17_PIN 12
+#define DIO17_WPORT PIOA
+
+#define DIO18_PIN 11
+#define DIO18_WPORT PIOA
+
+#define DIO19_PIN 10
+#define DIO19_WPORT PIOA
+
+#define DIO20_PIN 12
+#define DIO20_WPORT PIOB
+
+#define DIO21_PIN 13
+#define DIO21_WPORT PIOB
+
+#define DIO22_PIN 26
+#define DIO22_WPORT PIOB
+
+#define DIO23_PIN 14
+#define DIO23_WPORT PIOA
+
+#define DIO24_PIN 15
+#define DIO24_WPORT PIOA
+
+#define DIO25_PIN 0
+#define DIO25_WPORT PIOD
+
+#define DIO26_PIN 1
+#define DIO26_WPORT PIOD
+
+#define DIO27_PIN 2
+#define DIO27_WPORT PIOD
+
+#define DIO28_PIN 3
+#define DIO28_WPORT PIOD
+
+#define DIO29_PIN 6
+#define DIO29_WPORT PIOD
+
+#define DIO30_PIN 9
+#define DIO30_WPORT PIOD
+
+#define DIO31_PIN 7
+#define DIO31_WPORT PIOA
+
+#define DIO32_PIN 10
+#define DIO32_WPORT PIOD
+
+#define DIO33_PIN 1
+#define DIO33_WPORT PIOC
+
+#define DIO34_PIN 2
+#define DIO34_WPORT PIOC
+
+#define DIO35_PIN 3
+#define DIO35_WPORT PIOC
+
+#define DIO36_PIN 4
+#define DIO36_WPORT PIOC
+
+#define DIO37_PIN 5
+#define DIO37_WPORT PIOC
+
+#define DIO38_PIN 6
+#define DIO38_WPORT PIOC
+
+#define DIO39_PIN 7
+#define DIO39_WPORT PIOC
+
+#define DIO40_PIN 8
+#define DIO40_WPORT PIOC
+
+#define DIO41_PIN 9
+#define DIO41_WPORT PIOC
+
+#define DIO42_PIN 19
+#define DIO42_WPORT PIOA
+
+#define DIO43_PIN 20
+#define DIO43_WPORT PIOA
+
+#define DIO44_PIN 19
+#define DIO44_WPORT PIOC
+
+#define DIO45_PIN 18
+#define DIO45_WPORT PIOC
+
+#define DIO46_PIN 17
+#define DIO46_WPORT PIOC
+
+#define DIO47_PIN 16
+#define DIO47_WPORT PIOC
+
+#define DIO48_PIN 15
+#define DIO48_WPORT PIOC
+
+#define DIO49_PIN 14
+#define DIO49_WPORT PIOC
+
+#define DIO50_PIN 13
+#define DIO50_WPORT PIOC
+
+#define DIO51_PIN 12
+#define DIO51_WPORT PIOC
+
+#define DIO52_PIN 21
+#define DIO52_WPORT PIOB
+
+#define DIO53_PIN 14
+#define DIO53_WPORT PIOB
+
+#define DIO54_PIN 16
+#define DIO54_WPORT PIOA
+
+#define DIO55_PIN 24
+#define DIO55_WPORT PIOA
+
+#define DIO56_PIN 23
+#define DIO56_WPORT PIOA
+
+#define DIO57_PIN 22
+#define DIO57_WPORT PIOA
+
+#define DIO58_PIN 6
+#define DIO58_WPORT PIOA
+
+#define DIO59_PIN 4
+#define DIO59_WPORT PIOA
+
+#define DIO60_PIN 3
+#define DIO60_WPORT PIOA
+
+#define DIO61_PIN 2
+#define DIO61_WPORT PIOA
+
+#define DIO62_PIN 17
+#define DIO62_WPORT PIOB
+
+#define DIO63_PIN 18
+#define DIO63_WPORT PIOB
+
+#define DIO64_PIN 19
+#define DIO64_WPORT PIOB
+
+#define DIO65_PIN 20
+#define DIO65_WPORT PIOB
+
+#define DIO66_PIN 15
+#define DIO66_WPORT PIOB
+
+#define DIO67_PIN 16
+#define DIO67_WPORT PIOB
+
+#define DIO68_PIN 1
+#define DIO68_WPORT PIOA
+
+#define DIO69_PIN 0
+#define DIO69_WPORT PIOA
+
+#define DIO70_PIN 17
+#define DIO70_WPORT PIOA
+
+#define DIO71_PIN 18
+#define DIO71_WPORT PIOA
+
+#define DIO72_PIN 30
+#define DIO72_WPORT PIOC
+
+#define DIO73_PIN 21
+#define DIO73_WPORT PIOA
+
+#define DIO74_PIN 25
+#define DIO74_WPORT PIOA
+
+#define DIO75_PIN 26
+#define DIO75_WPORT PIOA
+
+#define DIO76_PIN 27
+#define DIO76_WPORT PIOA
+
+#define DIO77_PIN 28
+#define DIO77_WPORT PIOA
+
+#define DIO78_PIN 23
+#define DIO78_WPORT PIOB
+
+#define DIO79_PIN 17
+#define DIO79_WPORT PIOA
+
+#define DIO80_PIN 12
+#define DIO80_WPORT PIOB
+
+#define DIO81_PIN 8
+#define DIO81_WPORT PIOA
+
+#define DIO82_PIN 11
+#define DIO82_WPORT PIOA
+
+#define DIO83_PIN 13
+#define DIO83_WPORT PIOA
+
+#define DIO84_PIN 4
+#define DIO84_WPORT PIOD
+
+#define DIO85_PIN 11
+#define DIO85_WPORT PIOB
+
+#define DIO86_PIN 21
+#define DIO86_WPORT PIOB
+
+#define DIO87_PIN 29
+#define DIO87_WPORT PIOA
+
+#define DIO88_PIN 15
+#define DIO88_WPORT PIOB
+
+#define DIO89_PIN 14
+#define DIO89_WPORT PIOB
+
+#define DIO90_PIN 1
+#define DIO90_WPORT PIOA
+
+#define DIO91_PIN 15
+#define DIO91_WPORT PIOB
+
+#define DIO92_PIN 5
+#define DIO92_WPORT PIOA
+
+#define DIO93_PIN 12
+#define DIO93_WPORT PIOB
+
+#define DIO94_PIN 22
+#define DIO94_WPORT PIOB
+
+#define DIO95_PIN 23
+#define DIO95_WPORT PIOB
+
+#define DIO96_PIN 24
+#define DIO96_WPORT PIOB
+
+#define DIO97_PIN 20
+#define DIO97_WPORT PIOC
+
+#define DIO98_PIN 27
+#define DIO98_WPORT PIOC
+
+#define DIO99_PIN 10
+#define DIO99_WPORT PIOC
+
+#define DIO100_PIN 11
+#define DIO100_WPORT PIOC
+
+
+#endif // _FASTIO_DUE_H
diff --git a/Marlin/src/HAL/HAL_DUE/persistent_store.cpp b/Marlin/src/HAL/HAL_DUE/persistent_store.cpp
new file mode 100644
index 000000000..ce9336d5c
--- /dev/null
+++ b/Marlin/src/HAL/HAL_DUE/persistent_store.cpp
@@ -0,0 +1,57 @@
+#include "../persistent_store_api.h"
+
+#include "../../../types.h"
+#include "../../../language.h"
+#include "../../../serial.h"
+#include "../../../utility.h"
+
+#ifdef ARDUINO_ARCH_SAM
+#if ENABLED(EEPROM_SETTINGS)
+
+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_START();
+ SERIAL_ECHOLNPGM(MSG_ERR_EEPROM_WRITE);
+ return false;
+ }
+ }
+ crc16(crc, &v, 1);
+ pos++;
+ value++;
+ };
+ return true;
+}
+
+void read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
+ do {
+ uint8_t c = eeprom_read_byte((unsigned char*)pos);
+ *value = c;
+ crc16(crc, &c, 1);
+ pos++;
+ value++;
+ } while (--size);
+}
+
+}
+}
+
+#endif // EEPROM_SETTINGS
+#endif // ARDUINO_ARCH_AVR
diff --git a/Marlin/src/HAL/HAL_DUE/servotimers.h b/Marlin/src/HAL/HAL_DUE/servotimers.h
new file mode 100644
index 000000000..1ba5aaac4
--- /dev/null
+++ b/Marlin/src/HAL/HAL_DUE/servotimers.h
@@ -0,0 +1,91 @@
+/*
+ Copyright (c) 2013 Arduino LLC. All right reserved.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+/**
+ * Defines for 16 bit timers used with Servo library
+ *
+ * If _useTimerX is defined then TimerX is a 32 bit timer on the current board
+ * timer16_Sequence_t enumerates the sequence that the timers should be allocated
+ * _Nbr_16timers indicates how many timers are available.
+ */
+
+/**
+ * SAM Only definitions
+ * --------------------
+ */
+
+// For SAM3X:
+//!#define _useTimer1
+//!#define _useTimer2
+#define _useTimer3
+//!#define _useTimer4
+#define _useTimer5
+
+#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays
+#define PRESCALER 32 // timer prescaler
+
+/*
+ TC0, chan 0 => TC0_Handler
+ TC0, chan 1 => TC1_Handler
+ TC0, chan 2 => TC2_Handler
+ TC1, chan 0 => TC3_Handler
+ TC1, chan 1 => TC4_Handler
+ TC1, chan 2 => TC5_Handler
+ TC2, chan 0 => TC6_Handler
+ TC2, chan 1 => TC7_Handler
+ TC2, chan 2 => TC8_Handler
+ */
+
+#ifdef _useTimer1
+ #define TC_FOR_TIMER1 TC1
+ #define CHANNEL_FOR_TIMER1 0
+ #define ID_TC_FOR_TIMER1 ID_TC3
+ #define IRQn_FOR_TIMER1 TC3_IRQn
+ #define HANDLER_FOR_TIMER1 TC3_Handler
+#endif
+#ifdef _useTimer2
+ #define TC_FOR_TIMER2 TC1
+ #define CHANNEL_FOR_TIMER2 1
+ #define ID_TC_FOR_TIMER2 ID_TC4
+ #define IRQn_FOR_TIMER2 TC4_IRQn
+ #define HANDLER_FOR_TIMER2 TC4_Handler
+#endif
+#ifdef _useTimer3
+ #define TC_FOR_TIMER3 TC1
+ #define CHANNEL_FOR_TIMER3 2
+ #define ID_TC_FOR_TIMER3 ID_TC5
+ #define IRQn_FOR_TIMER3 TC5_IRQn
+ #define HANDLER_FOR_TIMER3 TC5_Handler
+#endif
+#ifdef _useTimer4
+ #define TC_FOR_TIMER4 TC0
+ #define CHANNEL_FOR_TIMER4 2
+ #define ID_TC_FOR_TIMER4 ID_TC2
+ #define IRQn_FOR_TIMER4 TC2_IRQn
+ #define HANDLER_FOR_TIMER4 TC2_Handler
+#endif
+#ifdef _useTimer5
+ #define TC_FOR_TIMER5 TC0
+ #define CHANNEL_FOR_TIMER5 0
+ #define ID_TC_FOR_TIMER5 ID_TC0
+ #define IRQn_FOR_TIMER5 TC0_IRQn
+ #define HANDLER_FOR_TIMER5 TC0_Handler
+#endif
+
+//typedef enum { _timer1, _timer2, _timer3, _timer4, _timer5, _Nbr_16timers } timer16_Sequence_t;
+typedef enum { _timer3, _timer5, _Nbr_16timers } timer16_Sequence_t;
diff --git a/Marlin/src/HAL/HAL_DUE/spi_pins.h b/Marlin/src/HAL/HAL_DUE/spi_pins.h
new file mode 100644
index 000000000..67414710b
--- /dev/null
+++ b/Marlin/src/HAL/HAL_DUE/spi_pins.h
@@ -0,0 +1,56 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+
+#ifndef SPI_PINS_H_
+#define SPI_PINS_H_
+
+/**
+ * Define SPI Pins: SCK, MISO, MOSI, SS
+ *
+ * Available chip select pins for HW SPI are 4 10 52 77
+ */
+#if (SDSS == 4) || (SDSS == 10) || (SDSS == 52) || (SDSS == 77)
+ #if (SDSS == 4)
+ #define SPI_PIN 87
+ #define SPI_CHAN 1
+ #elif (SDSS == 10)
+ #define SPI_PIN 77
+ #define SPI_CHAN 0
+ #elif (SDSS == 52)
+ #define SPI_PIN 86
+ #define SPI_CHAN 2
+ #else
+ #define SPI_PIN 77
+ #define SPI_CHAN 0
+ #endif
+ #define SCK_PIN 76
+ #define MISO_PIN 74
+ #define MOSI_PIN 75
+#else
+ // defaults
+ #define SOFTWARE_SPI
+ #define SCK_PIN 52
+ #define MISO_PIN 50
+ #define MOSI_PIN 51
+#endif
+
+#define SS_PIN SDSS // A.28, A.29, B.21, C.26, C.29
+
+#endif /* SPI_PINS_H_ */
diff --git a/Marlin/src/HAL/HAL_DUE/watchdog_Due.cpp b/Marlin/src/HAL/HAL_DUE/watchdog_Due.cpp
new file mode 100644
index 000000000..00a992d75
--- /dev/null
+++ b/Marlin/src/HAL/HAL_DUE/watchdog_Due.cpp
@@ -0,0 +1,39 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#ifdef ARDUINO_ARCH_SAM
+
+#include "../../../MarlinConfig.h"
+
+#if ENABLED(USE_WATCHDOG)
+
+ #include "watchdog_Due.h"
+
+ void watchdogSetup(void) {
+ // do whatever. don't remove this function.
+ }
+
+ void watchdog_init(void) { watchdogEnable(4000); }
+
+#endif // USE_WATCHDOG
+
+#endif
diff --git a/Marlin/src/HAL/HAL_DUE/watchdog_Due.h b/Marlin/src/HAL/HAL_DUE/watchdog_Due.h
new file mode 100644
index 000000000..1b4c68b01
--- /dev/null
+++ b/Marlin/src/HAL/HAL_DUE/watchdog_Due.h
@@ -0,0 +1,37 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#ifndef WATCHDOG_DUE_H
+#define WATCHDOG_DUE_H
+
+//#include "../../../Marlin.h"
+
+// Arduino Due core now has watchdog support
+
+// Initialize watchdog with a 4 second interrupt time
+void watchdog_init();
+
+// Reset watchdog. MUST be called at least every 4 seconds after the
+// first watchdog_init or AVR will go into emergency procedures.
+inline void watchdog_reset() { watchdogReset(); }
+
+#endif /* WATCHDOG_DUE_H */
diff --git a/platformio.ini b/platformio.ini
index 3d7cff483..beb71cdb8 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -80,3 +80,10 @@ platform = atmelavr
framework = arduino
board = sanguino_atmega644p
lib_deps = ${common.lib_deps}
+
+[env:DUE]
+platform = atmelsam
+framework = arduino
+board = due
+build_flags = -I $BUILDSRC_DIR
+lib_deps = ${common.lib_deps}