Browse Source

Support for Teensy 4 (#19311)

bilsef 3 years ago
parent
commit
049fbc92a9
No account linked to committer's email address

+ 167
- 0
Marlin/src/HAL/TEENSY40_41/HAL.cpp View File

@@ -0,0 +1,167 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * Description: HAL for Teensy40 (IMXRT1062)
25
+ */
26
+
27
+#ifdef __IMXRT1062__
28
+
29
+#include "HAL.h"
30
+#include "../shared/Delay.h"
31
+#include "timers.h"
32
+
33
+#include <Wire.h>
34
+
35
+uint16_t HAL_adc_result, HAL_adc_select;
36
+
37
+static const uint8_t pin2sc1a[] = {
38
+  0x07,  // 0/A0  AD_B1_02
39
+  0x08,  // 1/A1  AD_B1_03
40
+  0x0C,  // 2/A2  AD_B1_07
41
+  0x0B,  // 3/A3  AD_B1_06
42
+  0x06,  // 4/A4  AD_B1_01
43
+  0x05,  // 5/A5  AD_B1_00
44
+  0x0F,  // 6/A6  AD_B1_10
45
+  0x00,  // 7/A7  AD_B1_11
46
+  0x0D,  // 8/A8  AD_B1_08
47
+  0x0E,  // 9/A9  AD_B1_09
48
+  0x01,  // 24/A10 AD_B0_12
49
+  0x02,  // 25/A11 AD_B0_13
50
+  0x83,  // 26/A12 AD_B1_14 - only on ADC2, 3
51
+  0x84,  // 27/A13 AD_B1_15 - only on ADC2, 4
52
+  0x07,  // 14/A0  AD_B1_02
53
+  0x08,  // 15/A1  AD_B1_03
54
+  0x0C,  // 16/A2  AD_B1_07
55
+  0x0B,  // 17/A3  AD_B1_06
56
+  0x06,  // 18/A4  AD_B1_01
57
+  0x05,  // 19/A5  AD_B1_00
58
+  0x0F,  // 20/A6  AD_B1_10
59
+  0x00,  // 21/A7  AD_B1_11
60
+  0x0D,  // 22/A8  AD_B1_08
61
+  0x0E,  // 23/A9  AD_B1_09
62
+  0x01,  // 24/A10 AD_B0_12
63
+  0x02,  // 25/A11 AD_B0_13
64
+  0x83,  // 26/A12 AD_B1_14 - only on ADC2, 3
65
+  0x84,  // 27/A13 AD_B1_15 - only on ADC2, 4
66
+  #ifdef ARDUINO_TEENSY41
67
+    0xFF,  // 28
68
+    0xFF,  // 29
69
+    0xFF,  // 30
70
+    0xFF,  // 31
71
+    0xFF,  // 32
72
+    0xFF,  // 33
73
+    0xFF,  // 34
74
+    0xFF,  // 35
75
+    0xFF,  // 36
76
+    0xFF,  // 37
77
+    0x81,  // 38/A14 AD_B1_12 - only on ADC2, 1
78
+    0x82,  // 39/A15 AD_B1_13 - only on ADC2, 2
79
+    0x09,  // 40/A16 AD_B1_04
80
+    0x0A,  // 41/A17 AD_B1_05
81
+  #endif
82
+};
83
+
84
+/*
85
+// disable interrupts
86
+void cli() { noInterrupts(); }
87
+
88
+// enable interrupts
89
+void sei() { interrupts(); }
90
+*/
91
+
92
+void HAL_adc_init() {
93
+  analog_init();
94
+  while (ADC1_GC & ADC_GC_CAL) ;
95
+  while (ADC2_GC & ADC_GC_CAL) ;
96
+}
97
+
98
+void HAL_clear_reset_source() {
99
+  uint32_t reset_source = SRC_SRSR;
100
+  SRC_SRSR = reset_source;
101
+ }
102
+
103
+uint8_t HAL_get_reset_source() {
104
+  switch (SRC_SRSR & 0xFF) {
105
+    case 1: return RST_POWER_ON; break;
106
+    case 2: return RST_SOFTWARE; break;
107
+    case 4: return RST_EXTERNAL; break;
108
+    // case 8: return RST_BROWN_OUT; break;
109
+    case 16: return RST_WATCHDOG; break;
110
+     case 64: return RST_JTAG; break;
111
+    // case 128: return RST_OVERTEMP; break;
112
+  }
113
+  return 0;
114
+}
115
+
116
+#define __bss_end _ebss
117
+
118
+extern "C" {
119
+  extern char __bss_end;
120
+  extern char __heap_start;
121
+  extern void* __brkval;
122
+
123
+  // Doesn't work on Teensy 4.x
124
+  uint32_t freeMemory() {
125
+    uint32_t free_memory;
126
+    if ((uint32_t)__brkval == 0)
127
+      free_memory = ((uint32_t)&free_memory) - ((uint32_t)&__bss_end);
128
+    else
129
+      free_memory = ((uint32_t)&free_memory) - ((uint32_t)__brkval);
130
+    return free_memory;
131
+  }
132
+}
133
+
134
+void HAL_adc_start_conversion(const uint8_t adc_pin) {
135
+  const uint16_t pin = pin2sc1a[adc_pin];
136
+  if (pin == 0xFF) {
137
+    HAL_adc_select = -1; // Digital only
138
+  }
139
+  else if (pin & 0x80) {
140
+    HAL_adc_select = 1;
141
+    ADC2_HC0 = pin & 0x7F;
142
+  }
143
+  else {
144
+    HAL_adc_select = 0;
145
+    ADC1_HC0 = pin;
146
+  }
147
+}
148
+
149
+uint16_t HAL_adc_get_result() {
150
+  switch (HAL_adc_select) {
151
+    case 0:
152
+      while (!(ADC1_HS & ADC_HS_COCO0)) ; // wait
153
+      return ADC1_R0;
154
+    case 1:
155
+      while (!(ADC2_HS & ADC_HS_COCO0)) ; // wait
156
+      return ADC2_R0;
157
+  }
158
+  return 0;
159
+}
160
+
161
+bool is_output(uint8_t pin) {
162
+  const struct digital_pin_bitband_and_config_table_struct *p;
163
+  p = digital_pin_to_info_PGM + pin;
164
+  return (*(p->reg + 1) & p->mask);
165
+}
166
+
167
+#endif // __IMXRT1062__

+ 180
- 0
Marlin/src/HAL/TEENSY40_41/HAL.h View File

@@ -0,0 +1,180 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ *
4
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
6
+ * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+/**
25
+ * Description: HAL for Teensy 4.0 and Teensy 4.1
26
+ */
27
+
28
+#define CPU_32_BIT
29
+
30
+#include "../shared/Marduino.h"
31
+#include "../shared/math_32bit.h"
32
+#include "../shared/HAL_SPI.h"
33
+
34
+#include "fastio.h"
35
+#include "watchdog.h"
36
+
37
+#include <stdint.h>
38
+#include <util/atomic.h>
39
+
40
+//#define ST7920_DELAY_1 DELAY_NS(600)
41
+//#define ST7920_DELAY_2 DELAY_NS(750)
42
+//#define ST7920_DELAY_3 DELAY_NS(750)
43
+
44
+// ------------------------
45
+// Defines
46
+// ------------------------
47
+
48
+#ifdef __IMXRT1062__
49
+  #define IS_32BIT_TEENSY 1
50
+  #define IS_TEENSY41 1
51
+#endif
52
+
53
+#if SERIAL_PORT == -1
54
+  #define MYSERIAL0 SerialUSB
55
+#elif SERIAL_PORT == 0
56
+  #define MYSERIAL0 Serial
57
+#elif SERIAL_PORT == 1
58
+  #define MYSERIAL0 Serial1
59
+#elif SERIAL_PORT == 2
60
+  #define MYSERIAL0 Serial2
61
+#elif SERIAL_PORT == 3
62
+  #define MYSERIAL0 Serial3
63
+#elif SERIAL_PORT == 4
64
+  #define MYSERIAL0 Serial4
65
+#elif SERIAL_PORT == 5
66
+  #define MYSERIAL0 Serial5
67
+#elif SERIAL_PORT == 6
68
+  #define MYSERIAL0 Serial6
69
+#elif SERIAL_PORT == 7
70
+  #define MYSERIAL0 Serial7
71
+#elif SERIAL_PORT == 8
72
+  #define MYSERIAL0 Serial8
73
+#else
74
+  #error "The required SERIAL_PORT must be from -1 to 8. Please update your configuration."
75
+#endif
76
+
77
+#ifdef SERIAL_PORT_2
78
+  #if SERIAL_PORT_2 == SERIAL_PORT
79
+    #error "SERIAL_PORT_2 must be different from SERIAL_PORT. Please update your configuration."
80
+  #elif SERIAL_PORT_2 == -1
81
+    #define MYSERIAL1 usbSerial
82
+  #elif SERIAL_PORT_2 == 0
83
+    #define MYSERIAL1 Serial
84
+  #elif SERIAL_PORT_2 == 1
85
+    #define MYSERIAL1 Serial1
86
+  #elif SERIAL_PORT_2 == 2
87
+    #define MYSERIAL1 Serial2
88
+  #elif SERIAL_PORT_2 == 3
89
+    #define MYSERIAL1 Serial3
90
+  #elif SERIAL_PORT_2 == 4
91
+    #define MYSERIAL1 Serial4
92
+  #elif SERIAL_PORT_2 == 5
93
+    #define MYSERIAL1 Serial5
94
+  #elif SERIAL_PORT_2 == 6
95
+    #define MYSERIAL1 Serial6
96
+  #elif SERIAL_PORT_2 == 7
97
+    #define MYSERIAL1 Serial7
98
+  #elif SERIAL_PORT_2 == 8
99
+    #define MYSERIAL1 Serial8
100
+  #else
101
+      #error "SERIAL_PORT_2 must be from -1 to 8. Please update your configuration."
102
+  #endif
103
+  #define NUM_SERIAL 2
104
+#else
105
+  #define NUM_SERIAL 1
106
+#endif
107
+
108
+#define HAL_SERVO_LIB libServo
109
+
110
+typedef int8_t pin_t;
111
+
112
+#ifndef analogInputToDigitalPin
113
+  #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
114
+#endif
115
+
116
+#define CRITICAL_SECTION_START()  uint32_t primask = __get_primask(); __disable_irq()
117
+#define CRITICAL_SECTION_END()    if (!primask) __enable_irq()
118
+#define ISRS_ENABLED() (!__get_primask())
119
+#define ENABLE_ISRS()  __enable_irq()
120
+#define DISABLE_ISRS() __disable_irq()
121
+
122
+#undef sq
123
+#define sq(x) ((x)*(x))
124
+
125
+#ifndef strncpy_P
126
+  #define strncpy_P(dest, src, num) strncpy((dest), (src), (num))
127
+#endif
128
+
129
+// Don't place string constants in PROGMEM
130
+#undef PSTR
131
+#define PSTR(str) ({static const char *data = (str); &data[0];})
132
+
133
+// Fix bug in pgm_read_ptr
134
+#undef pgm_read_ptr
135
+#define pgm_read_ptr(addr) (*((void**)(addr)))
136
+// Add type-checking to pgm_read_word
137
+#undef pgm_read_word
138
+#define pgm_read_word(addr) (*((uint16_t*)(addr)))
139
+
140
+// Enable hooks into idle and setup for HAL
141
+#define HAL_IDLETASK 1
142
+FORCE_INLINE void HAL_idletask() {}
143
+FORCE_INLINE void HAL_init() {}
144
+
145
+// Clear reset reason
146
+void HAL_clear_reset_source();
147
+
148
+// Reset reason
149
+uint8_t HAL_get_reset_source();
150
+
151
+FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
152
+
153
+#pragma GCC diagnostic push
154
+#pragma GCC diagnostic ignored "-Wunused-function"
155
+extern "C" {
156
+  uint32_t freeMemory();
157
+}
158
+#pragma GCC diagnostic pop
159
+
160
+// ADC
161
+
162
+void HAL_adc_init();
163
+
164
+#define HAL_ADC_VREF         3.3
165
+#define HAL_ADC_RESOLUTION  10
166
+#define HAL_ADC_FILTERED      // turn off ADC oversampling
167
+#define HAL_START_ADC(pin)  HAL_adc_start_conversion(pin)
168
+#define HAL_READ_ADC()      HAL_adc_get_result()
169
+#define HAL_ADC_READY()     true
170
+
171
+#define HAL_ANALOG_SELECT(pin)
172
+
173
+void HAL_adc_start_conversion(const uint8_t adc_pin);
174
+uint16_t HAL_adc_get_result();
175
+
176
+#define GET_PIN_MAP_PIN(index) index
177
+#define GET_PIN_MAP_INDEX(pin) pin
178
+#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
179
+
180
+bool is_output(uint8_t pin);

+ 138
- 0
Marlin/src/HAL/TEENSY40_41/HAL_SPI.cpp View File

@@ -0,0 +1,138 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#ifdef __IMXRT1062__
23
+
24
+#include "HAL.h"
25
+#include <SPI.h>
26
+#include <pins_arduino.h>
27
+#include "spi_pins.h"
28
+#include "../../core/macros.h"
29
+
30
+static SPISettings spiConfig;
31
+
32
+// ------------------------
33
+// Public functions
34
+// ------------------------
35
+
36
+#if ENABLED(SOFTWARE_SPI)
37
+  // ------------------------
38
+  // Software SPI
39
+  // ------------------------
40
+  #error "Software SPI not supported for Teensy 4. Use Hardware SPI."
41
+#else
42
+
43
+// ------------------------
44
+// Hardware SPI
45
+// ------------------------
46
+
47
+void spiBegin() {
48
+  #ifndef SS_PIN
49
+    #error "SS_PIN is not defined!"
50
+  #endif
51
+
52
+  OUT_WRITE(SS_PIN, HIGH);
53
+
54
+  //SET_OUTPUT(SCK_PIN);
55
+  //SET_INPUT(MISO_PIN);
56
+  //SET_OUTPUT(MOSI_PIN);
57
+
58
+  #if 0 && DISABLED(SOFTWARE_SPI)
59
+    // set SS high - may be chip select for another SPI device
60
+    #if SET_SPI_SS_HIGH
61
+      WRITE(SS_PIN, HIGH);
62
+    #endif
63
+    // set a default rate
64
+    spiInit(SPI_HALF_SPEED); // 1
65
+  #endif
66
+}
67
+
68
+void spiInit(uint8_t spiRate) {
69
+  // Use Marlin data-rates
70
+  uint32_t clock;
71
+  switch (spiRate) {
72
+  case SPI_FULL_SPEED:    clock = 10000000; break;
73
+  case SPI_HALF_SPEED:    clock =  5000000; break;
74
+  case SPI_QUARTER_SPEED: clock =  2500000; break;
75
+  case SPI_EIGHTH_SPEED:  clock =  1250000; break;
76
+  case SPI_SPEED_5:       clock =   625000; break;
77
+  case SPI_SPEED_6:       clock =   312500; break;
78
+  default:
79
+    clock = 4000000; // Default from the SPI libarary
80
+  }
81
+  spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0);
82
+  SPI.begin();
83
+}
84
+
85
+uint8_t spiRec() {
86
+  SPI.beginTransaction(spiConfig);
87
+  uint8_t returnByte = SPI.transfer(0xFF);
88
+  SPI.endTransaction();
89
+  return returnByte;
90
+  //SPDR = 0xFF;
91
+  //while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
92
+  //return SPDR;
93
+}
94
+
95
+void spiRead(uint8_t* buf, uint16_t nbyte) {
96
+  SPI.beginTransaction(spiConfig);
97
+  SPI.transfer(buf, nbyte);
98
+  SPI.endTransaction();
99
+  //if (nbyte-- == 0) return;
100
+  //  SPDR = 0xFF;
101
+  //for (uint16_t i = 0; i < nbyte; i++) {
102
+  //  while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
103
+  //  buf[i] = SPDR;
104
+  //  SPDR = 0xFF;
105
+  //}
106
+  //while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
107
+  //buf[nbyte] = SPDR;
108
+}
109
+
110
+void spiSend(uint8_t b) {
111
+  SPI.beginTransaction(spiConfig);
112
+  SPI.transfer(b);
113
+  SPI.endTransaction();
114
+  //SPDR = b;
115
+  //while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
116
+}
117
+
118
+void spiSendBlock(uint8_t token, const uint8_t* buf) {
119
+  SPI.beginTransaction(spiConfig);
120
+  SPDR = token;
121
+  for (uint16_t i = 0; i < 512; i += 2) {
122
+    while (!TEST(SPSR, SPIF)) { /* nada */ };
123
+    SPDR = buf[i];
124
+    while (!TEST(SPSR, SPIF)) { /* nada */ };
125
+    SPDR = buf[i + 1];
126
+  }
127
+  while (!TEST(SPSR, SPIF)) { /* nada */ };
128
+  SPI.endTransaction();
129
+}
130
+
131
+// Begin SPI transaction, set clock, bit order, data mode
132
+void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) {
133
+  spiConfig = SPISettings(spiClock, bitOrder, dataMode);
134
+  SPI.beginTransaction(spiConfig);
135
+}
136
+
137
+#endif // SOFTWARE_SPI
138
+#endif // __IMXRT1062__

