Browse Source

Printrboard G2 support (#13116)

Bob Kuhn 5 years ago
parent
commit
ddbe4cfa20

+ 145
- 0
Marlin/src/HAL/HAL_DUE/G2_PWM.cpp View File

@@ -0,0 +1,145 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * The PWM module is only used to generate interrupts at specified times. It
25
+ * is NOT used to directly toggle pins. The ISR writes to the pin assigned to
26
+ * that interrupt.
27
+ *
28
+ * All PWMs use the same repetition rate.  The G2 needs about 10KHz min in order to
29
+ * not have obvious ripple on the Vref signals.
30
+ *
31
+ * The data structures are setup to minimize the computation done by the ISR which
32
+ * minimizes ISR execution time.  Execution times are 0.8 to 1.1 microseconds.
33
+ *
34
+ * FIve PWM interrupt sources are used.  Channel 0 sets the base period.  All Vref
35
+ * signals are set active when this counter overflows and resets to zero.  The compare
36
+ * values in channels 1-4 are set to give the desired duty cycle for that Vref pin.
37
+ * When counter 0 matches the compare value then that channel generates an interrupt.
38
+ * The ISR checks the source of the interrupt and sets the corresponding pin inactive.
39
+ *
40
+ * Some jitter in the Vref signal is OK so the interrupt priority is left at its default value.
41
+ */
42
+
43
+#include "../../inc/MarlinConfig.h"
44
+
45
+#if MB(PRINTRBOARD_G2)
46
+
47
+#include "G2_PWM.h"
48
+
49
+volatile uint32_t *SODR_A = &PIOA->PIO_SODR,
50
+                  *SODR_B = &PIOB->PIO_SODR,
51
+                  *CODR_A = &PIOA->PIO_CODR,
52
+                  *CODR_B = &PIOB->PIO_CODR;
53
+
54
+PWM_map ISR_table[NUM_PWMS] = PWM_MAP_INIT;
55
+
56
+void Stepper::digipot_init() {
57
+
58
+  OUT_WRITE(MOTOR_CURRENT_PWM_X_PIN, 0);  // init pins
59
+  OUT_WRITE(MOTOR_CURRENT_PWM_Y_PIN, 0);
60
+  OUT_WRITE(MOTOR_CURRENT_PWM_Z_PIN, 0);
61
+  OUT_WRITE(MOTOR_CURRENT_PWM_E_PIN, 0);
62
+
63
+  #define WPKEY          (0x50574D << 8) // “PWM” in ASCII
64
+  #define WPCMD_DIS_SW   0  // command to disable Write Protect SW
65
+  #define WPRG_ALL       (PWM_WPCR_WPRG0 | PWM_WPCR_WPRG1 | PWM_WPCR_WPRG2 | PWM_WPCR_WPRG3 | PWM_WPCR_WPRG4 | PWM_WPCR_WPRG5)  // all Write Protect Groups
66
+
67
+  #define PWM_CLOCK_F    F_CPU / 1000000UL   // set clock to 1MHz
68
+
69
+  PMC->PMC_PCER1 = PMC_PCER1_PID36;                       // enable PWM controller clock (disabled on power up)
70
+
71
+  PWM->PWM_WPCR = WPKEY | WPRG_ALL | WPCMD_DIS_SW;        // enable setting of all PWM registers
72
+  PWM->PWM_CLK = PWM_CLOCK_F;                             // enable CLK_A and set it to 1MHz, leave CLK_B disabled
73
+  PWM->PWM_CH_NUM[0].PWM_CMR = 0b1011;                    // set channel 0 to Clock A input & to left aligned
74
+  PWM->PWM_CH_NUM[1].PWM_CMR = 0b1011;                    // set channel 1 to Clock A input & to left aligned
75
+  PWM->PWM_CH_NUM[2].PWM_CMR = 0b1011;                    // set channel 2 to Clock A input & to left aligned
76
+  PWM->PWM_CH_NUM[3].PWM_CMR = 0b1011;                    // set channel 3 to Clock A input & to left aligned
77
+  PWM->PWM_CH_NUM[4].PWM_CMR = 0b1011;                    // set channel 4 to Clock A input & to left aligned
78
+
79
+  PWM->PWM_CH_NUM[0].PWM_CPRD = PWM_PERIOD_US;            // set channel 0 Period
80
+
81
+  PWM->PWM_IER2 = PWM_IER1_CHID0;                         // generate interrupt when counter0 overflows
82
+  PWM->PWM_IER2 = PWM_IER2_CMPM0 | PWM_IER2_CMPM1 | PWM_IER2_CMPM2 | PWM_IER2_CMPM3 | PWM_IER2_CMPM4;        // generate interrupt on compare event
83
+
84
+  PWM->PWM_CMP[1].PWM_CMPV = 0x010000000LL | G2_VREF_COUNT(G2_VREF(motor_current_setting[0]));   // interrupt when counter0 == CMPV - used to set Motor 1 PWM inactive
85
+  PWM->PWM_CMP[2].PWM_CMPV = 0x010000000LL | G2_VREF_COUNT(G2_VREF(motor_current_setting[0]));   // interrupt when counter0 == CMPV - used to set Motor 2 PWM inactive
86
+  PWM->PWM_CMP[3].PWM_CMPV = 0x010000000LL | G2_VREF_COUNT(G2_VREF(motor_current_setting[1]));   // interrupt when counter0 == CMPV - used to set Motor 3 PWM inactive
87
+  PWM->PWM_CMP[4].PWM_CMPV = 0x010000000LL | G2_VREF_COUNT(G2_VREF(motor_current_setting[2]));   // interrupt when counter0 == CMPV - used to set Motor 4 PWM inactive
88
+
89
+  PWM->PWM_CMP[1].PWM_CMPM = 0x0001;  // enable compare event
90
+  PWM->PWM_CMP[2].PWM_CMPM = 0x0001;  // enable compare event
91
+  PWM->PWM_CMP[3].PWM_CMPM = 0x0001;  // enable compare event
92
+  PWM->PWM_CMP[4].PWM_CMPM = 0x0001;  // enable compare event
93
+
94
+  PWM->PWM_SCM = PWM_SCM_UPDM_MODE0 | PWM_SCM_SYNC0 | PWM_SCM_SYNC1 | PWM_SCM_SYNC2 | PWM_SCM_SYNC3 | PWM_SCM_SYNC4; // sync 1-4 with 0, use mode 0 for updates
95
+
96
+  PWM->PWM_ENA = PWM_ENA_CHID0 | PWM_ENA_CHID1 | PWM_ENA_CHID2 | PWM_ENA_CHID3 | PWM_ENA_CHID4;         // enable the channels used by G2
97
+  PWM->PWM_IER1 = PWM_IER1_CHID0 | PWM_IER1_CHID1 | PWM_IER1_CHID2 | PWM_IER1_CHID3 | PWM_IER1_CHID4;        // enable interrupts for the channels used by G2
98
+
99
+  NVIC_EnableIRQ(PWM_IRQn);     // Enable interrupt handler
100
+  NVIC_SetPriority(PWM_IRQn, NVIC_EncodePriority(0, 10, 0));  // normal priority for PWM module (can stand some jitter on the Vref signals)
101
+}
102
+
103
+void Stepper::digipot_current(const uint8_t driver, const int16_t current) {
104
+
105
+  if (!(PWM->PWM_CH_NUM[0].PWM_CPRD == PWM_PERIOD_US)) digipot_init();  // Init PWM system if needed
106
+
107
+  switch (driver) {
108
+    case 0: PWM->PWM_CMP[1].PWM_CMPVUPD = 0x010000000LL | G2_VREF_COUNT(G2_VREF(current));    // update X & Y
109
+            PWM->PWM_CMP[2].PWM_CMPVUPD = 0x010000000LL | G2_VREF_COUNT(G2_VREF(current));
110
+            PWM->PWM_CMP[1].PWM_CMPMUPD = 0x0001;  // enable compare event
111
+            PWM->PWM_CMP[2].PWM_CMPMUPD = 0x0001;  // enable compare event
112
+            PWM->PWM_SCUC = PWM_SCUC_UPDULOCK; // tell the PWM controller to update the values on the next cycle
113
+            break;
114
+    case 1: PWM->PWM_CMP[3].PWM_CMPVUPD = 0x010000000LL | G2_VREF_COUNT(G2_VREF(current));    // update Z
115
+            PWM->PWM_CMP[3].PWM_CMPMUPD = 0x0001;  // enable compare event
116
+            PWM->PWM_SCUC = PWM_SCUC_UPDULOCK; // tell the PWM controller to update the values on the next cycle
117
+            break;
118
+    default:PWM->PWM_CMP[4].PWM_CMPVUPD = 0x010000000LL | G2_VREF_COUNT(G2_VREF(current));    // update E
119
+            PWM->PWM_CMP[4].PWM_CMPMUPD = 0x0001;  // enable compare event
120
+            PWM->PWM_SCUC = PWM_SCUC_UPDULOCK; // tell the PWM controller to update the values on the next cycle
121
+            break;
122
+  }
123
+}
124
+
125
+volatile uint32_t PWM_ISR1_STATUS, PWM_ISR2_STATUS;
126
+
127
+void PWM_Handler() {
128
+  PWM_ISR1_STATUS = PWM->PWM_ISR1;
129
+  PWM_ISR2_STATUS = PWM->PWM_ISR2;
130
+  if (PWM_ISR1_STATUS & PWM_IER1_CHID0) {                           // CHAN_0 interrupt
131
+    *ISR_table[0].set_register = ISR_table[0].write_mask;                                          // set X to active
132
+    *ISR_table[1].set_register = ISR_table[1].write_mask;                                          // set Y to active
133
+    *ISR_table[2].set_register = ISR_table[2].write_mask;                                          // set Z to active
134
+    *ISR_table[3].set_register = ISR_table[3].write_mask;                                          // set E to active
135
+  }
136
+  else {
137
+    if (PWM_ISR2_STATUS & PWM_IER2_CMPM1)  *ISR_table[0].clr_register = ISR_table[0].write_mask;   // set X to inactive
138
+    if (PWM_ISR2_STATUS & PWM_IER2_CMPM2)  *ISR_table[1].clr_register = ISR_table[1].write_mask;   // set Y to inactive
139
+    if (PWM_ISR2_STATUS & PWM_IER2_CMPM3)  *ISR_table[2].clr_register = ISR_table[2].write_mask;   // set Z to inactive
140
+    if (PWM_ISR2_STATUS & PWM_IER2_CMPM4)  *ISR_table[3].clr_register = ISR_table[3].write_mask;   // set E to inactive
141
+  }
142
+  return;
143
+}
144
+
145
+#endif // PRINTRBOARD_G2

+ 77
- 0
Marlin/src/HAL/HAL_DUE/G2_PWM.h View File

@@ -0,0 +1,77 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * This module is stripped down version of the LPC1768_PWM.h file from
25
+ * PR #7500. It is hardwired for the PRINTRBOARD_G2 Motor Current needs.
26
+ */
27
+
28
+#include "../../inc/MarlinConfigPre.h"
29
+#include "../../module/stepper.h"
30
+//C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\module\stepper.h
31
+//C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\HAL\HAL_DUE\G2_PWM.h
32
+
33
+#define PWM_PERIOD_US  100  // base repetition rate in micro seconds
34
+
35
+typedef struct {       // holds the data needed by the ISR to control the Vref pin
36
+  volatile uint32_t* set_register;
37
+  volatile uint32_t* clr_register;
38
+  uint32_t write_mask;
39
+} PWM_map;
40
+
41
+#define G2_VREF(I) (uint32_t)(I * 5 * 0.15)   // desired Vref * 1000 (scaled so don't loose accuracy in next step)
42
+
43
+#define G2_VREF_COUNT(Q) (uint32_t)map(constrain(Q, 500, 3.3 * 1000), 0, 3.3 * 1000, 0, PWM_PERIOD_US)  // under 500  the results are very non-linear
44
+
45
+extern volatile uint32_t *SODR_A, *SODR_B, *CODR_A, *CODR_B;
46
+
47
+#define _PIN(IO) (DIO ## IO ## _PIN)
48
+
49
+#define PWM_MAP_INIT_ROW(IO,ZZ) { ZZ == 'A' ? SODR_A : SODR_B,  ZZ == 'A' ? CODR_A : CODR_B, 1 << _PIN(IO) }
50
+
51
+
52
+#define PWM_MAP_INIT {  PWM_MAP_INIT_ROW(MOTOR_CURRENT_PWM_X_PIN, 'B'), \
53
+                        PWM_MAP_INIT_ROW(MOTOR_CURRENT_PWM_Y_PIN, 'B'), \
54
+                        PWM_MAP_INIT_ROW(MOTOR_CURRENT_PWM_Z_PIN, 'B'), \
55
+                        PWM_MAP_INIT_ROW(MOTOR_CURRENT_PWM_E_PIN, 'A'), \
56
+                     };
57
+
58
+#define NUM_PWMS 4
59
+
60
+extern PWM_map ISR_table[NUM_PWMS];
61
+
62
+extern uint32_t motor_current_setting[3];
63
+
64
+#define IR_BIT(p) (WITHIN(p, 0, 3) ? (p) : (p) + 4)
65
+#define COPY_ACTIVE_TABLE() do{ for (uint8_t i = 0; i < 6 ; i++) work_table[i] = active_table[i]; }while(0)
66
+
67
+#define PWM_MR0 19999         // base repetition rate minus one count - 20mS
68
+#define PWM_PR 24             // prescaler value - prescaler divide by 24 + 1  -  1 MHz output
69
+#define PWM_PCLKSEL0 0x00     // select clock source for prescaler - defaults to 25MHz on power up
70
+                              // 0: 25MHz, 1: 100MHz, 2: 50MHz, 3: 12.5MHZ to PWM1 prescaler
71
+#define MR0_MARGIN 200        // if channel value too close to MR0 the system locks up
72
+
73
+extern bool PWM_table_swap;   // flag to tell the ISR that the tables have been swapped
74
+
75
+#define HAL_G2_PWM_ISR  void PWM_Handler()
76
+
77
+extern volatile uint32_t PWM_ISR1_STATUS, PWM_ISR2_STATUS;