+ 57
- 0
Marlin/src/HAL/TEENSY40_41/Servo.cpp View File

@@ -0,0 +1,57 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#ifdef __IMXRT1062__
23
+
24
+#include "../../inc/MarlinConfig.h"
25
+
26
+#if HAS_SERVOS
27
+
28
+#include "Servo.h"
29
+
30
+int8_t libServo::attach(const int inPin) {
31
+  if (inPin > 0) servoPin = inPin;
32
+  return super::attach(servoPin);
33
+}
34
+
35
+int8_t libServo::attach(const int inPin, const int inMin, const int inMax) {
36
+  if (inPin > 0) servoPin = inPin;
37
+  return super::attach(servoPin, inMin, inMax);
38
+}
39
+
40
+void libServo::move(const int value) {
41
+  constexpr uint16_t servo_delay[] = SERVO_DELAY;
42
+  static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
43
+  if (attach(0) >= 0) {
44
+    write(value);
45
+    safe_delay(servo_delay[servoIndex]);
46
+    TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
47
+  }
48
+}
49
+
50
+void libServo::detach() {
51
+  // PWMServo library does not have detach() function
52
+  //super::detach();
53
+}
54
+
55
+#endif // HAS_SERVOS
56
+
57
+#endif // __IMXRT1062__

+ 39
- 0
Marlin/src/HAL/TEENSY40_41/Servo.h View File