+ 278
- 0
Marlin/src/HAL/HAL_DUE/G2_pins.h View File

@@ -0,0 +1,278 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include <stdint.h>
25
+
26
+/**
27
+ * This file contains the custom port/pin definitions for the PRINTRBOARD_G2
28
+ * motherboard. This motherboard uses the SAM3X8C which is a subset of the
29
+ * SAM3X8E used in the DUE board.  It uses port/pin pairs that are not
30
+ * available using the DUE definitions.
31
+ *
32
+ * The first part is a copy of the pin descriptions in the
33
+ * "variants\arduino_due_x\variant.cpp" file but with pins 34-41 replaced by
34
+ * the G2 pins.
35
+ *
36
+ * The second part is the FASTIO port/pin definitions.
37
+ *
38
+ * THESE PINS CAN ONLY BE ACCESSED VIA FASTIO COMMANDS.
39
+ */
40
+
41
+/*
42
+  Copyright (c) 2011 Arduino.  All right reserved.
43
+
44
+  This library is free software; you can redistribute it and/or
45
+  modify it under the terms of the GNU Lesser General Public
46
+  License as published by the Free Software Foundation; either
47
+  version 2.1 of the License, or (at your option) any later version.
48
+
49
+  This library is distributed in the hope that it will be useful,
50
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
51
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
52
+  See the GNU Lesser General Public License for more details.
53
+
54
+  You should have received a copy of the GNU Lesser General Public
55
+  License along with this library; if not, write to the Free Software
56
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
57
+*/
58
+
59
+typedef struct _G2_PinDescription {
60
+  Pio* pPort;
61
+  uint32_t ulPin;
62
+  uint32_t ulPeripheralId;
63
+  EPioType ulPinType;
64
+  uint32_t ulPinConfiguration;
65
+  uint32_t ulPinAttribute;
66
+  EAnalogChannel ulAnalogChannel; /* Analog pin in the Arduino context (label on the board) */
67
+  EAnalogChannel ulADCChannelNumber; /* ADC Channel number in the SAM device */
68
+  EPWMChannel ulPWMChannel;
69
+  ETCChannel ulTCChannel;
70
+} G2_PinDescription;
71
+
72
+/**
73
+ * This section is a copy of the pin descriptions in the "variants\arduino_due_x\variant.cpp" file
74
+ * with pins 34-41 replaced by the G2 pins.
75
+ */
76
+
77
+/**
78
+ * Pins descriptions
79
+ */
80
+const G2_PinDescription G2_g_APinDescription[] = {
81
+  // 0 .. 53 - Digital pins
82
+  // ----------------------
83
+  // 0/1 - UART (Serial)
84
+  { PIOA, PIO_PA8A_URXD,     ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT,  PIN_ATTR_DIGITAL,                 NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // URXD
85
+  { PIOA, PIO_PA9A_UTXD,     ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT,  PIN_ATTR_DIGITAL,                 NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // UTXD
86
+
87
+  // 2
88
+  { PIOB, PIO_PB25B_TIOA0,   ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM,  TC0_CHA0     }, // TIOA0
89
+  { PIOC, PIO_PC28B_TIOA7,   ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM,  TC2_CHA7     }, // TIOA7
90
+  { PIOC, PIO_PC26B_TIOB6,   ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM,  TC2_CHB6     }, // TIOB6
91
+
92
+  // 5
93
+  { PIOC, PIO_PC25B_TIOA6,   ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM,  TC2_CHA6     }, // TIOA6
94
+  { PIOC, PIO_PC24B_PWML7,   ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM),   NO_ADC, NO_ADC, PWM_CH7,     NOT_ON_TIMER }, // PWML7
95
+  { PIOC, PIO_PC23B_PWML6,   ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM),   NO_ADC, NO_ADC, PWM_CH6,     NOT_ON_TIMER }, // PWML6
96
+  { PIOC, PIO_PC22B_PWML5,   ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM),   NO_ADC, NO_ADC, PWM_CH5,     NOT_ON_TIMER }, // PWML5
97
+  { PIOC, PIO_PC21B_PWML4,   ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM),   NO_ADC, NO_ADC, PWM_CH4,     NOT_ON_TIMER }, // PWML4
98
+  // 10
99
+  { PIOC, PIO_PC29B_TIOB7,   ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM,  TC2_CHB7     }, // TIOB7
100
+  { PIOD, PIO_PD7B_TIOA8,    ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM,  TC2_CHA8     }, // TIOA8
101
+  { PIOD, PIO_PD8B_TIOB8,    ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM,  TC2_CHB8     }, // TIOB8
102
+
103
+  // 13 - AMBER LED
104
+  { PIOB, PIO_PB27B_TIOB0,   ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM,  TC0_CHB0     }, // TIOB0
105
+
106
+  // 14/15 - USART3 (Serial3)
107
+  { PIOD, PIO_PD4B_TXD3,     ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // TXD3
108
+  { PIOD, PIO_PD5B_RXD3,     ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // RXD3
109
+
110
+  // 16/17 - USART1 (Serial2)
111
+  { PIOA, PIO_PA13A_TXD1,    ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // TXD1
112
+  { PIOA, PIO_PA12A_RXD1,    ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // RXD1
113
+
114
+  // 18/19 - USART0 (Serial1)
115
+  { PIOA, PIO_PA11A_TXD0,    ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // TXD0
116
+  { PIOA, PIO_PA10A_RXD0,    ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // RXD0
117
+
118
+  // 20/21 - TWI1
119
+  { PIOB, PIO_PB12A_TWD1,    ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // TWD1 - SDA0
120
+  { PIOB, PIO_PB13A_TWCK1,   ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // TWCK1 - SCL0
121
+
122
+  // 22
123
+  { PIOB, PIO_PB26,          ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 22
124
+  { PIOA, PIO_PA14,          ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 23
125
+  { PIOA, PIO_PA15,          ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 24
126
+  { PIOD, PIO_PD0,           ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 25
127
+
128
+  // 26
129
+  { PIOD, PIO_PD1,           ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 26
130
+  { PIOD, PIO_PD2,           ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 27
131
+  { PIOD, PIO_PD3,           ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 28
132
+  { PIOD, PIO_PD6,           ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 29
133
+
134
+  // 30
135
+  { PIOD, PIO_PD9,           ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 30
136
+  { PIOA, PIO_PA7,           ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 31
137
+  { PIOD, PIO_PD10,          ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 32
138
+  { PIOC, PIO_PC1,           ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 33
139
+
140
+  // 34
141
+
142
+  // start of custom pins
143
+  { PIOA, PIO_PA29,          ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 34  Y_STEP_PIN
144
+  { PIOB, PIO_PB1,           ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 35  Y_DIR_PIN
145
+  { PIOB, PIO_PB0,           ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 36  Y_ENABLE_PIN
146
+  { PIOB, PIO_PB22,          ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 37  E0_ENABLE_PIN
147
+  { PIOB, PIO_PB11,          ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 38  E0_MS1_PIN
148
+  { PIOB, PIO_PB10,          ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 39  E0_MS3_PIN
149
+  { PIOA, PIO_PA5,           ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 40  HEATER_0_PIN
150
+  { PIOB, PIO_PB24,          ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 41  HEATER_BED_PIN
151
+  // end of custom pins
152
+
153
+  // 42
154
+  { PIOA, PIO_PA19,          ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 42
155
+  { PIOA, PIO_PA20,          ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 43
156
+  { PIOC, PIO_PC19,          ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 44
157
+  { PIOC, PIO_PC18,          ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 45
158
+
159
+  // 46
160
+  { PIOC, PIO_PC17,          ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 46
161
+  { PIOC, PIO_PC16,          ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 47
162
+  { PIOC, PIO_PC15,          ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 48
163
+  { PIOC, PIO_PC14,          ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 49
164
+
165
+  // 50
166
+  { PIOC, PIO_PC13,          ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 50
167
+  { PIOC, PIO_PC12,          ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 51
168
+  { PIOB, PIO_PB21,          ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 52
169
+  { PIOB, PIO_PB14,          ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 53
170
+
171
+
172
+  // 54 .. 65 - Analog pins
173
+  // ----------------------
174
+  { PIOA, PIO_PA16X1_AD7,    ID_PIOA, PIO_INPUT,    PIO_DEFAULT, PIN_ATTR_ANALOG,                   ADC0,   ADC7,   NOT_ON_PWM,  NOT_ON_TIMER }, // AD0
175
+  { PIOA, PIO_PA24X1_AD6,    ID_PIOA, PIO_INPUT,    PIO_DEFAULT, PIN_ATTR_ANALOG,                   ADC1,   ADC6,   NOT_ON_PWM,  NOT_ON_TIMER }, // AD1
176
+  { PIOA, PIO_PA23X1_AD5,    ID_PIOA, PIO_INPUT,    PIO_DEFAULT, PIN_ATTR_ANALOG,                   ADC2,   ADC5,   NOT_ON_PWM,  NOT_ON_TIMER }, // AD2
177
+  { PIOA, PIO_PA22X1_AD4,    ID_PIOA, PIO_INPUT,    PIO_DEFAULT, PIN_ATTR_ANALOG,                   ADC3,   ADC4,   NOT_ON_PWM,  NOT_ON_TIMER }, // AD3
178
+  // 58
179
+  { PIOA, PIO_PA6X1_AD3,     ID_PIOA, PIO_INPUT,    PIO_DEFAULT, PIN_ATTR_ANALOG,                   ADC4,   ADC3,   NOT_ON_PWM,  TC0_CHB2     }, // AD4
180
+  { PIOA, PIO_PA4X1_AD2,     ID_PIOA, PIO_INPUT,    PIO_DEFAULT, PIN_ATTR_ANALOG,                   ADC5,   ADC2,   NOT_ON_PWM,  NOT_ON_TIMER }, // AD5
181
+  { PIOA, PIO_PA3X1_AD1,     ID_PIOA, PIO_INPUT,    PIO_DEFAULT, PIN_ATTR_ANALOG,                   ADC6,   ADC1,   NOT_ON_PWM,  TC0_CHB1     }, // AD6
182
+  { PIOA, PIO_PA2X1_AD0,     ID_PIOA, PIO_INPUT,    PIO_DEFAULT, PIN_ATTR_ANALOG,                   ADC7,   ADC0,   NOT_ON_PWM,  TC0_CHA1     }, // AD7
183
+  // 62
184
+  { PIOB, PIO_PB17X1_AD10,   ID_PIOB, PIO_INPUT,    PIO_DEFAULT, PIN_ATTR_ANALOG,                   ADC8,   ADC10,  NOT_ON_PWM,  NOT_ON_TIMER }, // AD8
185
+  { PIOB, PIO_PB18X1_AD11,   ID_PIOB, PIO_INPUT,    PIO_DEFAULT, PIN_ATTR_ANALOG,                   ADC9,   ADC11,  NOT_ON_PWM,  NOT_ON_TIMER }, // AD9
186
+  { PIOB, PIO_PB19X1_AD12,   ID_PIOB, PIO_INPUT,    PIO_DEFAULT, PIN_ATTR_ANALOG,                   ADC10,  ADC12,  NOT_ON_PWM,  NOT_ON_TIMER }, // AD10
187
+  { PIOB, PIO_PB20X1_AD13,   ID_PIOB, PIO_INPUT,    PIO_DEFAULT, PIN_ATTR_ANALOG,                   ADC11,  ADC13,  NOT_ON_PWM,  NOT_ON_TIMER }, // AD11
188
+
189
+  // 66/67 - DAC0/DAC1
190
+  { PIOB, PIO_PB15X1_DAC0,   ID_PIOB, PIO_INPUT,    PIO_DEFAULT, PIN_ATTR_ANALOG,                   ADC12,  DA0,    NOT_ON_PWM,  NOT_ON_TIMER }, // DAC0
191
+  { PIOB, PIO_PB16X1_DAC1,   ID_PIOB, PIO_INPUT,    PIO_DEFAULT, PIN_ATTR_ANALOG,                   ADC13,  DA1,    NOT_ON_PWM,  NOT_ON_TIMER }, // DAC1
192
+
193
+  // 68/69 - CANRX0/CANTX0
194
+  { PIOA, PIO_PA1A_CANRX0,   ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  ADC14,  NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // CANRX
195
+  { PIOA, PIO_PA0A_CANTX0,   ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  ADC15,  NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // CANTX
196
+
197
+  // 70/71 - TWI0
198
+  { PIOA, PIO_PA17A_TWD0,    ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // TWD0 - SDA1
199
+  { PIOA, PIO_PA18A_TWCK0,   ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // TWCK0 - SCL1
200
+
201
+  // 72/73 - LEDs
202
+  { PIOC, PIO_PC30,          ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // LED AMBER RXL
203
+  { PIOA, PIO_PA21,          ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // LED AMBER TXL
204
+
205
+  // 74/75/76 - SPI
206
+  { PIOA, PIO_PA25A_SPI0_MISO,ID_PIOA,PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // MISO
207
+  { PIOA, PIO_PA26A_SPI0_MOSI,ID_PIOA,PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // MOSI
208
+  { PIOA, PIO_PA27A_SPI0_SPCK,ID_PIOA,PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // SPCK
209
+
210
+  // 77 - SPI CS0
211
+  { PIOA, PIO_PA28A_SPI0_NPCS0,ID_PIOA,PIO_PERIPH_A,PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // NPCS0
212
+
213
+  // 78 - SPI CS3 (unconnected)
214
+  { PIOB, PIO_PB23B_SPI0_NPCS3,ID_PIOB,PIO_PERIPH_B,PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // NPCS3
215
+
216
+  // 79 .. 84 - "All pins" masks
217
+
218
+  // 79 - TWI0 all pins
219
+  { PIOA, PIO_PA17A_TWD0|PIO_PA18A_TWCK0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
220
+  // 80 - TWI1 all pins
221
+  { PIOB, PIO_PB12A_TWD1|PIO_PB13A_TWCK1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
222
+  // 81 - UART (Serial) all pins
223
+  { PIOA, PIO_PA8A_URXD|PIO_PA9A_UTXD, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
224
+  // 82 - USART0 (Serial1) all pins
225
+  { PIOA, PIO_PA11A_TXD0|PIO_PA10A_RXD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
226
+  // 83 - USART1 (Serial2) all pins
227
+  { PIOA, PIO_PA13A_TXD1|PIO_PA12A_RXD1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
228
+  // 84 - USART3 (Serial3) all pins
229
+  { PIOD, PIO_PD4B_TXD3|PIO_PD5B_RXD3, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
230
+
231
+  // 85 - USB
232
+  { PIOB, PIO_PB11A_UOTGID|PIO_PB10A_UOTGVBOF, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // ID - VBOF
233
+
234
+  // 86 - SPI CS2
235
+  { PIOB, PIO_PB21B_SPI0_NPCS2, ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // NPCS2
236
+
237
+  // 87 - SPI CS1
238
+  { PIOA, PIO_PA29A_SPI0_NPCS1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // NPCS1
239
+
240
+  // 88/89 - CANRX1/CANTX1 (same physical pin for 66/53)
241
+  { PIOB, PIO_PB15A_CANRX1,     ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // CANRX1
242
+  { PIOB, PIO_PB14A_CANTX1,     ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // CANTX1
243
+
244
+  // 90 .. 91 - "All CAN pins" masks
245
+  // 90 - CAN0 all pins
246
+  { PIOA, PIO_PA1A_CANRX0|PIO_PA0A_CANTX0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC,  NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER },
247
+  // 91 - CAN1 all pins
248
+  { PIOB, PIO_PB15A_CANRX1|PIO_PB14A_CANTX1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER },
249
+
250
+  // END
251
+  { NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }
252
+};
253
+
254
+// This section replaces the FASTIO definitions of pins 34-41
255
+
256
+#define DIO34_PIN 29
257
+#define DIO34_WPORT PIOA  // only available via FASTIO      //       34 PA29 - Y_STEP_PIN
258
+
259
+#define DIO35_PIN 1
260
+#define DIO35_WPORT PIOB  // only available via FASTIO      //       35 PAB1 - Y_DIR_PIN
261
+
262
+#define DIO36_PIN 0
263
+#define DIO36_WPORT PIOB  // only available via FASTIO      //       36 PB0 - Y_ENABLE_PIN
264
+
265
+#define DIO37_PIN 22
266
+#define DIO37_WPORT PIOB  // only available via FASTIO      //       37 PB22 - E0_ENABLE_PIN
267
+
268
+#define DIO38_PIN 11
269
+#define DIO38_WPORT PIOB  // only available via FASTIO      //       38 PB11 - E0_MS1_PIN
270
+
271
+#define DIO39_PIN 10
272
+#define DIO39_WPORT PIOB  // only available via FASTIO      //       39 PB10 - E0_MS3_PIN
273
+
274
+#define DIO40_PIN 5
275
+#define DIO40_WPORT PIOA  // only available via FASTIO      //       40 PA5  - HEATER_0_PIN
276
+
277
+#define DIO41_PIN 24
278
+#define DIO41_WPORT PIOB  // only available via FASTIO      //       41 PB24 - HEATER_BED_PIN

+ 100
- 31
Marlin/src/HAL/HAL_DUE/fastio_Due.h View File

@@ -65,7 +65,7 @@
65 65
 // Write to a pin
66 66
 #define _WRITE_VAR(IO,V) do { \
67 67
   volatile Pio* port = digitalPinToPort(IO); \
68
-  uint32_t mask = digitalPinToBitMask(IO); \
68
+  const uint32_t mask = digitalPinToBitMask(IO); \
69 69
   if (V) port->PIO_SODR = mask; \
70 70
   else port->PIO_CODR = mask; \
71 71
 } while(0)
@@ -73,7 +73,7 @@
73 73
 // Write to a pin
74 74
 #define _WRITE(IO,V) do { \
75 75
   volatile Pio* port = (DIO ##  IO ## _WPORT); \
76
-  uint32_t mask = MASK(DIO ## IO ## _PIN); \
76
+  const uint32_t mask = MASK(DIO ## IO ## _PIN); \
77 77
   if (V) port->PIO_SODR = mask; \
78 78
   else port->PIO_CODR = mask; \
79 79
 } while(0)
@@ -81,18 +81,79 @@
81 81
 // Toggle a pin
82 82
 #define _TOGGLE(IO) _WRITE(IO, !READ(IO))
83 83
 
84
-// Set pin as input
85
-#define _SET_INPUT(IO) do{ \
86
-  pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
87
-  PIO_Configure(digitalPinToPort(IO), PIO_INPUT, digitalPinToBitMask(IO), 0); \
88
-}while(0)
84
+#include <pins_arduino.h>
85
+
86
+#if MB(PRINTRBOARD_G2)
87
+
88
+  #include "G2_pins.h"
89
+
90
+  // Set pin as input
91
+  #define _SET_INPUT(IO) do{ \
92
+    pmc_enable_periph_clk(G2_g_APinDescription[IO].ulPeripheralId); \
93
+    PIO_Configure((DIO ## IO ## _WPORT), PIO_INPUT, MASK(DIO ## IO ## _PIN), 0); \
94
+  }while(0)
95
+
96
+  // Set pin as output
97
+  #define _SET_OUTPUT(IO) do{ \
98
+    uint32_t mask = MASK(G2_g_APinDescription[IO].ulPeripheralId); \
99
+    if ((PMC->PMC_PCSR0 & mask) != (mask)) PMC->PMC_PCER0 = mask; \
100
+    volatile Pio* port = (DIO ## IO ## _WPORT); \
101
+    mask = MASK(DIO ## IO ## _PIN); \
102
+    if (_READ(IO)) port->PIO_SODR = mask; \
103
+    else port->PIO_CODR = mask; \
104
+    port->PIO_IDR = mask; \
105
+    const uint32_t pin_config = G2_g_APinDescription[IO].ulPinConfiguration; \
106
+    if (pin_config & PIO_PULLUP) port->PIO_PUER = mask; \
107
+    else port->PIO_PUDR = mask; \
108
+    if (pin_config & PIO_OPENDRAIN) port->PIO_MDER = mask; \
109
+    else port->PIO_MDDR = mask; \
110
+    port->PIO_PER = mask; \
111
+    port->PIO_OER = mask; \
112
+    g_pinStatus[IO] = (g_pinStatus[IO] & 0xF0) | PIN_STATUS_DIGITAL_OUTPUT; \
113
+  }while(0)
114
+
115
+ /**
116
+  *  Set pin as output with comments
117
+  *  #define _SET_OUTPUT(IO) do{ \
118
+  *    uint32_t mask = MASK(G2_g_APinDescription[IO].ulPeripheralId); \
119
+  *    if ((PMC->PMC_PCSR0 & mask ) != (mask))  PMC->PMC_PCER0 = mask; \  // enable PIO clock if not already enabled
120
+  *
121
+  *    volatile Pio* port = (DIO ##  IO ## _WPORT); \
122
+  *    const uint32_t mask = MASK(DIO ## IO ## _PIN); \
123
+  *    if (_READ(IO)) port->PIO_SODR = mask; \ // set output to match input BEFORE setting direction or will glitch the output
124
+  *    else port->PIO_CODR = mask; \
125
+  *
126
+  *    port->PIO_IDR = mask; \ // disable interrupt
127
+  *
128
+  *    uint32_t pin_config = G2_g_APinDescription[IO].ulPinConfiguration; \
129
+  *    if (pin_config & PIO_PULLUP) pPio->PIO_PUER = mask; \  // enable pullup if necessary
130
+  *    else  pPio->PIO_PUDR = mask; \
131
+  *
132
+  *    if (pin_config & PIO_OPENDRAIN) port->PIO_MDER = mask; \ // Enable multi-drive if necessary
133
+  *    else  port->PIO_MDDR = mask; \
134
+  *
135
+  *    port->PIO_PER = mask; \
136
+  *    port->PIO_OER = mask; \  // set to output
137
+  *
138
+  *    g_pinStatus[IO] = (g_pinStatus[IO] & 0xF0) | PIN_STATUS_DIGITAL_OUTPUT; \
139
+  *  }while(0)
140
+  */
89 141
 
90
-// Set pin as output
91
-#define _SET_OUTPUT(IO) do{ \
92
-  pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
93
-  PIO_Configure(digitalPinToPort(IO), _READ(IO) ? PIO_OUTPUT_1 : PIO_OUTPUT_0, digitalPinToBitMask(IO), g_APinDescription[IO].ulPinConfiguration); \
94
-  g_pinStatus[IO] = (g_pinStatus[IO] & 0xF0) | PIN_STATUS_DIGITAL_OUTPUT;\
95
-}while(0)
142
+#else
143
+
144
+    // Set pin as input
145
+  #define _SET_INPUT(IO) do{ \
146
+    pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
147
+    PIO_Configure(digitalPinToPort(IO), PIO_INPUT, digitalPinToBitMask(IO), 0); \
148
+  }while(0)
149
+
150
+  // Set pin as output
151
+  #define _SET_OUTPUT(IO) do{ \
152
+    pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
153
+    PIO_Configure(digitalPinToPort(IO), _READ(IO) ? PIO_OUTPUT_1 : PIO_OUTPUT_0, digitalPinToBitMask(IO), g_APinDescription[IO].ulPinConfiguration); \
154
+    g_pinStatus[IO] = (g_pinStatus[IO] & 0xF0) | PIN_STATUS_DIGITAL_OUTPUT; \
155
+  }while(0)
156
+#endif
96 157
 
97 158
 // Set pin as input with pullup mode
98 159
 #define _PULLUP(IO,V) pinMode(IO, (V) ? INPUT_PULLUP : INPUT)
@@ -243,29 +304,33 @@
243 304
 #define DIO33_PIN 1
244 305
 #define DIO33_WPORT PIOC
245 306
 
246
-#define DIO34_PIN 2
247
-#define DIO34_WPORT PIOC
307
+#if !MB(PRINTRBOARD_G2)    // normal DUE pin mapping
308
+
309
+  #define DIO34_PIN 2
310
+  #define DIO34_WPORT PIOC
311
+
312
+  #define DIO35_PIN 3
313
+  #define DIO35_WPORT PIOC
248 314
 
249
-#define DIO35_PIN 3
250
-#define DIO35_WPORT PIOC
315
+  #define DIO36_PIN 4
316
+  #define DIO36_WPORT PIOC
251 317
 
252
-#define DIO36_PIN 4
253
-#define DIO36_WPORT PIOC
318
+  #define DIO37_PIN 5
319
+  #define DIO37_WPORT PIOC
254 320
 
255
-#define DIO37_PIN 5
256
-#define DIO37_WPORT PIOC
321
+  #define DIO38_PIN 6
322
+  #define DIO38_WPORT PIOC
257 323
 
258
-#define DIO38_PIN 6
259
-#define DIO38_WPORT PIOC
324
+  #define DIO39_PIN 7
325
+  #define DIO39_WPORT PIOC
260 326
 
261
-#define DIO39_PIN 7
262
-#define DIO39_WPORT PIOC
327
+  #define DIO40_PIN 8
328
+  #define DIO40_WPORT PIOC
263 329
 
264
-#define DIO40_PIN 8
265
-#define DIO40_WPORT PIOC
330
+  #define DIO41_PIN 9
331
+  #define DIO41_WPORT PIOC
266 332
 
267
-#define DIO41_PIN 9
268
-#define DIO41_WPORT PIOC
333
+#endif // !PRINTRBOARD_G2
269 334
 
270 335
 #define DIO42_PIN 19
271 336
 #define DIO42_WPORT PIOA
@@ -418,6 +483,7 @@
418 483
 #define DIO91_WPORT PIOB
419 484
 
420 485
 #if ARDUINO_SAM_ARCHIM
486
+
421 487
   #define DIO92_PIN 11
422 488
   #define DIO92_WPORT PIOC
423 489
 
@@ -468,7 +534,9 @@
468 534
 
469 535
   #define DIO108_PIN 9
470 536
   #define DIO108_WPORT PIOB
471
-#else
537
+
538
+#else // !ARDUINO_SAM_ARCHIM
539
+
472 540
   #define DIO92_PIN 5
473 541
   #define DIO92_WPORT PIOA
474 542
 
@@ -495,4 +563,5 @@
495 563
 
496 564
   #define DIO100_PIN 11
497 565
   #define DIO100_WPORT PIOC
498
-#endif
566
+
567
+#endif // !ARDUINO_SAM_ARCHIM

+ 12
- 0
Marlin/src/Marlin.cpp View File

@@ -423,7 +423,9 @@ void disable_all_steppers() {
423 423
  *  - Check for HOME button held down
424 424
  *  - Check if cooling fan needs to be switched on
425 425
  *  - Check if an idle but hot extruder needs filament extruded (EXTRUDER_RUNOUT_PREVENT)
426
+ *  - Pulse FET_SAFETY_PIN if it exists
426 427
  */
428
+
427 429
 void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
428 430
 
429 431
   #if HAS_FILAMENT_SENSOR
@@ -639,6 +641,16 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
639 641
     planner.check_axes_activity();
640 642
     next_check_axes_ms = ms + 100UL;
641 643
   }
644
+
645
+  #if PIN_EXISTS(FET_SAFETY)
646
+    static millis_t FET_next;
647
+    if (ELAPSED(ms, FET_next)) {
648
+      FET_next = ms + FET_SAFETY_DELAY;  // 2uS pulse every FET_SAFETY_DELAY mS
649
+      OUT_WRITE(FET_SAFETY_PIN, !FET_SAFETY_INVERTED);
650
+      DELAY_US(2);
651
+      WRITE(FET_SAFETY_PIN, FET_SAFETY_INVERTED);
652
+    }
653
+  #endif
642 654
 }
643 655
 
644 656
 /**

+ 2102
- 0
Marlin/src/config/examples/Printrbot/PrintrboardG2/Configuration.h
File diff suppressed because it is too large
View File


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

@@ -222,6 +222,12 @@
222 222
 #define BOARD_ARCHIM1          1591   // UltiMachine Archim1 (with DRV8825 drivers)
223 223
 #define BOARD_ARCHIM2          1592   // UltiMachine Archim2 (with TMC2130 drivers)
224 224
 #define BOARD_ALLIGATOR        1602   // Alligator Board R2
225
+
226
+//
227
+// SAM3X8C ARM Cortex M3
228
+//
229
+
230
+#define BOARD_PRINTRBOARD_G2   1620   // PRINTRBOARD G2
225 231
 #define BOARD_ADSK             1610   // Arduino DUE Shield Kit (ADSK)
226 232
 
227 233
 //

+ 11
- 11
Marlin/src/gcode/feature/digipot/M907-M910.cpp View File

@@ -44,37 +44,37 @@
44 44
 void GcodeSuite::M907() {
45 45
   #if HAS_DIGIPOTSS
46 46
 
47
-    LOOP_XYZE(i) if (parser.seen(axis_codes[i])) stepper.digipot_current(i, parser.value_int());
48
-    if (parser.seen('B')) stepper.digipot_current(4, parser.value_int());
49
-    if (parser.seen('S')) for (uint8_t i = 0; i <= 4; i++) stepper.digipot_current(i, parser.value_int());
47
+    LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) stepper.digipot_current(i, parser.value_int());
48
+    if (parser.seenval('B')) stepper.digipot_current(4, parser.value_int());
49
+    if (parser.seenval('S')) for (uint8_t i = 0; i <= 4; i++) stepper.digipot_current(i, parser.value_int());
50 50
 
51 51
   #elif HAS_MOTOR_CURRENT_PWM
52 52
 
53
-    #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
54
-      if (parser.seen('X')) stepper.digipot_current(0, parser.value_int());
53
+    #if PIN_EXISTS(MOTOR_CURRENT_PWM_X) || PIN_EXISTS(MOTOR_CURRENT_PWM_Y) || PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
54
+      if (parser.seenval('X') || parser.seenval('Y')) stepper.digipot_current(0, parser.value_int());
55 55
     #endif
56 56
     #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
57
-      if (parser.seen('Z')) stepper.digipot_current(1, parser.value_int());
57
+      if (parser.seenval('Z')) stepper.digipot_current(1, parser.value_int());
58 58
     #endif
59 59
     #if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
60
-      if (parser.seen('E')) stepper.digipot_current(2, parser.value_int());
60
+      if (parser.seenval('E')) stepper.digipot_current(2, parser.value_int());
61 61
     #endif
62 62
 
63 63
   #endif
64 64
 
65 65
   #if ENABLED(DIGIPOT_I2C)
66 66
     // this one uses actual amps in floating point
67
-    LOOP_XYZE(i) if (parser.seen(axis_codes[i])) digipot_i2c_set_current(i, parser.value_float());
67
+    LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) digipot_i2c_set_current(i, parser.value_float());
68 68
     // for each additional extruder (named B,C,D,E..., channels 4,5,6,7...)
69
-    for (uint8_t i = NUM_AXIS; i < DIGIPOT_I2C_NUM_CHANNELS; i++) if (parser.seen('B' + i - (NUM_AXIS))) digipot_i2c_set_current(i, parser.value_float());
69
+    for (uint8_t i = NUM_AXIS; i < DIGIPOT_I2C_NUM_CHANNELS; i++) if (parser.seenval('B' + i - (NUM_AXIS))) digipot_i2c_set_current(i, parser.value_float());
70 70
   #endif
71 71
 
72 72
   #if ENABLED(DAC_STEPPER_CURRENT)
73
-    if (parser.seen('S')) {
73
+    if (parser.seenval('S')) {
74 74
       const float dac_percent = parser.value_float();
75 75
       for (uint8_t i = 0; i <= 4; i++) dac_current_percent(i, dac_percent);
76 76
     }
77
-    LOOP_XYZE(i) if (parser.seen(axis_codes[i])) dac_current_percent(i, parser.value_float());
77
+    LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) dac_current_percent(i, parser.value_float());
78 78
   #endif
79 79
 }
80 80
 

+ 85
- 77
Marlin/src/module/stepper.cpp View File

@@ -2485,99 +2485,107 @@ void Stepper::report_positions() {
2485 2485
 
2486 2486
 #endif // HAS_MOTOR_CURRENT_PWM
2487 2487
 
2488
-#if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM
2488
+#if !MB(PRINTRBOARD_G2)
2489 2489
 
2490
-  void Stepper::digipot_current(const uint8_t driver, const int16_t current) {
2490
+  #if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM
2491 2491
 
2492
-    #if HAS_DIGIPOTSS
2492
+    void Stepper::digipot_current(const uint8_t driver, const int16_t current) {
2493 2493
 
2494
-      const uint8_t digipot_ch[] = DIGIPOT_CHANNELS;
2495
-      digitalPotWrite(digipot_ch[driver], current);
2494
+      #if HAS_DIGIPOTSS
2496 2495
 
2497
-    #elif HAS_MOTOR_CURRENT_PWM
2496
+        const uint8_t digipot_ch[] = DIGIPOT_CHANNELS;
2497
+        digitalPotWrite(digipot_ch[driver], current);
2498 2498
 
2499
-      if (WITHIN(driver, 0, COUNT(motor_current_setting) - 1))
2500
-        motor_current_setting[driver] = current; // update motor_current_setting
2499
+      #elif HAS_MOTOR_CURRENT_PWM
2501 2500
 
2502
-      #define _WRITE_CURRENT_PWM(P) analogWrite(MOTOR_CURRENT_PWM_## P ##_PIN, 255L * current / (MOTOR_CURRENT_PWM_RANGE))
2503
-      switch (driver) {
2504
-        case 0:
2505
-          #if PIN_EXISTS(MOTOR_CURRENT_PWM_X)
2506
-            _WRITE_CURRENT_PWM(X);
2507
-          #endif
2508
-          #if PIN_EXISTS(MOTOR_CURRENT_PWM_Y)
2509
-            _WRITE_CURRENT_PWM(Y);
2510
-          #endif
2511
-          #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
2512
-            _WRITE_CURRENT_PWM(XY);
2513
-          #endif
2514
-          break;
2515
-        case 1:
2516
-          #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
2517
-            _WRITE_CURRENT_PWM(Z);
2518
-          #endif
2519
-          break;
2520
-        case 2:
2521
-          #if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
2522
-            _WRITE_CURRENT_PWM(E);
2523
-          #endif
2524
-          #if PIN_EXISTS(MOTOR_CURRENT_PWM_E0)
2525
-            _WRITE_CURRENT_PWM(E0);
2526
-          #endif
2527
-          #if PIN_EXISTS(MOTOR_CURRENT_PWM_E1)
2528
-            _WRITE_CURRENT_PWM(E1);
2529
-          #endif
2530
-          break;
2531
-      }
2532
-    #endif
2533
-  }
2501
+        if (WITHIN(driver, 0, COUNT(motor_current_setting) - 1))
2502
+          motor_current_setting[driver] = current; // update motor_current_setting
2534 2503
 
2535
-  void Stepper::digipot_init() {
2504
+        #define _WRITE_CURRENT_PWM(P) analogWrite(MOTOR_CURRENT_PWM_## P ##_PIN, 255L * current / (MOTOR_CURRENT_PWM_RANGE))
2505
+        switch (driver) {
2506
+          case 0:
2507
+            #if PIN_EXISTS(MOTOR_CURRENT_PWM_X)
2508
+              _WRITE_CURRENT_PWM(X);
2509
+            #endif
2510
+            #if PIN_EXISTS(MOTOR_CURRENT_PWM_Y)
2511
+              _WRITE_CURRENT_PWM(Y);
2512
+            #endif
2513
+            #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
2514
+              _WRITE_CURRENT_PWM(XY);
2515
+            #endif
2516
+            break;
2517
+          case 1:
2518
+            #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
2519
+              _WRITE_CURRENT_PWM(Z);
2520
+            #endif
2521
+            break;
2522
+          case 2:
2523
+            #if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
2524
+              _WRITE_CURRENT_PWM(E);
2525
+            #endif
2526
+            #if PIN_EXISTS(MOTOR_CURRENT_PWM_E0)
2527
+              _WRITE_CURRENT_PWM(E0);
2528
+            #endif
2529
+            #if PIN_EXISTS(MOTOR_CURRENT_PWM_E1)
2530
+              _WRITE_CURRENT_PWM(E1);
2531
+            #endif
2532
+            break;
2533
+        }
2534
+      #endif
2535
+    }
2536 2536
 
2537
-    #if HAS_DIGIPOTSS
2537
+    void Stepper::digipot_init() {
2538 2538
 
2539
-      static const uint8_t digipot_motor_current[] = DIGIPOT_MOTOR_CURRENT;
2539
+      #if HAS_DIGIPOTSS
2540 2540
 
2541
-      SPI.begin();
2542
-      SET_OUTPUT(DIGIPOTSS_PIN);
2541
+        static const uint8_t digipot_motor_current[] = DIGIPOT_MOTOR_CURRENT;
2543 2542
 
2544
-      for (uint8_t i = 0; i < COUNT(digipot_motor_current); i++) {
2545
-        //digitalPotWrite(digipot_ch[i], digipot_motor_current[i]);
2546
-        digipot_current(i, digipot_motor_current[i]);
2547
-      }
2543
+        SPI.begin();
2544
+        SET_OUTPUT(DIGIPOTSS_PIN);
2548 2545
 
2549
-    #elif HAS_MOTOR_CURRENT_PWM
2546
+        for (uint8_t i = 0; i < COUNT(digipot_motor_current); i++) {
2547
+          //digitalPotWrite(digipot_ch[i], digipot_motor_current[i]);
2548
+          digipot_current(i, digipot_motor_current[i]);
2549
+        }
2550 2550
 
2551
-      #if PIN_EXISTS(MOTOR_CURRENT_PWM_X)
2552
-        SET_OUTPUT(MOTOR_CURRENT_PWM_X_PIN);
2553
-      #endif
2554
-      #if PIN_EXISTS(MOTOR_CURRENT_PWM_Y)
2555
-        SET_OUTPUT(MOTOR_CURRENT_PWM_Y_PIN);
2556
-      #endif
2557
-      #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
2558
-        SET_OUTPUT(MOTOR_CURRENT_PWM_XY_PIN);
2559
-      #endif
2560
-      #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
2561
-        SET_OUTPUT(MOTOR_CURRENT_PWM_Z_PIN);
2562
-      #endif
2563
-      #if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
2564
-        SET_OUTPUT(MOTOR_CURRENT_PWM_E_PIN);
2565
-      #endif
2566
-      #if PIN_EXISTS(MOTOR_CURRENT_PWM_E0)
2567
-        SET_OUTPUT(MOTOR_CURRENT_PWM_E0_PIN);
2568
-      #endif
2569
-      #if PIN_EXISTS(MOTOR_CURRENT_PWM_E1)
2570
-        SET_OUTPUT(MOTOR_CURRENT_PWM_E1_PIN);
2571
-      #endif
2551
+      #elif HAS_MOTOR_CURRENT_PWM
2572 2552
 
2573
-      refresh_motor_power();
2553
+        #if PIN_EXISTS(MOTOR_CURRENT_PWM_X)
2554
+          SET_OUTPUT(MOTOR_CURRENT_PWM_X_PIN);
2555
+        #endif
2556
+        #if PIN_EXISTS(MOTOR_CURRENT_PWM_Y)
2557
+          SET_OUTPUT(MOTOR_CURRENT_PWM_Y_PIN);
2558
+        #endif
2559
+        #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
2560
+          SET_OUTPUT(MOTOR_CURRENT_PWM_XY_PIN);
2561
+        #endif
2562
+        #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
2563
+          SET_OUTPUT(MOTOR_CURRENT_PWM_Z_PIN);
2564
+        #endif
2565
+        #if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
2566
+          SET_OUTPUT(MOTOR_CURRENT_PWM_E_PIN);
2567
+        #endif
2568
+        #if PIN_EXISTS(MOTOR_CURRENT_PWM_E0)
2569
+          SET_OUTPUT(MOTOR_CURRENT_PWM_E0_PIN);
2570
+        #endif
2571
+        #if PIN_EXISTS(MOTOR_CURRENT_PWM_E1)
2572
+          SET_OUTPUT(MOTOR_CURRENT_PWM_E1_PIN);
2573
+        #endif
2574 2574
 
2575
-      // Set Timer5 to 31khz so the PWM of the motor power is as constant as possible. (removes a buzzing noise)
2576
-      #ifdef __AVR__
2577
-        SET_CS5(PRESCALER_1);
2575
+        refresh_motor_power();
2576
+
2577
+        // Set Timer5 to 31khz so the PWM of the motor power is as constant as possible. (removes a buzzing noise)
2578
+        #ifdef __AVR__
2579
+          SET_CS5(PRESCALER_1);
2580
+        #endif
2578 2581
       #endif
2579
-    #endif
2580
-  }
2582
+    }
2583
+
2584
+  #endif
2585
+
2586
+#else
2587
+
2588
+  #include "../HAL/HAL_DUE/G2_PWM.h"
2581 2589
 
2582 2590
 #endif
2583 2591
 

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

@@ -393,6 +393,8 @@
393 393
   #include "pins_ALLIGATOR_R2.h"      // SAM3X8E                                    env:DUE env:DUE_debug
394 394
 #elif MB(ADSK)
395 395
   #include "pins_ADSK.h"              // SAM3X8E                                    env:DUE env:DUE_debug
396
+#elif MB(PRINTRBOARD_G2)
397
+  #include "pins_PRINTRBOARD_G2.h"    // SAM3X8C                                    env:DUE_USB
396 398
 
397 399
 //
398 400
 // STM32 ARM Cortex-M3

+ 9
- 0
Marlin/src/pins/pinsDebug_list.h View File

@@ -614,6 +614,12 @@
614 614
 #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
615 615
   REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_XY_PIN)
616 616
 #endif
617
+#if PIN_EXISTS(MOTOR_CURRENT_PWM_X)
618
+  REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_X_PIN)
619
+#endif
620
+#if PIN_EXISTS(MOTOR_CURRENT_PWM_Y)
621
+  REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_Y_PIN)
622
+#endif
617 623
 #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
618 624
   REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_Z_PIN)
619 625
 #endif
@@ -1154,3 +1160,6 @@
1154 1160
 #if PIN_EXISTS(L6470_RESET_CHAIN)
1155 1161
   REPORT_NAME_DIGITAL(__LINE__, L6470_RESET_CHAIN_PIN)
1156 1162
 #endif
1163
+#if PIN_EXISTS(FET_SAFETY)
1164
+  REPORT_NAME_DIGITAL(__LINE__, FET_SAFETY_PIN)
1165
+#endif

+ 177
- 0
Marlin/src/pins/pins_PRINTRBOARD_G2.h View File

@@ -0,0 +1,177 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016, 2019 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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * PRINTRBOARD_G2
25
+ */
26
+
27
+#ifndef __SAM3X8E__
28
+  #error "Oops! Select 'Arduino Due' in 'Tools > Board.'"
29
+#endif
30
+
31
+#ifndef BOARD_NAME
32
+  #define BOARD_NAME "PRINTRBOARD_G2"
33
+#endif
34
+
35
+//
36
+// Servos
37
+//
38
+//#define SERVO0_PIN       -1
39
+//#define SERVO1_PIN       -1
40
+
41
+//
42
+// Limit Switches
43
+//
44
+#define X_MIN_PIN          22   // PB26
45
+#define Y_MAX_PIN          18   // PA11
46
+#define Z_MIN_PIN          19   // PA10
47
+
48
+//
49
+// Z Probe (when not Z_MIN_PIN)
50
+//
51
+#ifndef Z_MIN_PROBE_PIN
52
+ #define Z_MIN_PROBE_PIN   22
53
+#endif
54
+
55
+#ifndef FIL_RUNOUT_PIN
56
+  //#define FIL_RUNOUT_PIN 57   // PA22
57
+#endif
58
+#ifndef FIL_RUNOUT2_PIN
59
+  //#define FIL_RUNOUT2_PIN 21  // PB13
60
+#endif
61
+
62
+
63
+//
64
+// LED defines
65
+//
66
+//#define NEOPIXEL_TYPE   NEO_GRBW  // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h)
67
+//#define NEOPIXEL_PIN    20        // LED driving pin on motherboard
68
+//#define NEOPIXEL_PIXELS 3         // Number of LEDs in the strip
69
+
70
+
71
+
72
+//#define SDA0 20 // PB12 NeoPixel pin I2C data
73
+//#define SCL0 21 // PB13              I2C clock
74
+
75
+// D0_12 #REF! (INDICATOR_LED)
76
+// B28 JTAG-CLK
77
+// B31 JTAG_TMS /SWD_DIO
78
+//A18 INTERRUPT_OUT
79
+//A12 USART_RX not used
80
+//A13 USART_TX not used
81
+//A14 UART_RTS
82
+//A15 UART_CTS
83
+//PB2 Unassigned
84
+//PB4 to PB9 Unassigned
85
+//#define UART_RX_PIN         0   // PA8    "RX0"
86
+//#define UART_TX_PIN         1   // PA9    "TX0"
87
+//#define UART_RTS_PIN       23   // PA14
88
+//#define UART_CTS_PIN       24   // PA15
89
+
90
+//
91
+// Steppers
92
+//
93
+#define Z_STEP_PIN         73   // PA21      MOTOR 1
94
+#define Z_DIR_PIN          75   // PA26
95
+#define Z_ENABLE_PIN       74   // PA25
96
+
97
+#define X_STEP_PIN         66   // PB15      MOTOR 2
98
+#define X_DIR_PIN          54   // PA16
99
+#define X_ENABLE_PIN       67   // PB16
100
+
101
+#define Y_STEP_PIN         34   // PA29      MOTOR 3
102
+#define Y_DIR_PIN          35   // PB1
103
+#define Y_ENABLE_PIN       36   // PB0
104
+
105
+#define E0_STEP_PIN        53   // PB14      MOTOR 4
106
+#define E0_DIR_PIN         78   // PB23
107
+#define E0_ENABLE_PIN      37   // PB22
108
+
109
+// Microstepping mode pins
110
+#define Z_MS1_PIN          52   // PB21 MODE0     MOTOR 1
111
+#define Z_MS2_PIN          52   // PB21 MODE1
112
+#define Z_MS3_PIN          65   // PB20 MODE2
113
+
114
+#define X_MS1_PIN          43   // PA20 MODE0     MOTOR 2
115
+#define X_MS2_PIN          43   // PA20 MODE1
116
+#define X_MS3_PIN          42   // PA19 MODE2
117
+
118
+#define Y_MS1_PIN          77   // PA28 MODE0     MOTOR 3
119
+#define Y_MS2_PIN          77   // PA28 MODE1
120
+#define Y_MS3_PIN          76   // PA27 MODE2
121
+
122
+#define E0_MS1_PIN         38   // PB11 MODE0     MOTOR 4
123
+#define E0_MS2_PIN         38   // PB11 MODE1
124
+#define E0_MS3_PIN         39   // PB10 MODE2
125
+
126
+// Motor current PWM pins
127
+#define MOTOR_CURRENT_PWM_X_PIN 62 // PB17        MOTOR 1
128
+#define MOTOR_CURRENT_PWM_Z_PIN 63 // PB18        MOTOR 2
129
+#define MOTOR_CURRENT_PWM_Y_PIN 64 // PB19        MOTOR 3
130
+#define MOTOR_CURRENT_PWM_E_PIN 61 // PA2         MOTOR 4
131
+
132
+//#define DEFAULT_PWM_MOTOR_CURRENT { 300, 400, 1000}  // XY Z E0, 1000 = 1000mAh
133
+
134
+//
135
+// Temperature Sensors
136
+//
137
+#define TEMP_0_PIN          2   // digital 56 PA23
138
+#define TEMP_BED_PIN        5   // digital 59 PA4
139
+
140
+//
141
+// Heaters / Fans
142
+//
143
+#define HEATER_0_PIN       40   // PA5
144
+#define HEATER_BED_PIN     41   // PB24
145
+
146
+#ifndef FAN_PIN
147
+  #define FAN_PIN          13   //  PB27 Fan1A
148
+#endif
149
+#define FAN1_PIN           58   //  PA6  Fan1B
150
+
151
+#define FET_SAFETY_PIN     31   // PA7  must be pulsed low every 50 mS or FETs are turned off
152
+#define FET_SAFETY_DELAY   50   // 50 mS delay between pulses
153
+#define FET_SAFETY_INVERTED true // true - negative going pulse of 2 uS
154
+
155
+/////////////////////////////////////////////////////////
156
+
157
+#define MISO_PIN           68   // set to unused pins for now
158
+#define MOSI_PIN           69   // set to unused pins for now
159
+#define SCK_PIN            70   // set to unused pins for now
160
+#define SDSS               71   // set to unused pins for now
161
+
162
+/**
163
+ * G2 uses 8 pins that are not available in the DUE environment:
164
+ *   34 PA29 - Y_STEP_PIN
165
+ *   35 PB1  - Y_DIR_PIN
166
+ *   36 PB0  - Y_ENABLE_PIN
167
+ *   37 PB22 - E0_ENABLE_PIN
168
+ *   38 PB11 - E0_MS1_PIN - normally used by the USB native port
169
+ *   39 PB10 - E0_MS3_PIN - normally used by the USB native port
170
+ *   40 PA5  - HEATER_0_PIN
171
+ *   41 PB24 - HEATER_BED_PIN
172
+ *
173
+ * None of these are in the arduino_due_x variant so digitalWrite and digitalRead can't be used on them.
174
+ *
175
+ * They can be accessed via FASTIO functions WRITE, READ, OUT_WRITE, OUTPUT, ...
176
+ *
177
+ */

Loading…
Cancel
Save