@@ -0,0 +1,39 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include <PWMServo.h>
25
+
26
+// Inherit and expand on core Servo library
27
+class libServo : public PWMServo {
28
+  public:
29
+    int8_t attach(const int pin);
30
+    int8_t attach(const int pin, const int min, const int max);
31
+    void move(const int value);
32
+    void detach(void);
33
+  private:
34
+    typedef PWMServo super;
35
+    uint8_t servoPin;
36
+    uint16_t min_ticks;
37
+    uint16_t max_ticks;
38
+    uint8_t servoIndex; // Index into the channel data for this servo
39
+};

+ 77
- 0
Marlin/src/HAL/TEENSY40_41/eeprom.cpp View File

@@ -0,0 +1,77 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ *
4
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
6
+ * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
7
+ * Copyright (c) 2016 Victor Perez victor_pv@hotmail.com
8
+ *
9
+ * This program is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+#ifdef __IMXRT1062__
24
+
25
+#include "../../inc/MarlinConfig.h"
26
+
27
+#if USE_WIRED_EEPROM
28
+
29
+/**
30
+ * PersistentStore for Arduino-style EEPROM interface
31
+ * with implementations supplied by the framework.
32
+ */
33
+
34
+#include "../shared/eeprom_api.h"
35
+#include <avr/eeprom.h>
36
+
37
+#ifndef MARLIN_EEPROM_SIZE
38
+  #define MARLIN_EEPROM_SIZE size_t(E2END + 1)
39
+#endif
40
+size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }
41
+
42
+bool PersistentStore::access_start()  { return true; }
43
+bool PersistentStore::access_finish() { return true; }
44
+
45
+bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
46
+  while (size--) {
47
+    uint8_t * const p = (uint8_t * const)pos;
48
+    uint8_t v = *value;
49
+    // EEPROM has only ~100,000 write cycles,
50
+    // so only write bytes that have changed!
51
+    if (v != eeprom_read_byte(p)) {
52
+      eeprom_write_byte(p, v);
53
+      if (eeprom_read_byte(p) != v) {
54
+        SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
55
+        return true;
56
+      }
57
+    }
58
+    crc16(crc, &v, 1);
59
+    pos++;
60
+    value++;
61
+  }
62
+  return false;
63
+}
64
+
65
+bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
66
+  do {
67
+    uint8_t c = eeprom_read_byte((uint8_t*)pos);
68
+    if (writing) *value = c;
69
+    crc16(crc, &c, 1);
70
+    pos++;
71
+    value++;
72
+  } while (--size);
73
+  return false;
74
+}
75
+
76
+#endif // USE_WIRED_EEPROM
77
+#endif // __IMXRT1062__

+ 66
- 0
Marlin/src/HAL/TEENSY40_41/endstop_interrupts.h View File

@@ -0,0 +1,66 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+/**
25
+ * Endstop Interrupts
26
+ *
27
+ * Without endstop interrupts the endstop pins must be polled continually in
28
+ * the temperature-ISR via endstops.update(), most of the time finding no change.
29
+ * With this feature endstops.update() is called only when we know that at
30
+ * least one endstop has changed state, saving valuable CPU cycles.
31
+ *
32
+ * This feature only works when all used endstop pins can generate an 'external interrupt'.
33
+ *
34
+ * Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'.
35
+ * (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
36
+ */
37
+
38
+#include "../../module/endstops.h"
39
+
40
+// One ISR for all EXT-Interrupts
41
+void endstop_ISR() { endstops.update(); }
42
+
43
+/**
44
+ * Endstop interrupts for Due based targets.
45
+ * On Due, all pins support external interrupt capability.
46
+ */
47
+void setup_endstop_interrupts() {
48
+  #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
49
+  TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
50
+  TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
51
+  TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
52
+  TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
53
+  TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
54
+  TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
55
+  TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
56
+  TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
57
+  TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
58
+  TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
59
+  TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
60
+  TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
61
+  TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
62
+  TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
63
+  TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
64
+  TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
65
+  TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
66
+}

+ 58
- 0
Marlin/src/HAL/TEENSY40_41/fastio.h View File

@@ -0,0 +1,58 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ * Copyright (c) 2017 Victor Perez
8
+ *
9
+ * This program is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+#pragma once
24
+
25
+/**
26
+ * Fast I/O interfaces for Teensy 4
27
+ * These use GPIO functions instead of Direct Port Manipulation, as on AVR.
28
+ */
29
+
30
+#ifndef PWM
31
+  #define PWM OUTPUT
32
+#endif
33
+
34
+#define READ(IO)                digitalRead(IO)
35
+#define WRITE(IO,V)             digitalWrite(IO,V)
36
+
37
+#define _GET_MODE(IO)           !is_output(IO)
38
+#define _SET_MODE(IO,M)         pinMode(IO, M)
39
+#define _SET_OUTPUT(IO)         pinMode(IO, OUTPUT)                               /*!< Output Push Pull Mode & GPIO_NOPULL   */
40
+
41
+#define OUT_WRITE(IO,V)         do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
42
+
43
+#define SET_INPUT(IO)           _SET_MODE(IO, INPUT)                              /*!< Input Floating Mode                   */
44
+#define SET_INPUT_PULLUP(IO)    _SET_MODE(IO, INPUT_PULLUP)                       /*!< Input with Pull-up activation         */
45
+#define SET_INPUT_PULLDOWN(IO)  _SET_MODE(IO, INPUT_PULLDOWN)                     /*!< Input with Pull-down activation       */
46
+#define SET_OUTPUT(IO)          OUT_WRITE(IO, LOW)
47
+#define SET_PWM(IO)             _SET_MODE(IO, PWM)
48
+
49
+#define TOGGLE(IO)              OUT_WRITE(IO, !READ(IO))
50
+
51
+#define IS_INPUT(IO)            !is_output(IO)
52
+#define IS_OUTPUT(IO)           is_output(IO)
53
+
54
+#define PWM_PIN(P)            digitalPinHasPWM(P)
55
+
56
+// digitalRead/Write wrappers
57
+#define extDigitalRead(IO)    digitalRead(IO)
58
+#define extDigitalWrite(IO,V) digitalWrite(IO,V)

+ 26
- 0
Marlin/src/HAL/TEENSY40_41/inc/Conditionals_LCD.h View File

@@ -0,0 +1,26 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#if HAS_SPI_TFT || HAS_FSMC_TFT
25
+  #error "Sorry! TFT displays are not available for HAL/TEENSY40_41."
26
+#endif

+ 22
- 0
Marlin/src/HAL/TEENSY40_41/inc/Conditionals_adv.h View File

@@ -0,0 +1,22 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once

+ 26
- 0
Marlin/src/HAL/TEENSY40_41/inc/Conditionals_post.h View File

@@ -0,0 +1,26 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#if USE_FALLBACK_EEPROM
25
+  #define USE_WIRED_EEPROM 1
26
+#endif

+ 38
- 0
Marlin/src/HAL/TEENSY40_41/inc/SanityCheck.h View File

@@ -0,0 +1,38 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+/**
25
+ * Test TEENSY41 specific configuration values for errors at compile-time.
26
+ */
27
+
28
+#if ENABLED(EMERGENCY_PARSER)
29
+  #error "EMERGENCY_PARSER is not yet implemented for Teensy 4.0/4.1. Disable EMERGENCY_PARSER to continue."
30
+#endif
31
+
32
+#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY
33
+  #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on Teensy 4.0/4.1."
34
+#endif
35
+
36
+#if HAS_TMC_SW_SERIAL
37
+  #error "TMC220x Software Serial is not supported on this platform."
38
+#endif

+ 146
- 0
Marlin/src/HAL/TEENSY40_41/pinsDebug.h View File

@@ -0,0 +1,146 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
+ *
18
+ */
19
+#pragma once
20
+
21
+#warning "PINS_DEBUGGING is not fully supported for Teensy 4.0 / 4.1 so 'M43' may cause hangs."
22
+
23
+#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
24
+
25
+#define digitalRead_mod(p) extDigitalRead(p)  // AVR digitalRead disabled PWM before it read the pin
26
+#define PRINT_PORT(p)
27
+#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
28
+#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%02d"), p); SERIAL_ECHO(buffer); }while(0)
29
+#define GET_ARRAY_PIN(p) pin_array[p].pin
30
+#define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital
31
+#define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL ? 1 : 0)
32
+#define DIGITAL_PIN_TO_ANALOG_PIN(p) int(p - analogInputToDigitalPin(0))
33
+#define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && (P) <= analogInputToDigitalPin(13)) || ((P) >= analogInputToDigitalPin(14) && (P) <= analogInputToDigitalPin(17))
34
+#define pwm_status(pin) HAL_pwm_status(pin)
35
+#define GET_PINMODE(PIN) (VALID_PIN(pin) && IS_OUTPUT(pin))
36
+#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
37
+
38
+struct pwm_pin_info_struct {
39
+  uint8_t type;    // 0=no pwm, 1=flexpwm, 2=quad
40
+  uint8_t module;  // 0-3, 0-3
41
+  uint8_t channel; // 0=X, 1=A, 2=B
42
+  uint8_t muxval;  //
43
+};
44
+
45
+#define M(a, b) ((((a) - 1) << 4) | (b))
46
+
47
+const struct pwm_pin_info_struct pwm_pin_info[] = {
48
+  {1, M(1, 1), 0, 4},  // FlexPWM1_1_X   0  // AD_B0_03
49
+  {1, M(1, 0), 0, 4},  // FlexPWM1_0_X   1  // AD_B0_02
50
+  {1, M(4, 2), 1, 1},  // FlexPWM4_2_A   2  // EMC_04
51
+  {1, M(4, 2), 2, 1},  // FlexPWM4_2_B   3  // EMC_05
52
+  {1, M(2, 0), 1, 1},  // FlexPWM2_0_A   4  // EMC_06
53
+  {1, M(2, 1), 1, 1},  // FlexPWM2_1_A   5  // EMC_08
54
+  {1, M(2, 2), 1, 2},  // FlexPWM2_2_A   6  // B0_10
55
+  {1, M(1, 3), 2, 6},  // FlexPWM1_3_B   7  // B1_01
56
+  {1, M(1, 3), 1, 6},  // FlexPWM1_3_A   8  // B1_00
57
+  {1, M(2, 2), 2, 2},  // FlexPWM2_2_B   9  // B0_11
58
+  {2, M(1, 0), 0, 1},  // QuadTimer1_0  10  // B0_00
59
+  {2, M(1, 2), 0, 1},  // QuadTimer1_2  11  // B0_02
60
+  {2, M(1, 1), 0, 1},  // QuadTimer1_1  12  // B0_01
61
+  {2, M(2, 0), 0, 1},  // QuadTimer2_0  13  // B0_03
62
+  {2, M(3, 2), 0, 1},  // QuadTimer3_2  14  // AD_B1_02
63
+  {2, M(3, 3), 0, 1},  // QuadTimer3_3  15  // AD_B1_03
64
+  {0, M(1, 0), 0, 0},
65
+  {0, M(1, 0), 0, 0},
66
+  {2, M(3, 1), 0, 1},  // QuadTimer3_1  18  // AD_B1_01
67
+  {2, M(3, 0), 0, 1},  // QuadTimer3_0  19  // AD_B1_00
68
+  {0, M(1, 0), 0, 0},
69
+  {0, M(1, 0), 0, 0},
70
+  {1, M(4, 0), 1, 1},  // FlexPWM4_0_A  22  // AD_B1_08
71
+  {1, M(4, 1), 1, 1},  // FlexPWM4_1_A  23  // AD_B1_09
72
+  {1, M(1, 2), 0, 4},  // FlexPWM1_2_X  24  // AD_B0_12
73
+  {1, M(1, 3), 0, 4},  // FlexPWM1_3_X  25  // AD_B0_13
74
+  {0, M(1, 0), 0, 0},
75
+  {0, M(1, 0), 0, 0},
76
+  {1, M(3, 1), 2, 1},  // FlexPWM3_1_B  28  // EMC_32
77
+  {1, M(3, 1), 1, 1},  // FlexPWM3_1_A  29  // EMC_31
78
+  {0, M(1, 0), 0, 0},
79
+  {0, M(1, 0), 0, 0},
80
+  {0, M(1, 0), 0, 0},
81
+  {1, M(2, 0), 2, 1},  // FlexPWM2_0_B  33  // EMC_07
82
+  #ifdef ARDUINO_TEENSY40
83
+    {1, M(1, 1), 2, 1},  // FlexPWM1_1_B  34  // SD_B0_03
84
+    {1, M(1, 1), 1, 1},  // FlexPWM1_1_A  35  // SD_B0_02
85
+    {1, M(1, 0), 2, 1},  // FlexPWM1_0_B  36  // SD_B0_01
86
+    {1, M(1, 0), 1, 1},  // FlexPWM1_0_A  37  // SD_B0_00
87
+    {1, M(1, 2), 2, 1},  // FlexPWM1_2_B  38  // SD_B0_05
88
+    {1, M(1, 2), 1, 1},  // FlexPWM1_2_A  39  // SD_B0_04
89
+  #endif
90
+  #ifdef ARDUINO_TEENSY41
91
+    {0, M(1, 0), 0, 0},
92
+    {0, M(1, 0), 0, 0},
93
+    {1, M(2, 3), 1, 6},  // FlexPWM2_3_A  36  // B1_00
94
+    {1, M(2, 3), 2, 6},  // FlexPWM2_3_B  37  // B1_01
95
+    {0, M(1, 0), 0, 0},
96
+    {0, M(1, 0), 0, 0},
97
+    {0, M(1, 0), 0, 0},
98
+    {0, M(1, 0), 0, 0},
99
+    {1, M(1, 1), 2, 1},  // FlexPWM1_1_B  42  // SD_B0_03
100
+    {1, M(1, 1), 1, 1},  // FlexPWM1_1_A  43  // SD_B0_02
101
+    {1, M(1, 0), 2, 1},  // FlexPWM1_0_B  44  // SD_B0_01
102
+    {1, M(1, 0), 1, 1},  // FlexPWM1_0_A  45  // SD_B0_00
103
+    {1, M(1, 2), 2, 1},  // FlexPWM1_2_B  46  // SD_B0_05
104
+    {1, M(1, 2), 1, 1},  // FlexPWM1_2_A  47  // SD_B0_04
105
+    {0, M(1, 0), 0, 0},  // duplicate FlexPWM1_0_B
106
+    {0, M(1, 0), 0, 0},  // duplicate FlexPWM1_2_A
107
+    {0, M(1, 0), 0, 0},  // duplicate FlexPWM1_2_B
108
+    {1, M(3, 3), 2, 1},  // FlexPWM3_3_B  51  // EMC_22
109
+    {0, M(1, 0), 0, 0},  // duplicate FlexPWM1_1_B
110
+    {0, M(1, 0), 0, 0},  // duplicate FlexPWM1_1_A
111
+    {1, M(3, 0), 1, 1},  // FlexPWM3_0_A  53  // EMC_29
112
+  #endif
113
+};
114
+
115
+void HAL_print_analog_pin(char buffer[], int8_t pin) {
116
+  if (pin <= 23)      sprintf_P(buffer, PSTR("(A%2d)  "), int(pin - 14));
117
+  else if (pin <= 41) sprintf_P(buffer, PSTR("(A%2d)  "), int(pin - 24));
118
+}
119
+
120
+void HAL_analog_pin_state(char buffer[], int8_t pin) {
121
+  if (pin <= 23)      sprintf_P(buffer, PSTR("Analog in =% 5d"), analogRead(pin - 14));
122
+  else if (pin <= 41) sprintf_P(buffer, PSTR("Analog in =% 5d"), analogRead(pin - 24));
123
+}
124
+
125
+#define PWM_PRINT(V) do{ sprintf_P(buffer, PSTR("PWM:  %4d"), V); SERIAL_ECHO(buffer); }while(0)
126
+
127
+/**
128
+ * Print a pin's PWM status.
129
+ * Return true if it's currently a PWM pin.
130
+ */
131
+bool HAL_pwm_status(int8_t pin) {
132
+  char buffer[20];   // for the sprintf statements
133
+  const struct pwm_pin_info_struct *info;
134
+
135
+  if (pin >= CORE_NUM_DIGITAL) return 0;
136
+  info = pwm_pin_info + pin;
137
+
138
+  if (info->type == 0) return 0;
139
+
140
+  /* TODO decode pwm value from timers */
141
+  // for now just indicate if output is set as pwm
142
+  PWM_PRINT(*(portConfigRegister(pin)) == info->muxval);
143
+  return (*(portConfigRegister(pin)) == info->muxval);
144
+}
145
+
146
+static void pwm_details(uint8_t pin) { /* TODO */ }

+ 27
- 0
Marlin/src/HAL/TEENSY40_41/spi_pins.h View File

@@ -0,0 +1,27 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#define SCK_PIN   13
25
+#define MISO_PIN  12
26
+#define MOSI_PIN  11
27
+#define SS_PIN    20 // SDSS // A.28, A.29, B.21, C.26, C.29

+ 114
- 0
Marlin/src/HAL/TEENSY40_41/timers.cpp View File

@@ -0,0 +1,114 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * Teensy4.0/4.1 (__IMXRT1062__)
25
+ */
26
+
27
+#ifdef __IMXRT1062__
28
+
29
+#include "../../inc/MarlinConfig.h"
30
+
31
+void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
32
+  switch (timer_num) {
33
+    case 0:
34
+      CCM_CSCMR1 &= ~CCM_CSCMR1_PERCLK_CLK_SEL; // turn off 24mhz mode
35
+      CCM_CCGR1 |= CCM_CCGR1_GPT1_BUS(CCM_CCGR_ON);
36
+
37
+      GPT1_CR = 0;                   // disable timer
38
+      GPT1_SR = 0x3F;                // clear all prior status
39
+      GPT1_PR = GPT1_TIMER_PRESCALE - 1;
40
+      GPT1_CR |= GPT_CR_CLKSRC(1);   //clock selection #1 (peripheral clock = 150 MHz)
41
+      GPT1_CR |= GPT_CR_ENMOD;       //reset count to zero before enabling
42
+      GPT1_CR |= GPT_CR_OM1(1);      // toggle mode
43
+      GPT1_OCR1 = (GPT1_TIMER_RATE / frequency) -1; // Initial compare value
44
+      GPT1_IR = GPT_IR_OF1IE;        // Compare3 value
45
+      GPT1_CR |= GPT_CR_EN;          //enable GPT2 counting at 150 MHz
46
+
47
+      OUT_WRITE(15, HIGH);
48
+      attachInterruptVector(IRQ_GPT1, &stepTC_Handler);
49
+      NVIC_SET_PRIORITY(IRQ_GPT1, 16);
50
+      break;
51
+    case 1:
52
+      CCM_CSCMR1 &= ~CCM_CSCMR1_PERCLK_CLK_SEL; // turn off 24mhz mode
53
+      CCM_CCGR0 |= CCM_CCGR0_GPT2_BUS(CCM_CCGR_ON);
54
+
55
+      GPT2_CR = 0;                   // disable timer
56
+      GPT2_SR = 0x3F;                // clear all prior status
57
+      GPT2_PR = GPT2_TIMER_PRESCALE - 1;
58
+      GPT2_CR |= GPT_CR_CLKSRC(1);   //clock selection #1 (peripheral clock = 150 MHz)
59
+      GPT2_CR |= GPT_CR_ENMOD;       //reset count to zero before enabling
60
+      GPT2_CR |= GPT_CR_OM1(1);      // toggle mode
61
+      GPT2_OCR1 = (GPT2_TIMER_RATE / frequency) -1; // Initial compare value
62
+      GPT2_IR = GPT_IR_OF1IE;        // Compare3 value
63
+      GPT2_CR |= GPT_CR_EN;          //enable GPT2 counting at 150 MHz
64
+
65
+      OUT_WRITE(14, HIGH);
66
+      attachInterruptVector(IRQ_GPT2, &tempTC_Handler);
67
+      NVIC_SET_PRIORITY(IRQ_GPT2, 32);
68
+      break;
69
+  }
70
+}
71
+
72
+void HAL_timer_enable_interrupt(const uint8_t timer_num) {
73
+  switch (timer_num) {
74
+    case 0:
75
+      NVIC_ENABLE_IRQ(IRQ_GPT1);
76
+      break;
77
+    case 1:
78
+      NVIC_ENABLE_IRQ(IRQ_GPT2);
79
+      break;
80
+  }
81
+}
82
+
83
+void HAL_timer_disable_interrupt(const uint8_t timer_num) {
84
+  switch (timer_num) {
85
+    case 0: NVIC_DISABLE_IRQ(IRQ_GPT1); break;
86
+    case 1: NVIC_DISABLE_IRQ(IRQ_GPT2); break;
87
+  }
88
+
89
+  // We NEED memory barriers to ensure Interrupts are actually disabled!
90
+  // ( https://dzone.com/articles/nvic-disabling-interrupts-on-arm-cortex-m-and-the )
91
+  asm volatile("dsb");
92
+}
93
+
94
+bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
95
+  switch (timer_num) {
96
+    case 0: return (NVIC_IS_ENABLED(IRQ_GPT1));
97
+    case 1: return (NVIC_IS_ENABLED(IRQ_GPT2));
98
+  }
99
+  return false;
100
+}
101
+
102
+void HAL_timer_isr_prologue(const uint8_t timer_num) {
103
+  switch (timer_num) {
104
+    case 0:
105
+      GPT1_SR = GPT_IR_OF1IE;  // clear OF3 bit
106
+      break;
107
+    case 1:
108
+      GPT2_SR = GPT_IR_OF1IE;  // clear OF3 bit
109
+      break;
110
+  }
111
+  asm volatile("dsb");
112
+}
113
+
114
+#endif // __IMXRT1062__

+ 119
- 0
Marlin/src/HAL/TEENSY40_41/timers.h View File

@@ -0,0 +1,119 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
5
+ * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
+ */
20
+#pragma once
21
+
22
+/**
23
+ * Description: HAL for
24
+ * Teensy4.0/4.1 (__IMXRT1062__)
25
+ */
26
+
27
+#include <stdint.h>
28
+
29
+// ------------------------
30
+// Defines
31
+// ------------------------
32
+
33
+#define FORCE_INLINE __attribute__((always_inline)) inline
34
+
35
+typedef uint32_t hal_timer_t;
36
+#define HAL_TIMER_TYPE_MAX 0xFFFFFFFE
37
+
38
+#define GPT_TIMER_RATE F_BUS_ACTUAL   // 150MHz
39
+
40
+#define GPT1_TIMER_PRESCALE 2
41
+#define GPT2_TIMER_PRESCALE 10
42
+
43
+#define GPT1_TIMER_RATE (GPT_TIMER_RATE / GPT1_TIMER_PRESCALE) // 75MHz
44
+#define GPT2_TIMER_RATE (GPT_TIMER_RATE / GPT2_TIMER_PRESCALE) // 15MHz
45
+
46
+#ifndef STEP_TIMER_NUM
47
+  #define STEP_TIMER_NUM        0  // Timer Index for Stepper
48
+#endif
49
+#ifndef PULSE_TIMER_NUM
50
+  #define PULSE_TIMER_NUM       STEP_TIMER_NUM
51
+#endif
52
+#ifndef TEMP_TIMER_NUM
53
+  #define TEMP_TIMER_NUM        1  // Timer Index for Temperature
54
+#endif
55
+
56
+#define TEMP_TIMER_RATE        1000000
57
+#define TEMP_TIMER_FREQUENCY   1000
58
+
59
+#define STEPPER_TIMER_RATE     GPT1_TIMER_RATE
60
+#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000)
61
+#define STEPPER_TIMER_PRESCALE ((GPT_TIMER_RATE / 1000000) / STEPPER_TIMER_TICKS_PER_US)
62
+
63
+#define PULSE_TIMER_RATE       STEPPER_TIMER_RATE   // frequency of pulse timer
64
+#define PULSE_TIMER_PRESCALE   STEPPER_TIMER_PRESCALE
65
+#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US
66
+
67
+#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(STEP_TIMER_NUM)
68
+#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(STEP_TIMER_NUM)
69
+#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(STEP_TIMER_NUM)
70
+
71
+#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
72
+#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
73
+
74
+#ifndef HAL_STEP_TIMER_ISR
75
+  #define HAL_STEP_TIMER_ISR()  extern "C" void stepTC_Handler() // GPT1_Handler()
76
+#endif
77
+#ifndef HAL_TEMP_TIMER_ISR
78
+  #define HAL_TEMP_TIMER_ISR()  extern "C" void tempTC_Handler() // GPT2_Handler()
79
+#endif
80
+
81
+extern "C" void stepTC_Handler();
82
+extern "C" void tempTC_Handler();
83
+
84
+void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
85
+
86
+FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
87
+  switch (timer_num) {
88
+    case 0:
89
+      GPT1_OCR1 = compare - 1;
90
+      break;
91
+    case 1:
92
+      GPT2_OCR1 = compare - 1;
93
+      break;
94
+  }
95
+}
96
+
97
+FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
98
+  switch (timer_num) {
99
+    case 0: return GPT1_OCR1;
100
+    case 1: return GPT2_OCR1;
101
+  }
102
+  return 0;
103
+}
104
+
105
+FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
106
+  switch (timer_num) {
107
+    case 0: return GPT1_CNT;
108
+    case 1: return GPT2_CNT;
109
+  }
110
+  return 0;
111
+}
112
+
113
+void HAL_timer_enable_interrupt(const uint8_t timer_num);
114
+void HAL_timer_disable_interrupt(const uint8_t timer_num);
115
+bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
116
+
117
+void HAL_timer_isr_prologue(const uint8_t timer_num);
118
+//void HAL_timer_isr_epilogue(const uint8_t timer_num) {}
119
+#define HAL_timer_isr_epilogue(TIMER_NUM)

+ 52
- 0
Marlin/src/HAL/TEENSY40_41/watchdog.cpp View File

@@ -0,0 +1,52 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#ifdef __IMXRT1062__
23
+
24
+#include "../../inc/MarlinConfig.h"
25
+
26
+#if ENABLED(USE_WATCHDOG)
27
+
28
+#include "watchdog.h"
29
+
30
+// 4 seconds timeout
31
+#define WDTO 4 //seconds
32
+
33
+uint8_t timeoutval = (WDTO - 0.5f) / 0.5f;
34
+
35
+void watchdog_init() {
36
+
37
+  CCM_CCGR3 |= CCM_CCGR3_WDOG1(3);  // enable WDOG1 clocks
38
+  WDOG1_WMCR = 0;                   // disable power down PDE
39
+  WDOG1_WCR |= WDOG_WCR_SRS | WDOG_WCR_WT(timeoutval);
40
+  WDOG1_WCR |= WDOG_WCR_WDE | WDOG_WCR_WDT | WDOG_WCR_SRE;
41
+
42
+}
43
+
44
+void HAL_watchdog_refresh() {
45
+  // Watchdog refresh sequence
46
+  WDOG1_WSR = 0x5555;
47
+  WDOG1_WSR = 0xAAAA;
48
+}
49
+
50
+#endif // USE_WATCHDOG
51
+
52
+#endif // __IMXRT1062__

+ 30
- 0
Marlin/src/HAL/TEENSY40_41/watchdog.h View File

@@ -0,0 +1,30 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+/**
25
+ * Watchdog for Teensy4.0/4.1 (__IMXRT1062__)
26
+ */
27
+
28
+void watchdog_init();
29
+
30
+void HAL_watchdog_refresh();

+ 2
- 0
Marlin/src/HAL/platforms.h View File

@@ -31,6 +31,8 @@
31 31
   #define HAL_PATH(PATH, NAME) XSTR(PATH/TEENSY31_32/NAME)
32 32
 #elif defined(__MK64FX512__) || defined(__MK66FX1M0__)
33 33
   #define HAL_PATH(PATH, NAME) XSTR(PATH/TEENSY35_36/NAME)
34
+#elif defined(__IMXRT1062__)
35
+  #define HAL_PATH(PATH, NAME) XSTR(PATH/TEENSY40_41/NAME)
34 36
 #elif defined(TARGET_LPC1768)
35 37
   #define HAL_PATH(PATH, NAME) XSTR(PATH/LPC1768/NAME)
36 38
 #elif defined(__STM32F1__) || defined(TARGET_STM32F1)

+ 13
- 0
Marlin/src/HAL/shared/backtrace/unwmemaccess.cpp View File

@@ -129,6 +129,19 @@
129 129
   #define START_FLASH_ADDR  0x00000000
130 130
   #define END_FLASH_ADDR    0x00140000
131 131
 
132
+#elif defined(__IMXRT1062__)
133
+
134
+  // For IMXRT1062 in TEENSY 4.0/4/1
135
+  //  ITCM (rwx):  ORIGIN = 0x00000000, LENGTH = 512K
136
+  //  DTCM (rwx):  ORIGIN = 0x20000000, LENGTH = 512K
137
+  //  RAM (rwx):   ORIGIN = 0x20200000, LENGTH = 512K
138
+  //  FLASH (rwx): ORIGIN = 0x60000000, LENGTH = 1984K
139
+  //
140
+  #define START_SRAM_ADDR   0x00000000
141
+  #define END_SRAM_ADDR     0x20280000
142
+  #define START_FLASH_ADDR  0x60000000
143
+  #define END_FLASH_ADDR    0x601F0000
144
+
132 145
 #elif defined(__SAMD51P20A__)
133 146
 
134 147
   // For SAMD51x20, valid address ranges are

+ 2
- 0
Marlin/src/HAL/shared/servo.h View File

@@ -71,6 +71,8 @@
71 71
   #include "../TEENSY31_32/Servo.h"
72 72
 #elif IS_TEENSY35 || IS_TEENSY36
73 73
   #include "../TEENSY35_36/Servo.h"
74
+#elif IS_TEENSY40 || IS_TEENSY41
75
+  #include "../TEENSY40_41/Servo.h"
74 76
 #elif defined(TARGET_LPC1768)
75 77
   #include "../LPC1768/Servo.h"
76 78
 #elif defined(__STM32F1__) || defined(TARGET_STM32F1)

+ 5
- 0
Marlin/src/core/boards.h View File

@@ -356,10 +356,13 @@
356 356
 
357 357
 #define BOARD_THE_BORG                5000  // THE-BORG (Power outputs: Hotend0, Hotend1, Bed, Fan)
358 358
 #define BOARD_REMRAM_V1               5001  // RemRam v1
359
+#define BOARD_TEENSY41                5002  // Teensy4.0 and Teensy4.1
360
+#define BOARD_T41U5XBB                5003  // T41U5XBB Teensy4.1 breakout board
359 361
 
360 362
 //
361 363
 // Espressif ESP32 WiFi
362 364
 //
365
+
363 366
 #define BOARD_ESPRESSIF_ESP32         6000  // Generic ESP32
364 367
 #define BOARD_MRR_ESPA                6001  // MRR ESPA board based on ESP32 (native pins only)
365 368
 #define BOARD_MRR_ESPE                6002  // MRR ESPE board based on ESP32 (with I2S stepper stream)
@@ -368,11 +371,13 @@
368 371
 //
369 372
 // SAMD51 ARM Cortex M4
370 373
 //
374
+
371 375
 #define BOARD_AGCM4_RAMPS_144         6100  // RAMPS 1.4.4
372 376
 
373 377
 //
374 378
 // Custom board
375 379
 //
380
+
376 381
 #define BOARD_CUSTOM                  9998  // Custom pins definition for development and/or rare boards
377 382
 
378 383
 //

+ 1
- 1
Marlin/src/libs/private_spi.h View File

@@ -43,7 +43,7 @@ class SPIclass<MISO_PIN, MOSI_PIN, SCK_PIN> {
43 43
       SET_INPUT_PULLUP(MISO_PIN);
44 44
     }
45 45
     FORCE_INLINE static uint8_t receive() {
46
-      #if defined(__AVR__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
46
+      #if defined(__AVR__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1062__)
47 47
         SPDR = 0;
48 48
         for (;!TEST(SPSR, SPIF););
49 49
         return SPDR;

+ 11
- 5
Marlin/src/module/motion.h View File

@@ -108,22 +108,28 @@ extern int16_t feedrate_percentage;
108 108
   extern float e_move_accumulator;
109 109
 #endif
110 110
 
111
-inline float pgm_read_any(const float *p) { return pgm_read_float(p); }
112
-inline signed char pgm_read_any(const signed char *p) { return pgm_read_byte(p); }
111
+#ifdef __IMXRT1062__
112
+  #define DEFS_PROGMEM
113
+#else
114
+  #define DEFS_PROGMEM PROGMEM
115
+#endif
116
+
117
+inline float pgm_read_any(const float *p)   { return TERN(__IMXRT1062__, *p, pgm_read_float(p)); }
118
+inline int8_t pgm_read_any(const int8_t *p) { return TERN(__IMXRT1062__, *p, pgm_read_byte(p)); }
113 119
 
114 120
 #define XYZ_DEFS(T, NAME, OPT) \
115 121
   inline T NAME(const AxisEnum axis) { \
116
-    static const XYZval<T> NAME##_P PROGMEM = { X_##OPT, Y_##OPT, Z_##OPT }; \
122
+    static const XYZval<T> NAME##_P DEFS_PROGMEM = { X_##OPT, Y_##OPT, Z_##OPT }; \
117 123
     return pgm_read_any(&NAME##_P[axis]); \
118 124
   }
119 125
 XYZ_DEFS(float, base_min_pos,   MIN_POS);
120 126
 XYZ_DEFS(float, base_max_pos,   MAX_POS);
121 127
 XYZ_DEFS(float, base_home_pos,  HOME_POS);
122 128
 XYZ_DEFS(float, max_length,     MAX_LENGTH);
123
-XYZ_DEFS(signed char, home_dir, HOME_DIR);
129
+XYZ_DEFS(int8_t, home_dir, HOME_DIR);
124 130
 
125 131
 inline float home_bump_mm(const AxisEnum axis) {
126
-  static const xyz_pos_t home_bump_mm_P PROGMEM = HOMING_BUMP_MM;
132
+  static const xyz_pos_t home_bump_mm_P DEFS_PROGMEM = HOMING_BUMP_MM;
127 133
   return pgm_read_any(&home_bump_mm_P[axis]);
128 134
 }
129 135
 

+ 4
- 0
Marlin/src/pins/pins.h View File

@@ -619,6 +619,10 @@
619 619
   #include "stm32f7/pins_THE_BORG.h"            // STM32F7                                env:STM32F7
620 620
 #elif MB(REMRAM_V1)
621 621
   #include "stm32f7/pins_REMRAM_V1.h"           // STM32F7                                env:STM32F7
622
+#elif MB(TEENSY40_41)
623
+  #include "teensy4/pins_TEENSY41.h"            // Teensy-4.x                             env:teensy41
624
+#elif MB(T41U5XBB)
625
+  #include "teensy4/pins_T41U5XBB.h"            // Teensy-4.x                             env:teensy41
622 626
 
623 627
 //
624 628
 // Espressif ESP32

+ 119
- 0
Marlin/src/pins/teensy4/pins_T41U5XBB.h View File

@@ -0,0 +1,119 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+/****************************************************************************************
25
+* Teensy 4.1 (IMXRT1062) Breadboard pin assignments
26
+* Requires the Teensyduino software with Teensy 4.1 selected in Arduino IDE!
27
+* https://www.pjrc.com/teensy/teensyduino.html
28
+****************************************************************************************/
29
+
30
+#if !IS_32BIT_TEENSY || !IS_TEENSY41
31
+  #error "Oops! Select 'Teensy 4.1' in 'Tools > Board.'"
32
+#else
33
+  #define BOARD_INFO_NAME "Teensy4.1"
34
+#endif
35
+
36
+#define AT90USB          1286  // Disable MarlinSerial etc.
37
+#define USBCON         //1286  // Disable MarlinSerial etc.
38
+/*
39
+
40
+   plan for Teensy4.0 and Teensy4.1:
41
+                                                     USB
42
+                                          GND |-----#####-----| VIN (3.65 TO 5.5V)
43
+      RX1                 CS1     RX1  PWM  0 |     #####     | GND
44
+      TX1                 MISO1   TX1  PWM  1 |               | 3.3V
45
+      STPX                             PWM  2 |               | 23  A9 PWM              
46
+      DIRX                             PWM  3 |               | 22  A8 PWM              LIMZ
47
+      STPY                             PWM  4 |               | 21  A7      RX5         LIMY
48
+      DIRY                             PWM  5 |               | 20  A6      TX5         LIMX
49
+      STPZ                             PWM  6 |               | 19  A5 PWM        SCL0  COOL
50
+      DIRZ                        RX2  PWM  7 |               | 18  A4 PWM        SDA0  MIST
51
+      STPA                        TX2  PWM  8 |               | 17  A3      RX4   SDA1  CYST
52
+      DIRA                             PWM  9 |               | 16  A2      TX4   SCL1  EHOLD
53
+      STEN                             PWM 10 |               | 15  A1 PWM  RX3         PRB
54
+      SPDI                MOSI0        PWM 11 |               | 14  A0 PWM  TX3         PANIC
55
+      SPEN                MISO0        PWM 12 |               | 13 LED PWM  SCK0        SPWM
56
+                                         3.3V |               | GND
57
+      SCL                              PWM 24 |               | 41 A17                  KPSTR
58
+      SDA                              PWM 25 |               | 40 A16                  STENY
59
+      STPB                MOSI1            26 |               | 39 A15      MISO1       STENZ
60
+      DIRB                SCK1             27 | *  *  *  *  * | 38 A14                  STENA
61
+      LIMB                        RX7  PWM 28 |               | 37     PWM              STENB  
62
+      DOOR                        TX7  PWM 29 |               | 36     PWM              ST0
63
+      ST1                                  30 |               | 35          TX8         ST3
64
+      AUX0                                 31 |    SDCARD     | 34          RX8         ST2
65
+      AUX1                                 32 |_______________| 33     PWM              AUX2
66
+
67
+ 
68
+*/
69
+
70
+//
71
+// Limit Switches
72
+//
73
+#define X_STOP_PIN                            20
74
+#define Y_STOP_PIN                            21
75
+#define Z_STOP_PIN                            22
76
+
77
+//
78
+// Steppers
79
+//
80
+#define X_STEP_PIN                             2
81
+#define X_DIR_PIN                              3
82
+#define X_ENABLE_PIN                          10
83
+//#define X_CS_PIN                              30
84
+
85
+#define Y_STEP_PIN                             4
86
+#define Y_DIR_PIN                              5
87
+#define Y_ENABLE_PIN                          40
88
+//#define Y_CS_PIN                              31
89
+
90
+#define Z_STEP_PIN                             6
91
+#define Z_DIR_PIN                              7
92
+#define Z_ENABLE_PIN                          39
93
+//#define Z_CS_PIN                              32
94
+
95
+#define E0_STEP_PIN                            8
96
+#define E0_DIR_PIN                             9
97
+#define E0_ENABLE_PIN                         38
98
+
99
+#define E1_STEP_PIN                           26
100
+#define E1_DIR_PIN                            27
101
+#define E1_ENABLE_PIN                         37
102
+
103
+#define HEATER_0_PIN                          31
104
+#define HEATER_1_PIN                          32
105
+#define HEATER_BED_PIN                        33
106
+
107
+#define TEMP_0_PIN                             5  // Extruder / Analog pin numbering: 2 => A2
108
+#define TEMP_1_PIN                             4
109
+#define TEMP_BED_PIN                          15  // Bed / Analog pin numbering
110
+
111
+#define LED_PIN                               13
112
+
113
+#define SOL0_PIN                              17
114
+#define SERVO0_PIN                            24
115
+#define SERVO1_PIN                            25
116
+
117
+#ifndef SDCARD_CONNECTION
118
+  #define SDCARD_CONNECTION              ONBOARD
119
+#endif

+ 129
- 0
Marlin/src/pins/teensy4/pins_TEENSY41.h View File

@@ -0,0 +1,129 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+/****************************************************************************************
25
+* Teensy 4.1 (IMXRT1062) Breadboard pin assignments
26
+* Requires the Teensyduino software with Teensy 4.1 selected in Arduino IDE!
27
+* https://www.pjrc.com/teensy/teensyduino.html
28
+****************************************************************************************/
29
+
30
+#if !IS_32BIT_TEENSY || !IS_TEENSY41
31
+  #error "Oops! Select 'Teensy 4.1' in 'Tools > Board.'"
32
+#else
33
+  #define BOARD_INFO_NAME "Teensy4.1"
34
+#endif
35
+
36
+#define AT90USB          1286  // Disable MarlinSerial etc.
37
+#define USBCON         //1286  // Disable MarlinSerial etc.
38
+/*
39
+
40
+   plan for Teensy4.0 and Teensy4.1:
41
+                                                     USB
42
+                                          GND |-----#####-----| VIN (3.65 TO 5.5V)
43
+      X_STEP_PIN          CS1     RX1  PWM  0 |     #####     | GND
44
+      X_DIR_PIN           MISO1   TX1  PWM  1 |               | 3.3V
45
+      Y_STEP_PIN                       PWM  2 |               | 23  A9 PWM              SERVO1_PIN
46
+      Y_DIR_PIN                        PWM  3 |               | 22  A8 PWM              SERVO0_PIN
47
+      Z_STEP_PIN                       PWM  4 |               | 21  A7      RX5        
48
+      Z_DIR_PIN                        PWM  5 |               | 20  A6      TX5         FILWIDTH_PIN
49
+      X_ENABLE_PIN                     PWM  6 |               | 19  A5 PWM        SCL0  
50
+      Y_ENABLE_PIN                RX2  PWM  7 |               | 18  A4 PWM        SDA0  HEATER_1_PIN
51
+      Z_ENABLE_PIN                TX2  PWM  8 |               | 17  A3      RX4   SDA1  
52
+      E0_STEP_PIN                      PWM  9 |               | 16  A2      TX4   SCL1  TEMP_0_PIN
53
+      E0_DIR_PIN                       PWM 10 |               | 15  A1 PWM  RX3         TEMP_BED_PIN
54
+      MOSI_PIN            MOSI0        PWM 11 |               | 14  A0 PWM  TX3         TEMP_1_PIN
55
+      MISO_PIN            MISO0        PWM 12 |               | 13 LED PWM  SCK0        SCK_PIN
56
+                                         3.3V |               | GND
57
+      Z_STOP_PIN                       PWM 24 |               | 41 A17                  
58
+      E0_ENABLE_PIN                    PWM 25 |               | 40 A16                  
59
+      FAN_PIN             MOSI1            26 |               | 39 A15      MISO1       X_STOP_PIN
60
+      Z-PROBE PWR         SCK1             27 | *  *  *  *  * | 38 A14                  Y_STOP_PIN
61
+      SOL1_PIN                    RX7  PWM 28 |               | 37     PWM              HEATER_0_PIN  
62
+      FAN_PIN                     TX7  PWM 29 |               | 36     PWM              HEATER_BED_PIN
63
+      X_CS_PIN                             30 |               | 35          TX8         E1_ENABLE_PIN
64
+      y_CS_PIN                             31 |    SDCARD     | 34          RX8         E1_DIR_PIN
65
+      Z_CS_PIN                             32 |_______________| 33     PWM              E1_STEP_PIN
66
+
67
+ 
68
+*/
69
+
70
+//
71
+// Limit Switches
72
+//
73
+#define X_STOP_PIN                            39
74
+#define Y_STOP_PIN                            38
75
+#define Z_STOP_PIN                            24
76
+
77
+//
78
+// Steppers
79
+//
80
+#define X_STEP_PIN                             0
81
+#define X_DIR_PIN                              1
82
+#define X_ENABLE_PIN                           6
83
+//#define X_CS_PIN                              30
84
+
85
+#define Y_STEP_PIN                             2
86
+#define Y_DIR_PIN                              3
87
+#define Y_ENABLE_PIN                           7
88
+//#define Y_CS_PIN                              31
89
+
90
+#define Z_STEP_PIN                             4
91
+#define Z_DIR_PIN                              5
92
+#define Z_ENABLE_PIN                           8
93
+//#define Z_CS_PIN                              32
94
+
95
+#define E0_STEP_PIN                            9
96
+#define E0_DIR_PIN                            10
97
+#define E0_ENABLE_PIN                         25
98
+
99
+#define E1_STEP_PIN                           33
100
+#define E1_DIR_PIN                            34
101
+#define E1_ENABLE_PIN                         35
102
+
103
+#define HEATER_0_PIN                          37
104
+#define HEATER_1_PIN                          18
105
+#define HEATER_BED_PIN                        36
106
+#ifndef FAN_PIN
107
+  #define FAN_PIN                             29
108
+#endif
109
+
110
+#define TEMP_0_PIN                             2  // Extruder / Analog pin numbering: 2 => A2
111
+#define TEMP_1_PIN                             0
112
+#define TEMP_BED_PIN                           1  // Bed / Analog pin numbering
113
+
114
+#define LED_PIN                               13
115
+//#define PS_ON_PIN                              1
116
+//#define ALARM_PIN                             -1
117
+
118
+//#define FILWIDTH_PIN                           6  // A6
119
+#define SOL0_PIN                              28
120
+#define SERVO0_PIN                            22
121
+#define SERVO1_PIN                            23
122
+
123
+//#define SCK_PIN                               13
124
+//#define MISO_PIN                              12
125
+//#define MOSI_PIN                              11
126
+
127
+#ifndef SDCARD_CONNECTION
128
+  #define SDCARD_CONNECTION              ONBOARD
129
+#endif

+ 7
- 0
README.md View File

@@ -96,6 +96,13 @@ Marlin 2.0 introduces a layer of abstraction so that all the existing high-level
96 96
   [Teensy 3.5](https://www.pjrc.com/store/teensy35.html)|[MK64FX512VMD12](https://www.mouser.com/ProductDetail/NXP-Freescale/MK64FX512VMD12) ARM-Cortex M4|120MHz|512k|192k|3.3-5V|yes
97 97
   [Teensy 3.6](https://www.pjrc.com/store/teensy36.html)|[MK66FX1M0VMD18](https://www.mouser.com/ProductDetail/NXP-Freescale/MK66FX1M0VMD18) ARM-Cortex M4|180MHz|1M|256k|3.3V|yes
98 98
 
99
+  #### Teensy 4.0 / 4.1
100
+
101
+  boards|processor|speed|flash|sram|logic|fpu
102
+  ----|---------|-----|-----|----|-----|---
103
+  [Teensy 4.0](https://www.pjrc.com/store/teensy40.html)|[IMXRT1062](https://www.mouser.com/new/nxp-semiconductors/nxp-imx-rt1060-crossover-processor/) ARM-Cortex M7|600MHz|1M|2M|3.3V|yes
104
+  [Teensy 4.1](https://www.pjrc.com/store/teensy41.html)|[IMXRT1062](https://www.mouser.com/new/nxp-semiconductors/nxp-imx-rt1060-crossover-processor/) ARM-Cortex M7|600MHz|1M|2M|3.3V|yes
105
+
99 106
 ## Submitting Patches
100 107
 
101 108
 Proposed patches should be submitted as a Pull Request against the ([bugfix-2.0.x](https://github.com/MarlinFirmware/Marlin/tree/bugfix-2.0.x)) branch.

+ 3
- 1
buildroot/share/git/mftest View File

@@ -48,6 +48,8 @@ case $TESTENV in
48 48
      t32) TESTENV='teensy31' ;;
49 49
      t35) TESTENV='teensy35' ;;
50 50
      t36) TESTENV='teensy35' ;;
51
+     t40) TESTENV='teensy41' ;;
52
+     t41) TESTENV='teensy41' ;;
51 53
 
52 54
 -h|--help)  echo -e "$(basename $0) : Marlin Firmware test, build, and upload\n"
53 55
             echo "Usage: $(basename $0) ................. Select env and test to apply / run"
@@ -56,7 +58,7 @@ case $TESTENV in
56 58
             echo "       $(basename $0) -b [variant] .... Auto-build the specified variant"
57 59
             echo "       $(basename $0) -u [variant] .... Auto-build and upload the specified variant"
58 60
             echo
59
-            echo "env shortcuts: tree due esp lin lpc|lpc8 lpc9 m128 m256|mega stm|f1 f4 f7 s6 teensy|t31|t32 t35|t36"
61
+            echo "env shortcuts: tree due esp lin lpc|lpc8 lpc9 m128 m256|mega stm|f1 f4 f7 s6 teensy|t31|t32 t35|t36 t40|t41"
60 62
             exit
61 63
             ;;
62 64
 

+ 123
- 0
buildroot/tests/teensy41-tests View File

@@ -0,0 +1,123 @@
1
+#!/usr/bin/env bash
2
+#
3
+# Build tests for Teensy 4.0/4.1 (ARM Cortex-M7)
4
+#
5
+
6
+# exit on first failure
7
+set -e
8
+
9
+restore_configs
10
+opt_set MOTHERBOARD BOARD_TEENSY41
11
+exec_test $1 $2 "Teensy4.1 with default config"
12
+
13
+#
14
+# Test as many features together as possible
15
+#
16
+restore_configs
17
+opt_set MOTHERBOARD BOARD_TEENSY41
18
+opt_set EXTRUDERS 2
19
+opt_set TEMP_SENSOR_0 1
20
+opt_set TEMP_SENSOR_1 5
21
+opt_set TEMP_SENSOR_BED 1
22
+opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LCD_INFO_MENU SDSUPPORT SDCARD_SORT_ALPHA \
23
+           FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY CALIBRATION_GCODE BAUD_RATE_GCODE \
24
+           FIX_MOUNTED_PROBE Z_SAFE_HOMING AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
25
+           BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \
26
+           PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT M100_FREE_MEMORY_WATCHER \
27
+           ADVANCED_PAUSE_FEATURE ARC_SUPPORT BEZIER_CURVE_SUPPORT EXPERIMENTAL_I2CBUS EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES PARK_HEAD_ON_PAUSE \
28
+           PHOTO_GCODE PHOTO_POSITION PHOTO_SWITCH_POSITION PHOTO_SWITCH_MS PHOTO_DELAY_MS PHOTO_RETRACT_MM \
29
+           HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT
30
+opt_set I2C_SLAVE_ADDRESS 63
31
+opt_set GRID_MAX_POINTS_X 16
32
+exec_test $1 $2 "Teensy4.1 with many features"
33
+
34
+#
35
+# Test a Sled Z Probe with Linear leveling
36
+#
37
+restore_configs
38
+opt_set MOTHERBOARD BOARD_TEENSY41
39
+opt_enable EEPROM_SETTINGS Z_PROBE_SLED Z_SAFE_HOMING AUTO_BED_LEVELING_LINEAR DEBUG_LEVELING_FEATURE GCODE_MACROS
40
+exec_test $1 $2 "Sled Z Probe with Linear leveling"
41
+
42
+#
43
+# Test a Servo Probe
44
+#
45
+# restore_configs
46
+# opt_set MOTHERBOARD BOARD_TEENSY41
47
+# opt_enable Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE \
48
+#            AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE EEPROM_SETTINGS
49
+# opt_set NUM_SERVOS 1
50
+# exec_test $1 $2 "Servo Probe"
51
+#
52
+# ...with AUTO_BED_LEVELING_3POINT, DEBUG_LEVELING_FEATURE, EEPROM_SETTINGS, EEPROM_CHITCHAT, EXTENDED_CAPABILITIES_REPORT, and AUTO_REPORT_TEMPERATURES
53
+#
54
+# opt_enable AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE EEPROM_SETTINGS \
55
+#            EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES
56
+# exec_test $1 $2 "...with AUTO_BED_LEVELING_3POINT, DEBUG_LEVELING_FEATURE, EEPROM_SETTINGS, EEPROM_CHITCHAT, EXTENDED_CAPABILITIES_REPORT, and AUTO_REPORT_TEMPERATURES"
57
+
58
+#
59
+# Test MAGNETIC_PARKING_EXTRUDER with LCD
60
+#
61
+restore_configs
62
+opt_set MOTHERBOARD BOARD_TEENSY41
63
+opt_set EXTRUDERS 2
64
+opt_set TEMP_SENSOR_1 1
65
+opt_enable MAGNETIC_PARKING_EXTRUDER ULTIMAKERCONTROLLER
66
+exec_test $1 $2 "MAGNETIC_PARKING_EXTRUDER with LCD"
67
+
68
+#
69
+# Mixing Extruder
70
+#
71
+restore_configs
72
+opt_set MOTHERBOARD BOARD_TEENSY41
73
+opt_enable MIXING_EXTRUDER DIRECT_MIXING_IN_G1 GRADIENT_MIX GRADIENT_VTOOL REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
74
+opt_set MIXING_STEPPERS 2
75
+exec_test $1 $2 "Mixing Extruder"
76
+
77
+#
78
+# Test SWITCHING_EXTRUDER
79
+#
80
+# restore_configs
81
+# opt_set MOTHERBOARD BOARD_TEENSY41
82
+# opt_set EXTRUDERS 2
83
+# opt_set NUM_SERVOS 1
84
+# opt_enable SWITCHING_EXTRUDER ULTIMAKERCONTROLLER
85
+# exec_test $1 $2 "SWITCHING_EXTRUDER"
86
+
87
+#
88
+# Enable COREXY
89
+#
90
+restore_configs
91
+opt_set MOTHERBOARD BOARD_TEENSY41
92
+opt_enable COREXY
93
+opt_set X_DRIVER_TYPE TMC5160
94
+opt_set Y_DRIVER_TYPE TMC5160
95
+opt_set X_MIN_ENDSTOP_INVERTING true
96
+opt_set Y_MIN_ENDSTOP_INVERTING true
97
+opt_add X_CS_PIN 46
98
+opt_add Y_CS_PIN 47
99
+opt_enable USE_ZMIN_PLUG MONITOR_DRIVER_STATUS SENSORLESS_HOMING
100
+exec_test $1 $2 "Teensy 4.0/4.1 COREXY"
101
+
102
+#
103
+# Enable COREXZ
104
+#
105
+restore_configs
106
+opt_set MOTHERBOARD BOARD_TEENSY41
107
+opt_enable COREXZ
108
+exec_test $1 $2 "Teensy 4.0/4.1 COREXZ"
109
+
110
+#
111
+# Enable Dual Z with Dual Z endstops
112
+#
113
+restore_configs
114
+opt_set MOTHERBOARD BOARD_TEENSY41
115
+opt_enable Z_MULTI_ENDSTOPS
116
+opt_set NUM_Z_STEPPER_DRIVERS 2
117
+pins_set ramps/RAMPS X_MAX_PIN -1
118
+opt_add Z2_MAX_PIN 2
119
+opt_enable USE_XMAX_PLUG
120
+exec_test $1 $2 "Dual Z with Dual Z endstops"
121
+
122
+# Clean up
123
+restore_configs

+ 13
- 0
platformio.ini View File

@@ -1264,6 +1264,19 @@ platform      = teensy
1264 1264
 board         = teensy35
1265 1265
 src_filter    = ${common.default_src_filter} +<src/HAL/TEENSY35_36>
1266 1266
 
1267
+[env:teensy36]
1268
+platform      = teensy
1269
+board         = teensy36
1270
+src_filter    = ${common.default_src_filter} +<src/HAL/TEENSY35_36>
1271
+
1272
+#
1273
+# Teensy 4.0 / 4.1 (ARM Cortex-M7)
1274
+#
1275
+[env:teensy41]
1276
+platform      = teensy
1277
+board         = teensy41
1278
+src_filter    = ${common.default_src_filter} +<src/HAL/TEENSY40_41>
1279
+
1267 1280
 #
1268 1281
 # Native
1269 1282
 # No supported Arduino libraries, base Marlin only

Loading…
Cancel
Save