Browse Source

HAL for DUE architecture

Christopher Pepper 6 years ago
parent
commit
cfef925559

+ 159
- 0
Marlin/pins_ALLIGATOR_R2.h View File

@@ -0,0 +1,159 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 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
+ * Alligator Board R2
25
+ * http://www.3dartists.org/
26
+ */
27
+
28
+#ifndef __SAM3X8E__
29
+  #error "Oops!  Make sure you have 'Arduino Due' selected from the 'Tools -> Boards' menu."
30
+#endif
31
+
32
+#define BOARD_NAME            "Alligator Board R2"
33
+
34
+//
35
+// Servos
36
+//
37
+#define SERVO0_PIN            36
38
+#define SERVO1_PIN            40
39
+#define SERVO2_PIN            41
40
+#define SERVO3_PIN            -1
41
+
42
+//
43
+// Limit Switches
44
+//
45
+#define X_MIN_PIN             33 // PC1
46
+#define X_MAX_PIN             34 // PC2
47
+#define Y_MIN_PIN             35 // PC3
48
+#define Y_MAX_PIN             37 // PC5
49
+#define Z_MIN_PIN             38 // PC6
50
+#define Z_MAX_PIN             39 // PC7
51
+
52
+//
53
+// Steppers
54
+//
55
+#define X_STEP_PIN            96 // PB24
56
+#define X_DIR_PIN              2 // PB25
57
+#define X_ENABLE_PIN          24 // PA15, motor RESET pin
58
+
59
+#define Y_STEP_PIN            94 // PB22
60
+#define Y_DIR_PIN             95 // PB23
61
+#define Y_ENABLE_PIN          24 // PA15, motor RESET pin
62
+
63
+#define Z_STEP_PIN            98 // PC27
64
+#define Z_DIR_PIN              3 // PC28
65
+#define Z_ENABLE_PIN          24 // PA15, motor RESET pin
66
+
67
+#define E0_STEP_PIN            5 // PC25
68
+#define E0_DIR_PIN             4 // PC26
69
+#define E0_ENABLE_PIN         24 // PA15, motor RESET pin
70
+
71
+#define E1_STEP_PIN           28 // PD3 on piggy
72
+#define E1_DIR_PIN            27 // PD2 on piggy
73
+#define E1_ENABLE_PIN         24 // PA15, motor RESET pin
74
+
75
+#define E2_STEP_PIN           11 // PD7 on piggy
76
+#define E2_DIR_PIN            29 // PD6 on piggy
77
+#define E2_ENABLE_PIN         24 // PA15, motor RESET pin
78
+
79
+#define E3_STEP_PIN           30 // PD9 on piggy
80
+#define E3_DIR_PIN            12 // PD8 on piggy
81
+#define E3_ENABLE_PIN         24 // PA15, motor RESET pin
82
+
83
+// Microstepping pins - Mapping not from fastio.h (?)
84
+#define X_MS1_PIN             99 // PC10
85
+#define Y_MS1_PIN             10 // PC29
86
+#define Z_MS1_PIN             44 // PC19
87
+#define E0_MS1_PIN            45 // PC18
88
+
89
+//#define MOTOR_FAULT_PIN     22 // PB26 , motor X-Y-Z-E0 motor FAULT
90
+
91
+//
92
+// Temperature Sensors
93
+//
94
+#define TEMP_0_PIN             1   // Analog Input (PA24)
95
+#define TEMP_1_PIN             2   // Analog Input (PA23 on piggy)
96
+#define TEMP_2_PIN             3   // Analog Input (PA22 on piggy)
97
+#define TEMP_3_PIN             4   // Analog Input (PA6 on piggy)
98
+#define TEMP_BED_PIN           0   // Analog Input (PA16)
99
+
100
+//
101
+// Heaters / Fans
102
+//
103
+// Note that on the Due pin A0 on the board is channel 2 on the ARM chip
104
+#define HEATER_0_PIN          68 // PA1
105
+#define HEATER_1_PIN           8 // PC22 on piggy
106
+#define HEATER_2_PIN           9 // PC21 on piggy
107
+#define HEATER_3_PIN          97 // PC20 on piggy
108
+#define HEATER_BED_PIN        69 // PA0
109
+
110
+#define FAN_PIN               92 // PA5
111
+#define FAN1_PIN              31 // PA7
112
+
113
+//
114
+// Misc. Functions
115
+//
116
+#define SDSS                  77 // PA28
117
+#define SD_DETECT_PIN         87 // PA29
118
+#define LED_RED_PIN           40 // PC8
119
+#define LED_GREEN_PIN         41 // PC9
120
+
121
+#define EXP_VOLTAGE_LEVEL_PIN 65
122
+
123
+#define SPI_CHAN_DAC           1
124
+
125
+#define DAC0_SYNC             53 // PB14
126
+#define DAC1_SYNC              6 // PC24
127
+
128
+// 64K SPI EEPROM
129
+#define SPI_EEPROM
130
+#define SPI_CHAN_EEPROM1       2
131
+#define SPI_EEPROM1_CS        25 // PD0
132
+
133
+// 2K SPI EEPROM
134
+#define SPI_EEPROM2_CS        26 // PD1
135
+
136
+// FLASH SPI
137
+// 32Mb
138
+#define SPI_FLASH_CS          23 // PA14
139
+
140
+//
141
+// LCD / Controller
142
+//
143
+#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
144
+
145
+  #define LCD_PINS_RS         18
146
+  #define LCD_PINS_ENABLE     15
147
+  #define LCD_PINS_D4         19
148
+  #define BEEPER_PIN          64
149
+
150
+  #define BTN_EN1             14
151
+  #define BTN_EN2             16
152
+  #define BTN_ENC             17
153
+
154
+  #if UI_VOLTAGE_LEVEL != 1
155
+    #undef UI_VOLTAGE_LEVEL
156
+    #define UI_VOLTAGE_LEVEL   1
157
+  #endif
158
+
159
+#endif // REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER

+ 164
- 0
Marlin/pins_DUE3DOM.h View File

@@ -0,0 +1,164 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 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
+ * DUE3DOM pin assignments
25
+ */
26
+
27
+#ifndef __SAM3X8E__
28
+  #error "Oops!  Make sure you have 'Arduino Due' selected from the 'Tools -> Boards' menu."
29
+#endif
30
+
31
+#define BOARD_NAME "DUE3DOM"
32
+
33
+//
34
+// Servos
35
+//
36
+#define SERVO0_PIN          5
37
+#define SERVO1_PIN          6
38
+#define SERVO2_PIN         13
39
+#define SERVO3_PIN         -1
40
+
41
+//
42
+// Limit Switches
43
+//
44
+#define X_MIN_PIN          38
45
+#define X_MAX_PIN          36
46
+#define Y_MIN_PIN          34
47
+#define Y_MAX_PIN          32
48
+#define Z_MIN_PIN          30
49
+#define Z_MAX_PIN          28
50
+
51
+//
52
+// Steppers
53
+//
54
+#define X_STEP_PIN          2
55
+#define X_DIR_PIN           3
56
+#define X_ENABLE_PIN       22
57
+
58
+#define Y_STEP_PIN         17
59
+#define Y_DIR_PIN          16
60
+#define Y_ENABLE_PIN       26
61
+
62
+#define Z_STEP_PIN         61 // Z1 STP
63
+#define Z_DIR_PIN          60 // Z1 DIR
64
+#define Z_ENABLE_PIN       15 // Z1 ENA
65
+
66
+#define E0_STEP_PIN        64 // Z2 STP
67
+#define E0_DIR_PIN         63 // Z2 DIR
68
+#define E0_ENABLE_PIN      62 // Z2 ENA
69
+
70
+#define E1_STEP_PIN        51 // E1 STP
71
+#define E1_DIR_PIN         53 // E1 DIR
72
+#define E1_ENABLE_PIN      65 // E1 ENA
73
+
74
+#define E2_STEP_PIN        24 // E2 STP
75
+#define E2_DIR_PIN         23 // E2 DIR
76
+#define E2_ENABLE_PIN      49 // E2 ENA
77
+
78
+//
79
+// Temperature Sensors
80
+//
81
+#define TEMP_0_PIN          0   // Analog Input (HOTEND0 thermistor)
82
+#define TEMP_1_PIN          2   // Analog Input (HOTEND1 thermistor)
83
+#define TEMP_2_PIN          5   // Analog Input (unused)
84
+#define TEMP_BED_PIN        1   // Analog Input (BED thermistor)
85
+
86
+// SPI for Max6675 or Max31855 Thermocouple
87
+#if DISABLED(SDSUPPORT)
88
+  #define MAX6675_SS        -1
89
+#else
90
+  #define MAX6675_SS        -1
91
+#endif
92
+
93
+//
94
+// Heaters / Fans
95
+//
96
+#define HEATER_0_PIN        7 // HOTEND0 MOSFET
97
+#define HEATER_1_PIN        8 // HOTEND1 MOSFET
98
+#define HEATER_BED_PIN     39 // BED MOSFET
99
+
100
+#define FAN_PIN            11 // FAN1 header on board - PRINT FAN
101
+#define FAN1_PIN            9 // FAN2 header on board - CONTROLLER FAN
102
+#define FAN2_PIN           12 // FAN3 header on board - EXTRUDER0 FAN
103
+
104
+//
105
+// Misc. Functions
106
+//
107
+#define SDSS                4
108
+#define PS_ON_PIN          40
109
+
110
+//
111
+// LCD / Controller
112
+//
113
+#if ENABLED(ULTRA_LCD)
114
+  #define LCD_PINS_RS       42
115
+  #define LCD_PINS_ENABLE   43
116
+  #define LCD_PINS_D4       44
117
+  #define LCD_PINS_D5       45
118
+  #define LCD_PINS_D6       46
119
+  #define LCD_PINS_D7       47
120
+
121
+  #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER)
122
+    #define BEEPER_PIN      41
123
+
124
+    #define BTN_EN1         50
125
+    #define BTN_EN2         52
126
+    #define BTN_ENC         48    
127
+
128
+    #define SDSS             4
129
+    #define SD_DETECT_PIN   14
130
+
131
+  // RADDS LCD panel
132
+  #elif ENABLED(RADDS_DISPLAY)
133
+    #define BEEPER_PIN      41
134
+
135
+    #define BTN_EN1         50
136
+    #define BTN_EN2         52
137
+    #define BTN_ENC         48
138
+      
139
+    #define BTN_BACK        71
140
+    
141
+    #undef SDSS
142
+    #define SDSS             4
143
+    #define SD_DETECT_PIN   14
144
+
145
+  #elif ENABLED(SSD1306_OLED_I2C_CONTROLLER)
146
+    #define BTN_EN1         50
147
+    #define BTN_EN2         52
148
+    #define BTN_ENC         48
149
+    #define BEEPER_PIN      41
150
+    #define LCD_SDSS         4
151
+    #define SD_DETECT_PIN   14
152
+
153
+  #elif ENABLED(SPARK_FULL_GRAPHICS)
154
+    #define LCD_PINS_D4     29
155
+    #define LCD_PINS_ENABLE 27
156
+    #define LCD_PINS_RS     25
157
+
158
+    #define BTN_EN1         35
159
+    #define BTN_EN2         33
160
+    #define BTN_ENC         37
161
+
162
+    #define BEEPER_PIN      -1
163
+  #endif // SPARK_FULL_GRAPHICS
164
+#endif // ULTRA_LCD

+ 156
- 0
Marlin/pins_DUE3DOM_MINI.h View File

@@ -0,0 +1,156 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 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
+ * DUE3DOM MINI pin assignments
25
+ */
26
+
27
+#ifndef __SAM3X8E__
28
+  #error "Oops!  Make sure you have 'Arduino Due' selected from the 'Tools -> Boards' menu."
29
+#endif
30
+
31
+#define BOARD_NAME "DUE3DOM MINI"
32
+
33
+//
34
+// Servos
35
+//
36
+#define SERVO0_PIN          5
37
+#define SERVO1_PIN          6
38
+#define SERVO2_PIN          8 // 4-pin header FAN0
39
+#define SERVO3_PIN         -1
40
+
41
+//
42
+// Limit Switches
43
+//
44
+#define X_MIN_PIN          38
45
+#define X_MAX_PIN          -1
46
+#define Y_MIN_PIN          34
47
+#define Y_MAX_PIN          -1
48
+#define Z_MIN_PIN          30
49
+#define Z_MAX_PIN          -1
50
+
51
+//
52
+// Steppers
53
+//
54
+#define X_STEP_PIN         17
55
+#define X_DIR_PIN          16
56
+#define X_ENABLE_PIN       22
57
+
58
+#define Y_STEP_PIN          2
59
+#define Y_DIR_PIN           3
60
+#define Y_ENABLE_PIN       26
61
+
62
+#define Z_STEP_PIN         64
63
+#define Z_DIR_PIN          63
64
+#define Z_ENABLE_PIN       15
65
+
66
+#define E0_STEP_PIN        61
67
+#define E0_DIR_PIN         60
68
+#define E0_ENABLE_PIN      62
69
+
70
+//
71
+// Temperature Sensors
72
+//
73
+#define TEMP_0_PIN          0   // Analog Input (HOTEND0 thermistor)
74
+#define TEMP_1_PIN          2   // Analog Input (unused)
75
+#define TEMP_2_PIN          5   // Analog Input (OnBoard thermistor beta 3950)
76
+#define TEMP_BED_PIN        1   // Analog Input (BED thermistor)
77
+
78
+// SPI for Max6675 or Max31855 Thermocouple
79
+#if DISABLED(SDSUPPORT)
80
+  #define MAX6675_SS        53
81
+#else
82
+  #define MAX6675_SS        53
83
+#endif
84
+
85
+//
86
+// Heaters / Fans
87
+//
88
+#define HEATER_0_PIN       13 // HOTEND0 MOSFET
89
+#define HEATER_BED_PIN      7 // BED MOSFET
90
+
91
+#define FAN_PIN            11 // FAN1 header on board - PRINT FAN
92
+#define FAN1_PIN           12 // FAN2 header on board - CONTROLLER FAN
93
+#define FAN2_PIN            9 // FAN3 header on board - EXTRUDER0 FAN
94
+//#define FAN3_PIN          8 // FAN0 4-pin header on board
95
+
96
+//
97
+// Misc. Functions
98
+//
99
+#define SDSS                4
100
+#define PS_ON_PIN          40
101
+
102
+//
103
+// LCD / Controller
104
+//
105
+#if ENABLED(ULTRA_LCD)
106
+  #define LCD_PINS_RS       42
107
+  #define LCD_PINS_ENABLE   43
108
+  #define LCD_PINS_D4       44
109
+  #define LCD_PINS_D5       45
110
+  #define LCD_PINS_D6       46
111
+  #define LCD_PINS_D7       47
112
+
113
+  #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER)
114
+    #define BEEPER_PIN      41
115
+
116
+    #define BTN_EN1         50
117
+    #define BTN_EN2         52
118
+    #define BTN_ENC         48    
119
+
120
+    #define SDSS             4
121
+    #define SD_DETECT_PIN   14
122
+
123
+  // RADDS LCD panel
124
+  #elif ENABLED(RADDS_DISPLAY)
125
+    #define BEEPER_PIN      41
126
+
127
+    #define BTN_EN1         50
128
+    #define BTN_EN2         52
129
+    #define BTN_ENC         48
130
+      
131
+    #define BTN_BACK        71
132
+    
133
+    #undef SDSS
134
+    #define SDSS             4
135
+    #define SD_DETECT_PIN   14
136
+
137
+  #elif ENABLED(SSD1306_OLED_I2C_CONTROLLER)
138
+    #define BTN_EN1         50
139
+    #define BTN_EN2         52
140
+    #define BTN_ENC         48
141
+    #define BEEPER_PIN      41
142
+    #define LCD_SDSS         4
143
+    #define SD_DETECT_PIN   14
144
+
145
+  #elif ENABLED(SPARK_FULL_GRAPHICS)
146
+    #define LCD_PINS_D4     29
147
+    #define LCD_PINS_ENABLE 27
148
+    #define LCD_PINS_RS     25
149
+
150
+    #define BTN_EN1         35
151
+    #define BTN_EN2         33
152
+    #define BTN_ENC         37
153
+
154
+    #define BEEPER_PIN      -1
155
+  #endif // SPARK_FULL_GRAPHICS
156
+#endif // ULTRA_LCD

+ 193
- 0
Marlin/pins_RADDS.h View File

@@ -0,0 +1,193 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 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
+ * RADDS
25
+ */
26
+
27
+#ifndef __SAM3X8E__
28
+  #error "Oops!  Make sure you have 'Arduino Due' selected from the 'Tools -> Boards' menu."
29
+#endif
30
+
31
+#define BOARD_NAME         "RADDS"
32
+
33
+//
34
+// Servos
35
+//
36
+#define SERVO0_PIN          5
37
+#define SERVO1_PIN          6
38
+#define SERVO2_PIN         39
39
+#define SERVO3_PIN         40
40
+
41
+//
42
+// Limit Switches
43
+//
44
+#define X_MIN_PIN          28
45
+#define X_MAX_PIN          34
46
+#define Y_MIN_PIN          30
47
+#define Y_MAX_PIN          36
48
+#define Z_MIN_PIN          32
49
+#define Z_MAX_PIN          38
50
+
51
+//
52
+// Steppers
53
+//
54
+#define X_STEP_PIN         24
55
+#define X_DIR_PIN          23
56
+#define X_ENABLE_PIN       26
57
+#define X_CS_PIN           25
58
+
59
+#define Y_STEP_PIN         17
60
+#define Y_DIR_PIN          16
61
+#define Y_ENABLE_PIN       22
62
+#define Y_CS_PIN           27
63
+
64
+#define Z_STEP_PIN          2
65
+#define Z_DIR_PIN           3
66
+#define Z_ENABLE_PIN       15
67
+#define Z_CS_PIN           29
68
+
69
+#define E0_STEP_PIN        61
70
+#define E0_DIR_PIN         60
71
+#define E0_ENABLE_PIN      62
72
+#define E0_CS_PIN          31
73
+
74
+#define E1_STEP_PIN        64
75
+#define E1_DIR_PIN         63
76
+#define E1_ENABLE_PIN      65
77
+#define E1_CS_PIN          33
78
+
79
+#define E2_STEP_PIN        51
80
+#define E2_DIR_PIN         53
81
+#define E2_ENABLE_PIN      49
82
+#define E2_CS_PIN          35
83
+
84
+// For Extension Board V2
85
+// http://doku.radds.org/dokumentation/extension-board
86
+//#define E3_STEP_PIN        35
87
+//#define E3_DIR_PIN         33
88
+//#define E3_ENABLE_PIN      37
89
+//#define E3_CS_PIN           6
90
+
91
+//#define Z2_STEP_PIN        29
92
+//#define Z2_DIR_PIN         27
93
+//#define Z2_ENABLE_PIN      31
94
+//#define Z2_CS_PIN          39
95
+
96
+// Microstepping pins - Mapping not from fastio.h (?)
97
+//#define E3_MS1_PIN         67
98
+//#define E3_MS2_PIN         68
99
+//#define E3_MS3_PIN         69
100
+//#define Z2_MS1_PIN         67 // shared with E3_MS1_PIN
101
+//#define Z2_MS2_PIN         68 // shared with E3_MS2_PIN
102
+//#define Z2_MS3_PIN         69 // shared with E3_MS3_PIN
103
+
104
+//
105
+// Temperature Sensors
106
+//
107
+#define TEMP_0_PIN          0   // Analog Input
108
+#define TEMP_1_PIN          1   // Analog Input
109
+#define TEMP_2_PIN          2   // Analog Input
110
+#define TEMP_3_PIN          3   // Analog Input
111
+#define TEMP_BED_PIN        4   // Analog Input
112
+
113
+// SPI for Max6675 or Max31855 Thermocouple
114
+#if DISABLED(SDSUPPORT)
115
+  #define MAX6675_SS        53
116
+#else
117
+  #define MAX6675_SS        49
118
+#endif
119
+
120
+//
121
+// Heaters / Fans
122
+//
123
+#define HEATER_0_PIN       13
124
+#define HEATER_1_PIN       12
125
+#define HEATER_2_PIN       11
126
+#define HEATER_BED_PIN      7 // BED
127
+
128
+#define FAN_PIN             9
129
+#define FAN1_PIN            8
130
+
131
+//
132
+// Misc. Functions
133
+//
134
+#define SDSS                4
135
+#define PS_ON_PIN          40
136
+
137
+#define I2C_EEPROM
138
+
139
+//
140
+// LCD / Controller
141
+//
142
+#if ENABLED(ULTRA_LCD)
143
+  // RADDS LCD panel
144
+  #if ENABLED(RADDS_DISPLAY)
145
+    #define LCD_PINS_RS     42
146
+    #define LCD_PINS_ENABLE 43
147
+    #define LCD_PINS_D4     44
148
+    #define LCD_PINS_D5     45
149
+    #define LCD_PINS_D6     46
150
+    #define LCD_PINS_D7     47
151
+
152
+    #define BEEPER_PIN      41
153
+
154
+    #define BTN_EN1         50
155
+    #define BTN_EN2         52
156
+    #define BTN_ENC         48
157
+
158
+    #define BTN_BACK        71
159
+
160
+    #undef SDSS
161
+    #define SDSS            10
162
+    #define SD_DETECT_PIN   14
163
+
164
+  #elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
165
+    #define LCD_PINS_RS     46
166
+    #define LCD_PINS_ENABLE 47
167
+    #define LCD_PINS_D4     44
168
+
169
+    #define BEEPER_PIN      41
170
+
171
+    #define BTN_EN1         50
172
+    #define BTN_EN2         52
173
+    #define BTN_ENC         48
174
+
175
+  #elif ENABLED(SSD1306_OLED_I2C_CONTROLLER)
176
+    #define BTN_EN1         50
177
+    #define BTN_EN2         52
178
+    #define BTN_ENC         48
179
+    #define BEEPER_PIN      41
180
+    #define LCD_SDSS        10
181
+    #define SD_DETECT_PIN   14
182
+
183
+  #elif ENABLED(SPARK_FULL_GRAPHICS)
184
+    #define LCD_PINS_D4     29
185
+    #define LCD_PINS_ENABLE 27
186
+    #define LCD_PINS_RS     25
187
+
188
+    #define BTN_EN1         35
189
+    #define BTN_EN2         33
190
+    #define BTN_ENC         37
191
+
192
+  #endif // SPARK_FULL_GRAPHICS
193
+#endif // ULTRA_LCD

+ 62
- 0
Marlin/pins_RAMPS4DUE.h View File

@@ -0,0 +1,62 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 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
+ * Arduino Mega or Due with RAMPS4DUE pin assignments
25
+ *
26
+ * Applies to the following boards:
27
+ *
28
+ *  RAMPS4DUE_EFB (Hotend, Fan, Bed)
29
+ *  RAMPS4DUE_EEB (Hotend0, Hotend1, Bed)
30
+ *  RAMPS4DUE_EFF (Hotend, Fan0, Fan1)
31
+ *  RAMPS4DUE_EEF (Hotend0, Hotend1, Fan)
32
+ *  RAMPS4DUE_SF  (Spindle, Controller Fan)
33
+ *
34
+ *  Differences between
35
+ *  RAMPS_14 | RAMPS4DUE
36
+ *       A13 | A9/D63 (shares the same pin with AUX2_4PIN)
37
+ *       A14 | A10/D64 (shares the same pin with AUX2_5PIN)
38
+ *       A15 | NC
39
+ */
40
+
41
+#if !defined(__SAM3X8E__) && !defined(__AVR_ATmega2560__)
42
+  #error "Oops!  Make sure you have 'Arduino Due' or 'Arduino Mega' selected from the 'Tools -> Boards' menu."
43
+#endif
44
+
45
+#ifndef BOARD_NAME
46
+  #define BOARD_NAME       "RAMPS4DUE"
47
+#endif
48
+
49
+#define IS_RAMPS4DUE
50
+#include "pins_RAMPS.h"
51
+
52
+//
53
+// Temperature Sensors
54
+//
55
+#undef TEMP_0_PIN
56
+#define TEMP_0_PIN          9   // Analog Input
57
+
58
+#undef TEMP_1_PIN
59
+#define TEMP_1_PIN         -1   // Analog Input
60
+
61
+#undef TEMP_BED_PIN
62
+#define TEMP_BED_PIN       10   // Analog Input

+ 123
- 0
Marlin/pins_RAMPS_DUO.h View File

@@ -0,0 +1,123 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 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
+ * Arduino Mega or Due with RAMPS Duo pin assignments
25
+ *
26
+ * Applies to the following boards:
27
+ *
28
+ *  RAMPS_DUO_EFB (Hotend, Fan, Bed)
29
+ *  RAMPS_DUO_EEB (Hotend0, Hotend1, Bed)
30
+ *  RAMPS_DUO_EFF (Hotend, Fan0, Fan1)
31
+ *  RAMPS_DUO_EEF (Hotend0, Hotend1, Fan)
32
+ *  RAMPS_DUO_SF  (Spindle, Controller Fan)
33
+ *
34
+ *  Differences between
35
+ *  RAMPS_14 | RAMPS_DUO
36
+ *    A9/D63 | A12/D66
37
+ *   A10/D64 | A13/D67
38
+ *   A11/D65 | A14/D68
39
+ *   A12/D66 | A15/D69
40
+ *       A13 | A9
41
+ *       A14 | A10
42
+ *       A15 | A11
43
+ */
44
+
45
+#if !defined(__SAM3X8E__) && !defined(__AVR_ATmega2560__)
46
+  #error "Oops!  Make sure you have 'Arduino Due' or 'Arduino Mega' selected from the 'Tools -> Boards' menu."
47
+#endif
48
+
49
+#ifndef BOARD_NAME
50
+  #define BOARD_NAME       "RAMPS Duo"
51
+#endif
52
+
53
+#define IS_RAMPS_DUO
54
+#include "pins_RAMPS.h"
55
+
56
+//
57
+// Temperature Sensors
58
+//
59
+#undef TEMP_0_PIN
60
+#define TEMP_0_PIN          9   // Analog Input
61
+
62
+#undef TEMP_1_PIN
63
+#define TEMP_1_PIN         11   // Analog Input
64
+
65
+#undef TEMP_BED_PIN
66
+#define TEMP_BED_PIN       10   // Analog Input
67
+
68
+// SPI for Max6675 or Max31855 Thermocouple
69
+#undef MAX6675_SS
70
+#if DISABLED(SDSUPPORT)
71
+  #define MAX6675_SS       69 // Do not use pin 53 if there is even the remote possibility of using Display/SD card
72
+#else
73
+  #define MAX6675_SS       69 // Do not use pin 49 as this is tied to the switch inside the SD card socket to detect if there is an SD card present
74
+#endif
75
+
76
+//
77
+// LCD / Controller
78
+//
79
+#if ENABLED(ULTRA_LCD)
80
+  #if ENABLED(NEWPANEL) && ENABLED(PANEL_ONE)
81
+    #undef LCD_PINS_D4
82
+    #define LCD_PINS_D4  68
83
+
84
+    #undef LCD_PINS_D5
85
+    #define LCD_PINS_D5  69
86
+
87
+    #undef LCD_PINS_D7
88
+    #define LCD_PINS_D7  67
89
+  #endif
90
+
91
+  #if ENABLED(NEWPANEL)
92
+    #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
93
+      #undef BTN_EN1
94
+      #define BTN_EN1 67
95
+
96
+      #undef BTN_ENC
97
+      #define BTN_ENC 66
98
+    #elif ENABLED(MINIPANEL)
99
+      #undef DOGLCD_CS
100
+      #define DOGLCD_CS    69
101
+
102
+      #undef LCD_BACKLIGHT_PIN
103
+      #define LCD_BACKLIGHT_PIN 68 // backlight LED on A14/D68
104
+
105
+      #undef KILL_PIN
106
+      #define KILL_PIN     67
107
+
108
+      #undef BTN_EN2
109
+      #define BTN_EN2      66
110
+    #else
111
+      #if ENABLED(REPRAPWORLD_KEYPAD)
112
+        #undef BTN_EN1
113
+        #define BTN_EN1    67 // encoder
114
+
115
+        #undef BTN_ENC
116
+        #define BTN_ENC    66 // enter button
117
+      #elif ENABLED(PANEL_ONE)
118
+        #undef BTN_EN2
119
+        #define BTN_EN2    66 // AUX2 PIN 4
120
+      #endif
121
+    #endif
122
+  #endif // NEWPANEL
123
+#endif // ULTRA_LCD

+ 148
- 0
Marlin/pins_RAMPS_FD.h View File

@@ -0,0 +1,148 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 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
+ * RAMPS-FD
25
+ *
26
+ * No EEPROM
27
+ * Use 4k7 thermistor tables
28
+ */
29
+
30
+#ifndef __SAM3X8E__
31
+  #error "Oops!  Make sure you have 'Arduino Due' selected from the 'Tools -> Boards' menu."
32
+#endif
33
+
34
+#ifndef BOARD_NAME
35
+  #define BOARD_NAME       "RAMPS-FD"
36
+#endif
37
+
38
+#define INVERTED_HEATER_PINS
39
+#define INVERTED_BED_PINS
40
+#define INVERTED_FAN_PINS
41
+
42
+//
43
+// Servos
44
+//
45
+#define SERVO0_PIN          7
46
+#define SERVO1_PIN          6
47
+#define SERVO2_PIN          5
48
+#define SERVO3_PIN          3
49
+
50
+//
51
+// Limit Switches
52
+//
53
+#define X_MIN_PIN          22
54
+#define X_MAX_PIN          30
55
+#define Y_MIN_PIN          24
56
+#define Y_MAX_PIN          38
57
+#define Z_MIN_PIN          26
58
+#define Z_MAX_PIN          34
59
+
60
+//
61
+// Steppers
62
+//
63
+#define X_STEP_PIN         63
64
+#define X_DIR_PIN          62
65
+#define X_ENABLE_PIN       48
66
+#define X_CS_PIN           68
67
+
68
+#define Y_STEP_PIN         65
69
+#define Y_DIR_PIN          64
70
+#define Y_ENABLE_PIN       46
71
+#define Y_CS_PIN           60
72
+
73
+#define Z_STEP_PIN         67
74
+#define Z_DIR_PIN          66
75
+#define Z_ENABLE_PIN       44
76
+#define Z_CS_PIN           58
77
+
78
+#define E0_STEP_PIN        36
79
+#define E0_DIR_PIN         28
80
+#define E0_ENABLE_PIN      42
81
+#define E0_CS_PIN          67
82
+
83
+#define E1_STEP_PIN        43
84
+#define E1_DIR_PIN         41
85
+#define E1_ENABLE_PIN      39
86
+#define E1_CS_PIN          61
87
+
88
+#define E2_STEP_PIN        32
89
+#define E2_DIR_PIN         47
90
+#define E2_ENABLE_PIN      45
91
+#define E2_CS_PIN          59
92
+
93
+//
94
+// Temperature Sensors
95
+//
96
+#define TEMP_0_PIN          1   // Analog Input
97
+#define TEMP_1_PIN          2   // Analog Input
98
+#define TEMP_2_PIN          3   // Analog Input
99
+#define TEMP_BED_PIN        0   // Analog Input
100
+
101
+// SPI for Max6675 or Max31855 Thermocouple
102
+#if DISABLED(SDSUPPORT)
103
+  #define MAX6675_SS            53
104
+#else
105
+  #define MAX6675_SS            49
106
+#endif
107
+
108
+//
109
+// Heaters / Fans
110
+//
111
+#define HEATER_0_PIN        9
112
+#define HEATER_1_PIN       10
113
+#define HEATER_2_PIN       11
114
+#define HEATER_BED_PIN      8 // BED
115
+
116
+#define FAN_PIN            12
117
+#define CONTROLLER_FAN_PIN -1
118
+
119
+//
120
+// Misc. Functions
121
+//
122
+#define SDSS                4
123
+#define LED_PIN            13
124
+
125
+//
126
+// LCD / Controller
127
+//
128
+#if ENABLED(ULTRA_LCD)
129
+  #if ENABLED(NEWPANEL)
130
+    // ramps-fd lcd adaptor
131
+    #define LCD_PINS_RS         16
132
+    #define LCD_PINS_ENABLE     17
133
+    #define LCD_PINS_D4         23
134
+    #define LCD_PINS_D5         25
135
+    #define LCD_PINS_D6         27
136
+    #define LCD_PINS_D7         29
137
+
138
+    #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER)
139
+      #define BEEPER_PIN        37
140
+
141
+      #define BTN_EN1           33
142
+      #define BTN_EN2           31
143
+      #define BTN_ENC           35
144
+
145
+      #define SD_DETECT_PIN     49
146
+    #endif
147
+  #endif
148
+#endif // ULTRA_LCD

+ 38
- 0
Marlin/pins_RAMPS_FD_V2.h View File

@@ -0,0 +1,38 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 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
+ * RAMPS-FD v2
25
+ *
26
+ * EEPROM supported
27
+ * Use 1k thermistor tables
28
+ */
29
+
30
+#define BOARD_NAME         "RAMPS-FD v2"
31
+
32
+#include "pins_RAMPS_FD.h"
33
+
34
+#undef INVERTED_HEATER_PINS
35
+#undef INVERTED_BED_PINS
36
+#undef INVERTED_FAN_PINS
37
+
38
+#define I2C_EEPROM

+ 113
- 0
Marlin/pins_RAMPS_SMART.h View File

@@ -0,0 +1,113 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 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
+ * Arduino Due with RAMPS-SMART pin assignments
25
+ *
26
+ * Applies to the following boards:
27
+ *
28
+ *  RAMPS_SMART_EFB (Hotend, Fan, Bed)
29
+ *  RAMPS_SMART_EEB (Hotend0, Hotend1, Bed)
30
+ *  RAMPS_SMART_EFF (Hotend, Fan0, Fan1)
31
+ *  RAMPS_SMART_EEF (Hotend0, Hotend1, Fan)
32
+ *  RAMPS_SMART_SF  (Spindle, Controller Fan)
33
+ *
34
+ *  Differences between
35
+ *  RAMPS_14 | RAMPS-SMART
36
+ *      NONE | D16 (Additional AUX-3 pin(AUX3_2PIN), shares the same pin with AUX4_18PIN)
37
+ *      NONE | D17 (Additional AUX-3 pin(AUX3_1PIN), shares the same pin with AUX4_17PIN)
38
+ *        D0 | NONE
39
+ *        D1 | NONE
40
+ *    A3/D57 | NONE
41
+ *    A4/D58 | NONE
42
+ *    A5/D59 | A3/D57
43
+ *    A9/D63 | A4/D58
44
+ *   A10/D64 | A5/D59
45
+ *   A11/D65 | D66
46
+ *   A12/D66 | D67
47
+ *       A13 | A9
48
+ *       A14 | A10
49
+ *       A15 | A11
50
+ */
51
+
52
+#ifndef __SAM3X8E__
53
+  #error "Oops!  Make sure you have 'Arduino Due' selected from the 'Tools -> Boards' menu."
54
+#endif
55
+
56
+#ifndef BOARD_NAME
57
+  #define BOARD_NAME       "RAMPS-SMART"
58
+#endif
59
+
60
+#define IS_RAMPS_SMART
61
+#include "pins_RAMPS.h"
62
+
63
+//
64
+// Temperature Sensors
65
+//
66
+#undef TEMP_0_PIN
67
+#define TEMP_0_PIN          9   // Analog Input
68
+
69
+#undef TEMP_1_PIN
70
+#define TEMP_1_PIN         10   // Analog Input
71
+
72
+#undef TEMP_BED_PIN
73
+#define TEMP_BED_PIN       11   // Analog Input
74
+
75
+// SPI for Max6675 or Max31855 Thermocouple
76
+#if DISABLED(SDSUPPORT)
77
+  #undef MAX6675_SS
78
+  #define MAX6675_SS       67 // Do not use pin 53 if there is even the remote possibility of using Display/SD card
79
+#else
80
+  #undef MAX6675_SS
81
+  #define MAX6675_SS       67 // Do not use pin 49 as this is tied to the switch inside the SD card socket to detect if there is an SD card present
82
+#endif
83
+
84
+//
85
+// LCD / Controller
86
+//
87
+// Support for AZSMZ 12864 LCD with SD Card 3D printer smart controller control panel (not tested)
88
+#if ENABLED(VIKI2)
89
+  #undef BEEPER_PIN
90
+  #define BEEPER_PIN       66
91
+
92
+  // Pins for DOGM SPI LCD Support
93
+  #undef DOGLCD_A0
94
+  #define DOGLCD_A0        59
95
+
96
+  #undef DOGLCD_A0
97
+  #define DOGLCD_CS        44
98
+
99
+  #undef BTN_EN1
100
+  #define BTN_EN1          58
101
+
102
+  #undef BTN_EN2
103
+  #define BTN_EN2          40
104
+
105
+  #undef BTN_ENC
106
+  #define BTN_ENC          67
107
+
108
+  #undef SD_DETECT_PIN
109
+  #define SD_DETECT_PIN    49 // Pin 49 for display sd interface, 72 for easy adapter board
110
+
111
+  #undef KILL_PIN
112
+  #define KILL_PIN         42
113
+#endif

+ 124
- 0
Marlin/src/HAL/HAL_DUE/HAL_Due.cpp View File

@@ -0,0 +1,124 @@
1
+/* **************************************************************************
2
+ 
3
+ Marlin 3D Printer Firmware
4
+ Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5
+ Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.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 <http://www.gnu.org/licenses/>.
19
+****************************************************************************/
20
+
21
+
22
+/**
23
+ * Description: HAL for Arduino Due and compatible (SAM3X8E)
24
+ *
25
+ * For ARDUINO_ARCH_SAM
26
+ */
27
+
28
+#ifdef ARDUINO_ARCH_SAM
29
+
30
+// --------------------------------------------------------------------------
31
+// Includes
32
+// --------------------------------------------------------------------------
33
+
34
+#include "../HAL.h"
35
+
36
+#include <Wire.h>
37
+
38
+// --------------------------------------------------------------------------
39
+// Externals
40
+// --------------------------------------------------------------------------
41
+
42
+// --------------------------------------------------------------------------
43
+// Local defines
44
+// --------------------------------------------------------------------------
45
+
46
+// --------------------------------------------------------------------------
47
+// Types
48
+// --------------------------------------------------------------------------
49
+
50
+// --------------------------------------------------------------------------
51
+// Variables
52
+// --------------------------------------------------------------------------
53
+
54
+// --------------------------------------------------------------------------
55
+// Public Variables
56
+// --------------------------------------------------------------------------
57
+
58
+uint16_t HAL_adc_result;
59
+
60
+// --------------------------------------------------------------------------
61
+// Private Variables
62
+// --------------------------------------------------------------------------
63
+
64
+// --------------------------------------------------------------------------
65
+// Function prototypes
66
+// --------------------------------------------------------------------------
67
+
68
+// --------------------------------------------------------------------------
69
+// Private functions
70
+// --------------------------------------------------------------------------
71
+
72
+// --------------------------------------------------------------------------
73
+// Public functions
74
+// --------------------------------------------------------------------------
75
+
76
+// disable interrupts
77
+void cli(void) { noInterrupts(); }
78
+
79
+// enable interrupts
80
+void sei(void) { interrupts(); }
81
+
82
+void HAL_clear_reset_source(void) { }
83
+
84
+uint8_t HAL_get_reset_source (void) {
85
+  switch ((RSTC->RSTC_SR >> 8) & 7) {
86
+    case 0: return RST_POWER_ON; break;
87
+    case 1: return RST_BACKUP; break;
88
+    case 2: return RST_WATCHDOG; break;
89
+    case 3: return RST_SOFTWARE; break;
90
+    case 4: return RST_EXTERNAL; break;
91
+    default:
92
+      return 0;
93
+  }
94
+}
95
+
96
+void _delay_ms(int delay_ms) {
97
+  //todo: port for Due?
98
+  delay (delay_ms);
99
+}
100
+
101
+extern "C" {
102
+  extern unsigned int _ebss; // end of bss section
103
+}
104
+
105
+// return free memory between end of heap (or end bss) and whatever is current
106
+int freeMemory() {
107
+  int free_memory, heap_end = (int)_sbrk(0);
108
+  return (int)&free_memory - (heap_end ? heap_end : (int)&_ebss);
109
+}
110
+
111
+// --------------------------------------------------------------------------
112
+// ADC
113
+// --------------------------------------------------------------------------
114
+
115
+void HAL_adc_start_conversion (uint8_t adc_pin) {
116
+  HAL_adc_result = analogRead(adc_pin);
117
+}
118
+
119
+uint16_t HAL_adc_get_result(void) {
120
+  // nop
121
+  return HAL_adc_result;
122
+}
123
+
124
+#endif // ARDUINO_ARCH_SAM

+ 169
- 0
Marlin/src/HAL/HAL_DUE/HAL_Due.h View File

@@ -0,0 +1,169 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ *
4
+ * Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * Description: HAL for Arduino Due and compatible (SAM3X8E)
25
+ *
26
+ * For ARDUINO_ARCH_SAM
27
+ */
28
+
29
+#ifndef _HAL_DUE_H
30
+#define _HAL_DUE_H
31
+
32
+// --------------------------------------------------------------------------
33
+// Includes
34
+// --------------------------------------------------------------------------
35
+
36
+#include <stdint.h>
37
+
38
+#include "Arduino.h"
39
+
40
+#include "fastio_Due.h"
41
+#include "watchdog_Due.h"
42
+
43
+#include "HAL_timers_Due.h"
44
+
45
+// --------------------------------------------------------------------------
46
+// Defines
47
+// --------------------------------------------------------------------------
48
+
49
+#if SERIAL_PORT == -1
50
+  #define MYSERIAL SerialUSB
51
+#elif SERIAL_PORT == 0
52
+  #define MYSERIAL Serial
53
+#elif SERIAL_PORT == 1
54
+  #define MYSERIAL Serial1
55
+#elif SERIAL_PORT == 2
56
+  #define MYSERIAL Serial2
57
+#elif SERIAL_PORT == 3
58
+  #define MYSERIAL Serial3
59
+#endif
60
+
61
+#define _BV(bit) (1 << (bit))
62
+
63
+#ifndef analogInputToDigitalPin
64
+  #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
65
+#endif
66
+
67
+#define CRITICAL_SECTION_START  uint32_t primask = __get_PRIMASK(); __disable_irq();
68
+#define CRITICAL_SECTION_END    if (!primask) __enable_irq();
69
+
70
+// On AVR this is in math.h?
71
+#define square(x) ((x)*(x))
72
+
73
+#ifndef strncpy_P
74
+  #define strncpy_P(dest, src, num) strncpy((dest), (src), (num))
75
+#endif
76
+
77
+// Fix bug in pgm_read_ptr
78
+#undef pgm_read_ptr
79
+#define pgm_read_ptr(addr) (*(addr))
80
+
81
+#define RST_POWER_ON   1
82
+#define RST_EXTERNAL   2
83
+#define RST_BROWN_OUT  4
84
+#define RST_WATCHDOG   8
85
+#define RST_JTAG       16
86
+#define RST_SOFTWARE   32
87
+#define RST_BACKUP     64
88
+
89
+// --------------------------------------------------------------------------
90
+// Types
91
+// --------------------------------------------------------------------------
92
+
93
+
94
+// --------------------------------------------------------------------------
95
+// Public Variables
96
+// --------------------------------------------------------------------------
97
+
98
+/** result of last ADC conversion */
99
+extern uint16_t HAL_adc_result;
100
+
101
+// --------------------------------------------------------------------------
102
+// Public functions
103
+// --------------------------------------------------------------------------
104
+
105
+// Disable interrupts
106
+void cli(void);
107
+
108
+// Enable interrupts
109
+void sei(void);
110
+
111
+/** clear reset reason */
112
+void HAL_clear_reset_source (void);
113
+
114
+/** reset reason */
115
+uint8_t HAL_get_reset_source (void);
116
+
117
+void _delay_ms(int delay);
118
+
119
+int freeMemory(void);
120
+
121
+// SPI: Extended functions which take a channel number (hardware SPI only)
122
+/** Write single byte to specified SPI channel */
123
+void spiSend(uint32_t chan, byte b);
124
+/** Write buffer to specified SPI channel */
125
+void spiSend(uint32_t chan, const uint8_t* buf, size_t n);
126
+/** Read single byte from specified SPI channel */
127
+uint8_t spiRec(uint32_t chan);
128
+
129
+
130
+// EEPROM
131
+void eeprom_write_byte(unsigned char *pos, unsigned char value);
132
+unsigned char eeprom_read_byte(unsigned char *pos);
133
+void eeprom_read_block (void *__dst, const void *__src, size_t __n);
134
+void eeprom_update_block (const void *__src, void *__dst, size_t __n);
135
+
136
+
137
+// ADC
138
+
139
+#define HAL_ANALOG_SELECT(pin)
140
+
141
+inline void HAL_adc_init(void) {}//todo
142
+
143
+#define HAL_START_ADC(pin)  HAL_adc_start_conversion(pin)
144
+#define HAL_READ_ADC        HAL_adc_result
145
+
146
+
147
+void HAL_adc_start_conversion (uint8_t adc_pin);
148
+
149
+uint16_t HAL_adc_get_result(void);
150
+
151
+//
152
+uint16_t HAL_getAdcReading(uint8_t chan);
153
+
154
+void HAL_startAdcConversion(uint8_t chan);
155
+uint8_t HAL_pinToAdcChannel(int pin);
156
+
157
+uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
158
+//uint16_t HAL_getAdcSuperSample(uint8_t chan);
159
+
160
+void HAL_enable_AdcFreerun(void);
161
+//void HAL_disable_AdcFreerun(uint8_t chan);
162
+
163
+
164
+// --------------------------------------------------------------------------
165
+//
166
+// --------------------------------------------------------------------------
167
+
168
+#endif // _HAL_DUE_H
169
+

+ 336
- 0
Marlin/src/HAL/HAL_DUE/HAL_spi_Due.cpp View File

@@ -0,0 +1,336 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 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
+ * Software SPI functions originally from Arduino Sd2Card Library
25
+ * Copyright (C) 2009 by William Greiman
26
+ */
27
+
28
+/**
29
+ * Description: HAL for Arduino Due and compatible (SAM3X8E)
30
+ *
31
+ * For ARDUINO_ARCH_SAM
32
+ */
33
+
34
+#ifdef ARDUINO_ARCH_SAM
35
+
36
+// --------------------------------------------------------------------------
37
+// Includes
38
+// --------------------------------------------------------------------------
39
+
40
+#include "../../../MarlinConfig.h"
41
+
42
+// --------------------------------------------------------------------------
43
+// Public Variables
44
+// --------------------------------------------------------------------------
45
+
46
+
47
+// --------------------------------------------------------------------------
48
+// Public functions
49
+// --------------------------------------------------------------------------
50
+
51
+#if ENABLED(SOFTWARE_SPI)
52
+  // --------------------------------------------------------------------------
53
+  // software SPI
54
+  // --------------------------------------------------------------------------
55
+  // bitbanging transfer
56
+  // run at ~100KHz (necessary for init)
57
+  static uint8_t spiTransfer(uint8_t b) { // using Mode 0
58
+    for (int bits = 0; bits < 8; bits++) {
59
+      if (b & 0x80) {
60
+        WRITE(MOSI_PIN, HIGH);
61
+      }
62
+      else {
63
+        WRITE(MOSI_PIN, LOW);
64
+      }
65
+      b <<= 1;
66
+
67
+      WRITE(SCK_PIN, HIGH);
68
+      delayMicroseconds(5U);
69
+
70
+      if (READ(MISO_PIN)) {
71
+        b |= 1;
72
+      }
73
+      WRITE(SCK_PIN, LOW);
74
+      delayMicroseconds(5U);
75
+    }
76
+    return b;
77
+  }
78
+
79
+  void spiBegin() {
80
+    SET_OUTPUT(SS_PIN);
81
+    WRITE(SS_PIN, HIGH);
82
+    SET_OUTPUT(SCK_PIN);
83
+    SET_INPUT(MISO_PIN);
84
+    SET_OUTPUT(MOSI_PIN);
85
+  }
86
+
87
+  void spiInit(uint8_t spiRate) {
88
+    UNUSED(spiRate);
89
+    WRITE(SS_PIN, HIGH);
90
+    WRITE(MOSI_PIN, HIGH);
91
+    WRITE(SCK_PIN, LOW);
92
+  }
93
+
94
+  uint8_t spiRec() {
95
+    WRITE(SS_PIN, LOW);
96
+    uint8_t b = spiTransfer(0xff);
97
+    WRITE(SS_PIN, HIGH);
98
+    return b;
99
+  }
100
+
101
+  void spiRead(uint8_t*buf, uint16_t nbyte) {
102
+    if (nbyte == 0) return;
103
+    WRITE(SS_PIN, LOW);
104
+    for (int i = 0; i < nbyte; i++) {
105
+      buf[i] = spiTransfer(0xff);
106
+    }
107
+    WRITE(SS_PIN, HIGH);
108
+  }
109
+
110
+  void spiSend(uint8_t b) {
111
+    WRITE(SS_PIN, LOW);
112
+    uint8_t response = spiTransfer(b);
113
+    UNUSED(response);
114
+    WRITE(SS_PIN, HIGH);
115
+  }
116
+
117
+  static void spiSend(const uint8_t* buf, size_t n) {
118
+    uint8_t response;
119
+    if (n == 0) return;
120
+    WRITE(SS_PIN, LOW);
121
+    for (uint16_t i = 0; i < n; i++) {
122
+      response = spiTransfer(buf[i]);
123
+    }
124
+    UNUSED(response);
125
+    WRITE(SS_PIN, HIGH);
126
+  }
127
+
128
+  void spiSendBlock(uint8_t token, const uint8_t* buf) {
129
+    uint8_t response;
130
+
131
+    WRITE(SS_PIN, LOW);
132
+    response = spiTransfer(token);
133
+
134
+    for (uint16_t i = 0; i < 512; i++) {
135
+      response = spiTransfer(buf[i]);
136
+    }
137
+    UNUSED(response);
138
+    WRITE(SS_PIN, HIGH);
139
+  }
140
+#else
141
+  // --------------------------------------------------------------------------
142
+  // hardware SPI
143
+  // --------------------------------------------------------------------------
144
+  // 8.4 MHz, 4 MHz, 2 MHz, 1 MHz, 0.5 MHz, 0.329 MHz, 0.329 MHz
145
+  int spiDueDividors[] = { 10, 21, 42, 84, 168, 255, 255 };
146
+  bool spiInitMaded = false;
147
+
148
+  void spiBegin() {
149
+    if(spiInitMaded == false) {
150
+      // Configure SPI pins
151
+      PIO_Configure(
152
+         g_APinDescription[SCK_PIN].pPort,
153
+         g_APinDescription[SCK_PIN].ulPinType,
154
+         g_APinDescription[SCK_PIN].ulPin,
155
+         g_APinDescription[SCK_PIN].ulPinConfiguration);
156
+      PIO_Configure(
157
+         g_APinDescription[MOSI_PIN].pPort,
158
+         g_APinDescription[MOSI_PIN].ulPinType,
159
+         g_APinDescription[MOSI_PIN].ulPin,
160
+         g_APinDescription[MOSI_PIN].ulPinConfiguration);
161
+      PIO_Configure(
162
+         g_APinDescription[MISO_PIN].pPort,
163
+         g_APinDescription[MISO_PIN].ulPinType,
164
+         g_APinDescription[MISO_PIN].ulPin,
165
+         g_APinDescription[MISO_PIN].ulPinConfiguration);
166
+
167
+      // set master mode, peripheral select, fault detection
168
+      SPI_Configure(SPI0, ID_SPI0, SPI_MR_MSTR | SPI_MR_MODFDIS | SPI_MR_PS);
169
+      SPI_Enable(SPI0);
170
+
171
+      #if MB(ALLIGATOR)
172
+        SET_OUTPUT(DAC0_SYNC);
173
+        #if EXTRUDERS > 1
174
+          SET_OUTPUT(DAC1_SYNC);
175
+          WRITE(DAC1_SYNC, HIGH);
176
+        #endif
177
+        SET_OUTPUT(SPI_EEPROM1_CS);
178
+        SET_OUTPUT(SPI_EEPROM2_CS);
179
+        SET_OUTPUT(SPI_FLASH_CS);
180
+        WRITE(DAC0_SYNC, HIGH);
181
+        WRITE(SPI_EEPROM1_CS, HIGH );
182
+        WRITE(SPI_EEPROM2_CS, HIGH );
183
+        WRITE(SPI_FLASH_CS, HIGH );
184
+        WRITE(SS_PIN, HIGH );
185
+      #endif // MB(ALLIGATOR)
186
+
187
+      PIO_Configure(
188
+        g_APinDescription[SPI_PIN].pPort,
189
+        g_APinDescription[SPI_PIN].ulPinType,
190
+        g_APinDescription[SPI_PIN].ulPin,
191
+        g_APinDescription[SPI_PIN].ulPinConfiguration);
192
+      spiInit(1);
193
+      spiInitMaded = true;
194
+    }
195
+  }
196
+
197
+  void spiInit(uint8_t spiRate) {
198
+    if(spiInitMaded == false) {
199
+      if(spiRate > 6) spiRate = 1;
200
+
201
+      #if MB(ALLIGATOR)
202
+        // Set SPI mode 1, clock, select not active after transfer, with delay between transfers  
203
+        SPI_ConfigureNPCS(SPI0, SPI_CHAN_DAC,
204
+                          SPI_CSR_CSAAT | SPI_CSR_SCBR(spiDueDividors[spiRate]) |
205
+                          SPI_CSR_DLYBCT(1));
206
+        // Set SPI mode 0, clock, select not active after transfer, with delay between transfers 
207
+        SPI_ConfigureNPCS(SPI0, SPI_CHAN_EEPROM1, SPI_CSR_NCPHA |
208
+                          SPI_CSR_CSAAT | SPI_CSR_SCBR(spiDueDividors[spiRate]) |
209
+                          SPI_CSR_DLYBCT(1));
210
+      #endif//MB(ALLIGATOR)
211
+
212
+      // Set SPI mode 0, clock, select not active after transfer, with delay between transfers
213
+      SPI_ConfigureNPCS(SPI0, SPI_CHAN, SPI_CSR_NCPHA |
214
+                        SPI_CSR_CSAAT | SPI_CSR_SCBR(spiDueDividors[spiRate]) |
215
+                        SPI_CSR_DLYBCT(1));
216
+      SPI_Enable(SPI0);
217
+      spiInitMaded = true;
218
+    }
219
+  }
220
+
221
+  // Write single byte to SPI
222
+  void spiSend(byte b) {
223
+    // write byte with address and end transmission flag
224
+    SPI0->SPI_TDR = (uint32_t)b | SPI_PCS(SPI_CHAN) | SPI_TDR_LASTXFER;
225
+    // wait for transmit register empty
226
+    while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
227
+    // wait for receive register
228
+    while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
229
+    // clear status
230
+    SPI0->SPI_RDR;
231
+    //delayMicroseconds(1U);
232
+  }
233
+
234
+  void spiSend(const uint8_t* buf, size_t n) {
235
+    if (n == 0) return;
236
+    for (size_t i = 0; i < n - 1; i++) {
237
+      SPI0->SPI_TDR = (uint32_t)buf[i] | SPI_PCS(SPI_CHAN);
238
+      while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
239
+      while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
240
+      SPI0->SPI_RDR;
241
+      //delayMicroseconds(1U);
242
+    }
243
+    spiSend(buf[n - 1]);
244
+  }
245
+
246
+  void spiSend(uint32_t chan, byte b) {
247
+    uint8_t dummy_read = 0;
248
+    // wait for transmit register empty
249
+    while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
250
+    // write byte with address and end transmission flag
251
+    SPI0->SPI_TDR = (uint32_t)b | SPI_PCS(chan) | SPI_TDR_LASTXFER;
252
+    // wait for receive register
253
+    while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
254
+    // clear status
255
+    while ((SPI0->SPI_SR & SPI_SR_RDRF) == 1)
256
+      dummy_read = SPI0->SPI_RDR;
257
+    UNUSED(dummy_read);
258
+  }
259
+
260
+  void spiSend(uint32_t chan, const uint8_t* buf, size_t n) {
261
+    uint8_t dummy_read = 0;
262
+    if (n == 0) return;
263
+    for (int i = 0; i < (int)n - 1; i++) {
264
+      while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
265
+      SPI0->SPI_TDR = (uint32_t)buf[i] | SPI_PCS(chan);
266
+      while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
267
+      while ((SPI0->SPI_SR & SPI_SR_RDRF) == 1)
268
+        dummy_read = SPI0->SPI_RDR;
269
+      UNUSED(dummy_read);
270
+    }
271
+    spiSend(chan, buf[n - 1]);
272
+  }
273
+
274
+  // Read single byte from SPI
275
+  uint8_t spiRec() {
276
+    // write dummy byte with address and end transmission flag
277
+    SPI0->SPI_TDR = 0x000000FF | SPI_PCS(SPI_CHAN) | SPI_TDR_LASTXFER;
278
+    // wait for transmit register empty
279
+    while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
280
+
281
+    // wait for receive register
282
+    while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
283
+    // get byte from receive register
284
+    //delayMicroseconds(1U);
285
+    return SPI0->SPI_RDR;
286
+  }
287
+
288
+  uint8_t spiRec(uint32_t chan) {
289
+    uint8_t spirec_tmp;
290
+    // wait for transmit register empty
291
+    while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
292
+    while ((SPI0->SPI_SR & SPI_SR_RDRF) == 1)
293
+      spirec_tmp =  SPI0->SPI_RDR;
294
+      UNUSED(spirec_tmp);
295
+
296
+    // write dummy byte with address and end transmission flag
297
+    SPI0->SPI_TDR = 0x000000FF | SPI_PCS(chan) | SPI_TDR_LASTXFER;
298
+
299
+    // wait for receive register
300
+    while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
301
+    // get byte from receive register
302
+    return SPI0->SPI_RDR;
303
+  }
304
+
305
+  // Read from SPI into buffer
306
+  void spiRead(uint8_t*buf, uint16_t nbyte) {
307
+    if (nbyte-- == 0) return;
308
+
309
+    for (int i = 0; i < nbyte; i++) {
310
+      //while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
311
+      SPI0->SPI_TDR = 0x000000FF | SPI_PCS(SPI_CHAN);
312
+      while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
313
+      buf[i] = SPI0->SPI_RDR;
314
+      //delayMicroseconds(1U);
315
+    }
316
+    buf[nbyte] = spiRec();
317
+  }
318
+
319
+  // Write from buffer to SPI
320
+  void spiSendBlock(uint8_t token, const uint8_t* buf) {
321
+    SPI0->SPI_TDR = (uint32_t)token | SPI_PCS(SPI_CHAN);
322
+    while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
323
+    //while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
324
+    //SPI0->SPI_RDR;
325
+    for (int i = 0; i < 511; i++) {
326
+      SPI0->SPI_TDR = (uint32_t)buf[i] | SPI_PCS(SPI_CHAN);
327
+      while ((SPI0->SPI_SR & SPI_SR_TDRE) == 0);
328
+      while ((SPI0->SPI_SR & SPI_SR_RDRF) == 0);
329
+      SPI0->SPI_RDR;
330
+      //delayMicroseconds(1U);
331
+    }
332
+    spiSend(buf[511]);
333
+  }
334
+#endif // ENABLED(SOFTWARE_SPI)
335
+
336
+#endif // ARDUINO_ARCH_SAM

+ 137
- 0
Marlin/src/HAL/HAL_DUE/HAL_timers_Due.cpp View File

@@ -0,0 +1,137 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ *
4
+ * Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * Description: HAL for Arduino Due and compatible (SAM3X8E)
25
+ *
26
+ * For ARDUINO_ARCH_SAM
27
+ */
28
+
29
+#ifdef ARDUINO_ARCH_SAM
30
+
31
+// --------------------------------------------------------------------------
32
+// Includes
33
+// --------------------------------------------------------------------------
34
+
35
+#include "../HAL.h"
36
+
37
+#include "HAL_timers_Due.h"
38
+
39
+// --------------------------------------------------------------------------
40
+// Externals
41
+// --------------------------------------------------------------------------
42
+
43
+// --------------------------------------------------------------------------
44
+// Local defines
45
+// --------------------------------------------------------------------------
46
+
47
+#define NUM_HARDWARE_TIMERS 9
48
+
49
+#define PRESCALER 2
50
+// --------------------------------------------------------------------------
51
+// Types
52
+// --------------------------------------------------------------------------
53
+
54
+
55
+// --------------------------------------------------------------------------
56
+// Public Variables
57
+// --------------------------------------------------------------------------
58
+
59
+// --------------------------------------------------------------------------
60
+// Private Variables
61
+// --------------------------------------------------------------------------
62
+
63
+const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
64
+  { TC0, 0, TC0_IRQn, 0},  // 0 - [servo timer5]
65
+  { TC0, 1, TC1_IRQn, 0},  // 1
66
+  { TC0, 2, TC2_IRQn, 0},  // 2
67
+  { TC1, 0, TC3_IRQn, 2},  // 3 - stepper
68
+  { TC1, 1, TC4_IRQn, 15}, // 4 - temperature
69
+  { TC1, 2, TC5_IRQn, 0},  // 5 - [servo timer3]
70
+  { TC2, 0, TC6_IRQn, 0},  // 6
71
+  { TC2, 1, TC7_IRQn, 0},  // 7
72
+  { TC2, 2, TC8_IRQn, 0},  // 8
73
+};
74
+
75
+// --------------------------------------------------------------------------
76
+// Function prototypes
77
+// --------------------------------------------------------------------------
78
+
79
+// --------------------------------------------------------------------------
80
+// Private functions
81
+// --------------------------------------------------------------------------
82
+
83
+// --------------------------------------------------------------------------
84
+// Public functions
85
+// --------------------------------------------------------------------------
86
+
87
+/*
88
+  Timer_clock1: Prescaler 2 -> 42MHz
89
+  Timer_clock2: Prescaler 8 -> 10.5MHz
90
+  Timer_clock3: Prescaler 32 -> 2.625MHz
91
+  Timer_clock4: Prescaler 128 -> 656.25kHz
92
+*/
93
+
94
+
95
+void HAL_timer_start (uint8_t timer_num, uint32_t frequency) {
96
+  Tc *tc = TimerConfig [timer_num].pTimerRegs;
97
+  IRQn_Type irq = TimerConfig [timer_num].IRQ_Id;
98
+  uint32_t channel = TimerConfig [timer_num].channel;
99
+
100
+  pmc_set_writeprotect(false);
101
+  pmc_enable_periph_clk((uint32_t)irq);
102
+  NVIC_SetPriority (irq, TimerConfig [timer_num].priority);
103
+
104
+  TC_Configure (tc, channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK1);
105
+
106
+  TC_SetRC(tc, channel, VARIANT_MCK/2/frequency);
107
+  TC_Start(tc, channel);
108
+
109
+  // enable interrupt on RC compare
110
+  tc->TC_CHANNEL[channel].TC_IER = TC_IER_CPCS;
111
+
112
+  NVIC_EnableIRQ(irq);
113
+}
114
+
115
+void HAL_timer_enable_interrupt (uint8_t timer_num) {
116
+  const tTimerConfig *pConfig = &TimerConfig [timer_num];
117
+  pConfig->pTimerRegs->TC_CHANNEL [pConfig->channel].TC_IER = TC_IER_CPCS;
118
+}
119
+
120
+void HAL_timer_disable_interrupt (uint8_t timer_num) {
121
+  const tTimerConfig *pConfig = &TimerConfig [timer_num];
122
+  pConfig->pTimerRegs->TC_CHANNEL [pConfig->channel].TC_IDR = TC_IDR_CPCS;
123
+}
124
+
125
+#if 0
126
+  void HAL_timer_set_count (uint8_t timer_num, uint32_t count) {
127
+    const tTimerConfig *pConfig = &TimerConfig [timer_num];
128
+    TC_SetRC (pConfig->pTimerRegs, pConfig->channel, count);
129
+  }
130
+
131
+  void HAL_timer_isr_prologue (uint8_t timer_num) {
132
+    const tTimerConfig *pConfig = &TimerConfig [timer_num];
133
+    TC_GetStatus (pConfig->pTimerRegs, pConfig->channel);
134
+  }
135
+#endif
136
+
137
+#endif // ARDUINO_ARCH_SAM

+ 116
- 0
Marlin/src/HAL/HAL_DUE/HAL_timers_Due.h View File

@@ -0,0 +1,116 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ *
4
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5
+ * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.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 <http://www.gnu.org/licenses/>.
19
+ *
20
+ */
21
+
22
+/**
23
+ * HAL for Arduino Due and compatible (SAM3X8E)
24
+ *
25
+ * For ARDUINO_ARCH_SAM
26
+ */
27
+
28
+#ifndef _HAL_TIMERS_DUE_H
29
+#define _HAL_TIMERS_DUE_H
30
+
31
+// --------------------------------------------------------------------------
32
+// Includes
33
+// --------------------------------------------------------------------------
34
+
35
+#include <stdint.h>
36
+
37
+// --------------------------------------------------------------------------
38
+// Defines
39
+// --------------------------------------------------------------------------
40
+
41
+#define FORCE_INLINE __attribute__((always_inline)) inline
42
+
43
+#define HAL_TIMER_TYPE uint32_t
44
+#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF
45
+
46
+#define STEP_TIMER_NUM 3  // index of timer to use for stepper
47
+#define TEMP_TIMER_NUM 4  // index of timer to use for temperature
48
+
49
+#define HAL_TIMER_RATE         ((F_CPU) / 2.0)  // frequency of timers peripherals
50
+#define STEPPER_TIMER_PRESCALE 1.0              // prescaler for setting stepper frequency
51
+#define HAL_STEPPER_TIMER_RATE HAL_TIMER_RATE   // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE)
52
+#define HAL_TICKS_PER_US       ((HAL_STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per us
53
+
54
+#define TEMP_TIMER_FREQUENCY   1000 // temperature interrupt frequency
55
+
56
+#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt (STEP_TIMER_NUM)
57
+#define DISABLE_STEPPER_DRIVER_INTERRUPT()  HAL_timer_disable_interrupt (STEP_TIMER_NUM)
58
+
59
+#define ENABLE_TEMPERATURE_INTERRUPT()  HAL_timer_enable_interrupt (TEMP_TIMER_NUM)
60
+#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt (TEMP_TIMER_NUM)
61
+
62
+#define HAL_ENABLE_ISRs() do { if (thermalManager.in_temp_isr)DISABLE_TEMPERATURE_INTERRUPT(); else ENABLE_TEMPERATURE_INTERRUPT(); ENABLE_STEPPER_DRIVER_INTERRUPT(); } while(0)
63
+//
64
+#define HAL_STEP_TIMER_ISR  void TC3_Handler()
65
+#define HAL_TEMP_TIMER_ISR  void TC4_Handler()
66
+
67
+// --------------------------------------------------------------------------
68
+// Types
69
+// --------------------------------------------------------------------------
70
+
71
+typedef struct {
72
+  Tc          *pTimerRegs;
73
+  uint16_t    channel;
74
+  IRQn_Type   IRQ_Id;
75
+  uint8_t     priority;
76
+} tTimerConfig;
77
+
78
+// --------------------------------------------------------------------------
79
+// Public Variables
80
+// --------------------------------------------------------------------------
81
+
82
+extern const tTimerConfig TimerConfig[];
83
+
84
+// --------------------------------------------------------------------------
85
+// Public functions
86
+// --------------------------------------------------------------------------
87
+
88
+void HAL_timer_start (uint8_t timer_num, uint32_t frequency);
89
+
90
+static FORCE_INLINE void HAL_timer_set_count (uint8_t timer_num, uint32_t count) {
91
+  const tTimerConfig *pConfig = &TimerConfig[timer_num];
92
+  pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC = count;
93
+}
94
+
95
+static FORCE_INLINE HAL_TIMER_TYPE HAL_timer_get_count (uint8_t timer_num) {
96
+  const tTimerConfig *pConfig = &TimerConfig[timer_num];
97
+  return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_RC;
98
+}
99
+
100
+static FORCE_INLINE uint32_t HAL_timer_get_current_count(uint8_t timer_num) {
101
+  const tTimerConfig *pConfig = &TimerConfig[timer_num];
102
+  return pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_CV;
103
+}
104
+
105
+void HAL_timer_enable_interrupt(uint8_t timer_num);
106
+void HAL_timer_disable_interrupt(uint8_t timer_num);
107
+
108
+//void HAL_timer_isr_prologue (uint8_t timer_num);
109
+
110
+static FORCE_INLINE void HAL_timer_isr_prologue(uint8_t timer_num) {
111
+  const tTimerConfig *pConfig = &TimerConfig[timer_num];
112
+  // Reading the status register clears the interrupt flag
113
+  pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_SR;
114
+}
115
+
116
+#endif // _HAL_TIMERS_DUE_H

+ 161
- 0
Marlin/src/HAL/HAL_DUE/Servo_Due.cpp View File

@@ -0,0 +1,161 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 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
+  Copyright (c) 2013 Arduino LLC. All right reserved.
25
+
26
+  This library is free software; you can redistribute it and/or
27
+  modify it under the terms of the GNU Lesser General Public
28
+  License as published by the Free Software Foundation; either
29
+  version 2.1 of the License, or (at your option) any later version.
30
+
31
+  This library is distributed in the hope that it will be useful,
32
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
33
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34
+  Lesser General Public License for more details.
35
+
36
+  You should have received a copy of the GNU Lesser General Public
37
+  License along with this library; if not, write to the Free Software
38
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
39
+*/
40
+
41
+#ifdef ARDUINO_ARCH_SAM
42
+
43
+#include "../../../MarlinConfig.h"
44
+
45
+#if HAS_SERVOS
46
+
47
+#include <Arduino.h>
48
+#include "../servo.h"
49
+#include "../servo_private.h"
50
+
51
+static volatile int8_t Channel[_Nbr_16timers ];             // counter for the servo being pulsed for each timer (or -1 if refresh interval)
52
+
53
+//------------------------------------------------------------------------------
54
+/// Interrupt handler for the TC0 channel 1.
55
+//------------------------------------------------------------------------------
56
+void Servo_Handler(timer16_Sequence_t timer, Tc *pTc, uint8_t channel);
57
+
58
+#ifdef _useTimer1
59
+  void HANDLER_FOR_TIMER1(void) { Servo_Handler(_timer1, TC_FOR_TIMER1, CHANNEL_FOR_TIMER1); }
60
+#endif
61
+#ifdef _useTimer2
62
+  void HANDLER_FOR_TIMER2(void) { Servo_Handler(_timer2, TC_FOR_TIMER2, CHANNEL_FOR_TIMER2); }
63
+#endif
64
+#ifdef _useTimer3
65
+  void HANDLER_FOR_TIMER3(void) { Servo_Handler(_timer3, TC_FOR_TIMER3, CHANNEL_FOR_TIMER3); }
66
+#endif
67
+#ifdef _useTimer4
68
+  void HANDLER_FOR_TIMER4(void) { Servo_Handler(_timer4, TC_FOR_TIMER4, CHANNEL_FOR_TIMER4); }
69
+#endif
70
+#ifdef _useTimer5
71
+  void HANDLER_FOR_TIMER5(void) { Servo_Handler(_timer5, TC_FOR_TIMER5, CHANNEL_FOR_TIMER5); }
72
+#endif
73
+
74
+void Servo_Handler(timer16_Sequence_t timer, Tc *tc, uint8_t channel) {
75
+  // clear interrupt
76
+  tc->TC_CHANNEL[channel].TC_SR;
77
+  if (Channel[timer] < 0)
78
+    tc->TC_CHANNEL[channel].TC_CCR |= TC_CCR_SWTRG; // channel set to -1 indicated that refresh interval completed so reset the timer
79
+  else if (SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive)
80
+    digitalWrite(SERVO(timer,Channel[timer]).Pin.nbr, LOW); // pulse this channel low if activated
81
+
82
+  Channel[timer]++;    // increment to the next channel
83
+  if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
84
+    tc->TC_CHANNEL[channel].TC_RA = tc->TC_CHANNEL[channel].TC_CV + SERVO(timer,Channel[timer]).ticks;
85
+    if (SERVO(timer,Channel[timer]).Pin.isActive)    // check if activated
86
+      digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH); // its an active channel so pulse it high
87
+  }
88
+  else {
89
+    // finished all channels so wait for the refresh period to expire before starting over
90
+    tc->TC_CHANNEL[channel].TC_RA =
91
+      tc->TC_CHANNEL[channel].TC_CV < usToTicks(REFRESH_INTERVAL) - 4
92
+        ? (unsigned int)usToTicks(REFRESH_INTERVAL) // allow a few ticks to ensure the next OCR1A not missed
93
+        : tc->TC_CHANNEL[channel].TC_CV + 4;        // at least REFRESH_INTERVAL has elapsed
94
+    Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel
95
+  }
96
+}
97
+
98
+static void _initISR(Tc *tc, uint32_t channel, uint32_t id, IRQn_Type irqn) {
99
+  pmc_enable_periph_clk(id);
100
+  TC_Configure(tc, channel,
101
+    TC_CMR_TCCLKS_TIMER_CLOCK3 | // MCK/32
102
+    TC_CMR_WAVE |                // Waveform mode
103
+    TC_CMR_WAVSEL_UP_RC );       // Counter running up and reset when equals to RC
104
+
105
+  /* 84MHz, MCK/32, for 1.5ms: 3937 */
106
+  TC_SetRA(tc, channel, 2625); // 1ms
107
+
108
+  /* Configure and enable interrupt */
109
+  NVIC_EnableIRQ(irqn);
110
+  // TC_IER_CPAS: RA Compare
111
+  tc->TC_CHANNEL[channel].TC_IER = TC_IER_CPAS;
112
+
113
+  // Enables the timer clock and performs a software reset to start the counting
114
+  TC_Start(tc, channel);
115
+}
116
+
117
+void initISR(timer16_Sequence_t timer) {
118
+  #ifdef _useTimer1
119
+    if (timer == _timer1)
120
+      _initISR(TC_FOR_TIMER1, CHANNEL_FOR_TIMER1, ID_TC_FOR_TIMER1, IRQn_FOR_TIMER1);
121
+  #endif
122
+  #ifdef _useTimer2
123
+    if (timer == _timer2)
124
+      _initISR(TC_FOR_TIMER2, CHANNEL_FOR_TIMER2, ID_TC_FOR_TIMER2, IRQn_FOR_TIMER2);
125
+  #endif
126
+  #ifdef _useTimer3
127
+    if (timer == _timer3)
128
+      _initISR(TC_FOR_TIMER3, CHANNEL_FOR_TIMER3, ID_TC_FOR_TIMER3, IRQn_FOR_TIMER3);
129
+  #endif
130
+  #ifdef _useTimer4
131
+    if (timer == _timer4)
132
+      _initISR(TC_FOR_TIMER4, CHANNEL_FOR_TIMER4, ID_TC_FOR_TIMER4, IRQn_FOR_TIMER4);
133
+  #endif
134
+  #ifdef _useTimer5
135
+    if (timer == _timer5)
136
+      _initISR(TC_FOR_TIMER5, CHANNEL_FOR_TIMER5, ID_TC_FOR_TIMER5, IRQn_FOR_TIMER5);
137
+  #endif
138
+}
139
+
140
+void finISR(timer16_Sequence_t timer) {
141
+  #ifdef _useTimer1
142
+    TC_Stop(TC_FOR_TIMER1, CHANNEL_FOR_TIMER1);
143
+  #endif
144
+  #ifdef _useTimer2
145
+    TC_Stop(TC_FOR_TIMER2, CHANNEL_FOR_TIMER2);
146
+  #endif
147
+  #ifdef _useTimer3
148
+    TC_Stop(TC_FOR_TIMER3, CHANNEL_FOR_TIMER3);
149
+  #endif
150
+  #ifdef _useTimer4
151
+    TC_Stop(TC_FOR_TIMER4, CHANNEL_FOR_TIMER4);
152
+  #endif
153
+  #ifdef _useTimer5
154
+    TC_Stop(TC_FOR_TIMER5, CHANNEL_FOR_TIMER5);
155
+  #endif
156
+}
157
+
158
+#endif // HAS_SERVOS
159
+
160
+#endif // ARDUINO_ARCH_SAM
161
+

+ 75
- 0
Marlin/src/HAL/HAL_DUE/endstop_interrupts.h View File

@@ -0,0 +1,75 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 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
+ * Endstop Interrupts
25
+ *
26
+ * Without endstop interrupts the endstop pins must be polled continually in
27
+ * the stepper-ISR via endstops.update(), most of the time finding no change.
28
+ * With this feature endstops.update() is called only when we know that at
29
+ * least one endstop has changed state, saving valuable CPU cycles.
30
+ *
31
+ * This feature only works when all used endstop pins can generate an 'external interrupt'.
32
+ *
33
+ * Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'.
34
+ * (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
35
+ */
36
+
37
+ #ifndef _ENDSTOP_INTERRUPTS_H_
38
+ #define _ENDSTOP_INTERRUPTS_H_
39
+
40
+/**
41
+ *  Endstop interrupts for Due based targets.
42
+ *  On Due, all pins support external interrupt capability.
43
+ */
44
+
45
+void setup_endstop_interrupts(void) {
46
+  #if HAS_X_MAX
47
+    attachInterrupt(digitalPinToInterrupt(X_MAX_PIN), endstop_ISR, CHANGE); // assign it
48
+  #endif
49
+  #if HAS_X_MIN
50
+    attachInterrupt(digitalPinToInterrupt(X_MIN_PIN), endstop_ISR, CHANGE);
51
+  #endif
52
+  #if HAS_Y_MAX
53
+    attachInterrupt(digitalPinToInterrupt(Y_MAX_PIN), endstop_ISR, CHANGE);
54
+  #endif
55
+  #if HAS_Y_MIN
56
+    attachInterrupt(digitalPinToInterrupt(Y_MIN_PIN), endstop_ISR, CHANGE);
57
+  #endif
58
+  #if HAS_Z_MAX
59
+    attachInterrupt(digitalPinToInterrupt(Z_MAX_PIN), endstop_ISR, CHANGE);
60
+  #endif
61
+  #if HAS_Z_MIN
62
+     attachInterrupt(digitalPinToInterrupt(Z_MIN_PIN), endstop_ISR, CHANGE);
63
+  #endif
64
+  #if HAS_Z2_MAX
65
+    attachInterrupt(digitalPinToInterrupt(Z2_MAX_PIN), endstop_ISR, CHANGE);
66
+  #endif
67
+  #if HAS_Z2_MIN
68
+    attachInterrupt(digitalPinToInterrupt(Z2_MIN_PIN), endstop_ISR, CHANGE);
69
+  #endif
70
+  #if HAS_Z_MIN_PROBE_PIN
71
+    attachInterrupt(digitalPinToInterrupt(Z_MIN_PROBE_PIN), endstop_ISR, CHANGE);
72
+  #endif
73
+}
74
+
75
+#endif //_ENDSTOP_INTERRUPTS_H_

+ 435
- 0
Marlin/src/HAL/HAL_DUE/fastio_Due.h View File

@@ -0,0 +1,435 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 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 code contributed by Triffid_Hunter and modified by Kliment
25
+  why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
26
+*/
27
+
28
+/**
29
+ * Description: Fast IO functions for Arduino Due and compatible (SAM3X8E)
30
+ *
31
+ * For ARDUINO_ARCH_SAM
32
+ */
33
+
34
+#ifndef _FASTIO_DUE_H
35
+#define _FASTIO_DUE_H
36
+
37
+/**
38
+  utility functions
39
+*/
40
+
41
+#ifndef MASK
42
+  #define MASK(PIN)  (1 << PIN)
43
+#endif
44
+
45
+/**
46
+  magic I/O routines
47
+  now you can simply SET_OUTPUT(STEP); WRITE(STEP, 1); WRITE(STEP, 0);
48
+*/
49
+
50
+/// Read a pin
51
+#define _READ(IO) ((bool)(DIO ## IO ## _WPORT -> PIO_PDSR & (MASK(DIO ## IO ## _PIN))))
52
+
53
+/// Write to a pin
54
+#define _WRITE_VAR(IO, v) do {  if (v) {g_APinDescription[IO].pPort->PIO_SODR = g_APinDescription[IO].ulPin; } \
55
+                                    else {g_APinDescription[IO].pPort->PIO_CODR = g_APinDescription[IO].ulPin; } \
56
+                                 } while (0)
57
+
58
+#define _WRITE(IO, v) do {  if (v) {DIO ## IO ## _WPORT -> PIO_SODR = MASK(DIO ## IO ##_PIN); } \
59
+                                else {DIO ##  IO ## _WPORT -> PIO_CODR = MASK(DIO ## IO ## _PIN); }; \
60
+                             } while (0)
61
+
62
+/// toggle a pin
63
+#define _TOGGLE(IO)  _WRITE(IO, !READ(IO))
64
+
65
+/// set pin as input
66
+#define _SET_INPUT(IO)  pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
67
+                        PIO_Configure(g_APinDescription[IO].pPort, PIO_INPUT, g_APinDescription[IO].ulPin, 0)
68
+/// set pin as output
69
+#define _SET_OUTPUT(IO)  PIO_Configure(g_APinDescription[IO].pPort, PIO_OUTPUT_1, \
70
+                         g_APinDescription[IO].ulPin, g_APinDescription[IO].ulPinConfiguration)
71
+
72
+/// set pin as input with pullup mode
73
+#define _PULLUP(IO, v)  { pinMode(IO, (v!=LOW ? INPUT_PULLUP : INPUT)); }
74
+
75
+/// check if pin is an input
76
+#define _GET_INPUT(IO)
77
+/// check if pin is an output
78
+#define _GET_OUTPUT(IO)
79
+
80
+/// check if pin is an timer
81
+#define _GET_TIMER(IO)
82
+
83
+//  why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
84
+
85
+/// Read a pin wrapper
86
+#define READ(IO)  _READ(IO)
87
+
88
+/// Write to a pin wrapper
89
+#define WRITE_VAR(IO, v)  _WRITE_VAR(IO, v)
90
+#define WRITE(IO, v)  _WRITE(IO, v)
91
+
92
+/// toggle a pin wrapper
93
+#define TOGGLE(IO)  _TOGGLE(IO)
94
+
95
+/// set pin as input wrapper
96
+#define SET_INPUT(IO)  _SET_INPUT(IO)
97
+/// set pin as input with pullup wrapper
98
+#define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
99
+/// set pin as output wrapper
100
+#define SET_OUTPUT(IO)  do{ _SET_OUTPUT(IO); _WRITE(IO, LOW); }while(0)
101
+
102
+/// check if pin is an input wrapper
103
+#define GET_INPUT(IO)  _GET_INPUT(IO)
104
+/// check if pin is an output wrapper
105
+#define GET_OUTPUT(IO)  _GET_OUTPUT(IO)
106
+
107
+/// check if pin is an timer wrapper
108
+#define GET_TIMER(IO)  _GET_TIMER(IO)
109
+
110
+// Shorthand
111
+#define OUT_WRITE(IO, v) { SET_OUTPUT(IO); WRITE(IO, v); }
112
+
113
+/**
114
+  ports and functions
115
+
116
+  added as necessary or if I feel like it- not a comprehensive list!
117
+*/
118
+
119
+// UART
120
+#define RXD        DIO0
121
+#define TXD        DIO1
122
+
123
+// TWI (I2C)
124
+#define SCL        DIO21
125
+#define SDA        DIO20
126
+
127
+/**
128
+pins
129
+*/
130
+
131
+#define DIO0_PIN 8
132
+#define DIO0_WPORT PIOA
133
+
134
+#define DIO1_PIN 9
135
+#define DIO1_WPORT PIOA
136
+
137
+#define DIO2_PIN 25
138
+#define DIO2_WPORT PIOB
139
+
140
+#define DIO3_PIN 28
141
+#define DIO3_WPORT PIOC
142
+
143
+#define DIO4_PIN 26
144
+#define DIO4_WPORT PIOC
145
+
146
+#define DIO5_PIN 25
147
+#define DIO5_WPORT PIOC
148
+
149
+#define DIO6_PIN 24
150
+#define DIO6_WPORT PIOC
151
+
152
+#define DIO7_PIN 23
153
+#define DIO7_WPORT PIOC
154
+
155
+#define DIO8_PIN 22
156
+#define DIO8_WPORT PIOC
157
+
158
+#define DIO9_PIN 21
159
+#define DIO9_WPORT PIOC
160
+
161
+#define DIO10_PIN 29
162
+#define DIO10_WPORT PIOC
163
+
164
+#define DIO11_PIN 7
165
+#define DIO11_WPORT PIOD
166
+
167
+#define DIO12_PIN 8
168
+#define DIO12_WPORT PIOD
169
+
170
+#define DIO13_PIN 27
171
+#define DIO13_WPORT PIOB
172
+
173
+#define DIO14_PIN 4
174
+#define DIO14_WPORT PIOD
175
+
176
+#define DIO15_PIN 5
177
+#define DIO15_WPORT PIOD
178
+
179
+#define DIO16_PIN 13
180
+#define DIO16_WPORT PIOA
181
+
182
+#define DIO17_PIN 12
183
+#define DIO17_WPORT PIOA
184
+
185
+#define DIO18_PIN 11
186
+#define DIO18_WPORT PIOA
187
+
188
+#define DIO19_PIN 10
189
+#define DIO19_WPORT PIOA
190
+
191
+#define DIO20_PIN 12
192
+#define DIO20_WPORT PIOB
193
+
194
+#define DIO21_PIN 13
195
+#define DIO21_WPORT PIOB
196
+
197
+#define DIO22_PIN 26
198
+#define DIO22_WPORT PIOB
199
+
200
+#define DIO23_PIN 14
201
+#define DIO23_WPORT PIOA
202
+
203
+#define DIO24_PIN 15
204
+#define DIO24_WPORT PIOA
205
+
206
+#define DIO25_PIN 0
207
+#define DIO25_WPORT PIOD
208
+
209
+#define DIO26_PIN 1
210
+#define DIO26_WPORT PIOD
211
+
212
+#define DIO27_PIN 2
213
+#define DIO27_WPORT PIOD
214
+
215
+#define DIO28_PIN 3
216
+#define DIO28_WPORT PIOD
217
+
218
+#define DIO29_PIN 6
219
+#define DIO29_WPORT PIOD
220
+
221
+#define DIO30_PIN 9
222
+#define DIO30_WPORT PIOD
223
+
224
+#define DIO31_PIN 7
225
+#define DIO31_WPORT PIOA
226
+
227
+#define DIO32_PIN 10
228
+#define DIO32_WPORT PIOD
229
+
230
+#define DIO33_PIN 1
231
+#define DIO33_WPORT PIOC
232
+
233
+#define DIO34_PIN 2
234
+#define DIO34_WPORT PIOC
235
+
236
+#define DIO35_PIN 3
237
+#define DIO35_WPORT PIOC
238
+
239
+#define DIO36_PIN 4
240
+#define DIO36_WPORT PIOC
241
+
242
+#define DIO37_PIN 5
243
+#define DIO37_WPORT PIOC
244
+
245
+#define DIO38_PIN 6
246
+#define DIO38_WPORT PIOC
247
+
248
+#define DIO39_PIN 7
249
+#define DIO39_WPORT PIOC
250
+
251
+#define DIO40_PIN 8
252
+#define DIO40_WPORT PIOC
253
+
254
+#define DIO41_PIN 9
255
+#define DIO41_WPORT PIOC
256
+
257
+#define DIO42_PIN 19
258
+#define DIO42_WPORT PIOA
259
+
260
+#define DIO43_PIN 20
261
+#define DIO43_WPORT PIOA
262
+
263
+#define DIO44_PIN 19
264
+#define DIO44_WPORT PIOC
265
+
266
+#define DIO45_PIN 18
267
+#define DIO45_WPORT PIOC
268
+
269
+#define DIO46_PIN 17
270
+#define DIO46_WPORT PIOC
271
+
272
+#define DIO47_PIN 16
273
+#define DIO47_WPORT PIOC
274
+
275
+#define DIO48_PIN 15
276
+#define DIO48_WPORT PIOC
277
+
278
+#define DIO49_PIN 14
279
+#define DIO49_WPORT PIOC
280
+
281
+#define DIO50_PIN 13
282
+#define DIO50_WPORT PIOC
283
+
284
+#define DIO51_PIN 12
285
+#define DIO51_WPORT PIOC
286
+
287
+#define DIO52_PIN 21
288
+#define DIO52_WPORT PIOB
289
+
290
+#define DIO53_PIN 14
291
+#define DIO53_WPORT PIOB
292
+
293
+#define DIO54_PIN 16
294
+#define DIO54_WPORT PIOA
295
+
296
+#define DIO55_PIN 24
297
+#define DIO55_WPORT PIOA
298
+
299
+#define DIO56_PIN 23
300
+#define DIO56_WPORT PIOA
301
+
302
+#define DIO57_PIN 22
303
+#define DIO57_WPORT PIOA
304
+
305
+#define DIO58_PIN 6
306
+#define DIO58_WPORT PIOA
307
+
308
+#define DIO59_PIN 4
309
+#define DIO59_WPORT PIOA
310
+
311
+#define DIO60_PIN 3
312
+#define DIO60_WPORT PIOA
313
+
314
+#define DIO61_PIN 2
315
+#define DIO61_WPORT PIOA
316
+
317
+#define DIO62_PIN 17
318
+#define DIO62_WPORT PIOB
319
+
320
+#define DIO63_PIN 18
321
+#define DIO63_WPORT PIOB
322
+
323
+#define DIO64_PIN 19
324
+#define DIO64_WPORT PIOB
325
+
326
+#define DIO65_PIN 20
327
+#define DIO65_WPORT PIOB
328
+
329
+#define DIO66_PIN 15
330
+#define DIO66_WPORT PIOB
331
+
332
+#define DIO67_PIN 16
333
+#define DIO67_WPORT PIOB
334
+
335
+#define DIO68_PIN 1
336
+#define DIO68_WPORT PIOA
337
+
338
+#define DIO69_PIN 0
339
+#define DIO69_WPORT PIOA
340
+
341
+#define DIO70_PIN 17
342
+#define DIO70_WPORT PIOA
343
+
344
+#define DIO71_PIN 18
345
+#define DIO71_WPORT PIOA
346
+
347
+#define DIO72_PIN 30
348
+#define DIO72_WPORT PIOC
349
+
350
+#define DIO73_PIN 21
351
+#define DIO73_WPORT PIOA
352
+
353
+#define DIO74_PIN 25
354
+#define DIO74_WPORT PIOA
355
+
356
+#define DIO75_PIN 26
357
+#define DIO75_WPORT PIOA
358
+
359
+#define DIO76_PIN 27
360
+#define DIO76_WPORT PIOA
361
+
362
+#define DIO77_PIN 28
363
+#define DIO77_WPORT PIOA
364
+
365
+#define DIO78_PIN 23
366
+#define DIO78_WPORT PIOB
367
+
368
+#define DIO79_PIN 17
369
+#define DIO79_WPORT PIOA
370
+
371
+#define DIO80_PIN 12
372
+#define DIO80_WPORT PIOB
373
+
374
+#define DIO81_PIN 8
375
+#define DIO81_WPORT PIOA
376
+
377
+#define DIO82_PIN 11
378
+#define DIO82_WPORT PIOA
379
+
380
+#define DIO83_PIN 13
381
+#define DIO83_WPORT PIOA
382
+
383
+#define DIO84_PIN 4
384
+#define DIO84_WPORT PIOD
385
+
386
+#define DIO85_PIN 11
387
+#define DIO85_WPORT PIOB
388
+
389
+#define DIO86_PIN 21
390
+#define DIO86_WPORT PIOB
391
+
392
+#define DIO87_PIN 29
393
+#define DIO87_WPORT PIOA
394
+
395
+#define DIO88_PIN 15
396
+#define DIO88_WPORT PIOB
397
+
398
+#define DIO89_PIN 14
399
+#define DIO89_WPORT PIOB
400
+
401
+#define DIO90_PIN 1
402
+#define DIO90_WPORT PIOA
403
+
404
+#define DIO91_PIN 15
405
+#define DIO91_WPORT PIOB
406
+
407
+#define DIO92_PIN 5
408
+#define DIO92_WPORT PIOA
409
+
410
+#define DIO93_PIN 12
411
+#define DIO93_WPORT PIOB
412
+
413
+#define DIO94_PIN 22
414
+#define DIO94_WPORT PIOB
415
+
416
+#define DIO95_PIN 23
417
+#define DIO95_WPORT PIOB
418
+
419
+#define DIO96_PIN 24
420
+#define DIO96_WPORT PIOB
421
+
422
+#define DIO97_PIN 20
423
+#define DIO97_WPORT PIOC
424
+
425
+#define DIO98_PIN 27
426
+#define DIO98_WPORT PIOC
427
+
428
+#define DIO99_PIN 10
429
+#define DIO99_WPORT PIOC
430
+
431
+#define DIO100_PIN 11
432
+#define DIO100_WPORT PIOC
433
+
434
+
435
+#endif // _FASTIO_DUE_H

+ 57
- 0
Marlin/src/HAL/HAL_DUE/persistent_store.cpp View File

@@ -0,0 +1,57 @@
1
+#include "../persistent_store_api.h"
2
+
3
+#include "../../../types.h"
4
+#include "../../../language.h"
5
+#include "../../../serial.h"
6
+#include "../../../utility.h"
7
+
8
+#ifdef ARDUINO_ARCH_SAM
9
+#if ENABLED(EEPROM_SETTINGS)
10
+
11
+namespace HAL {
12
+namespace PersistentStore {
13
+
14
+bool access_start() {
15
+  return true;
16
+}
17
+
18
+bool access_finish(){
19
+  return true;
20
+}
21
+
22
+bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
23
+  while (size--) {
24
+    uint8_t * const p = (uint8_t * const)pos;
25
+    uint8_t v = *value;
26
+    // EEPROM has only ~100,000 write cycles,
27
+    // so only write bytes that have changed!
28
+    if (v != eeprom_read_byte(p)) {
29
+      eeprom_write_byte(p, v);
30
+      if (eeprom_read_byte(p) != v) {
31
+        SERIAL_ECHO_START();
32
+        SERIAL_ECHOLNPGM(MSG_ERR_EEPROM_WRITE);
33
+        return false;
34
+      }
35
+    }
36
+    crc16(crc, &v, 1);
37
+    pos++;
38
+    value++;
39
+  };
40
+  return true;
41
+}
42
+
43
+void read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
44
+  do {
45
+    uint8_t c = eeprom_read_byte((unsigned char*)pos);
46
+    *value = c;
47
+    crc16(crc, &c, 1);
48
+    pos++;
49
+    value++;
50
+  } while (--size);
51
+}
52
+
53
+}
54
+}
55
+
56
+#endif // EEPROM_SETTINGS
57
+#endif // ARDUINO_ARCH_AVR

+ 91
- 0
Marlin/src/HAL/HAL_DUE/servotimers.h View File

@@ -0,0 +1,91 @@
1
+/*
2
+  Copyright (c) 2013 Arduino LLC. All right reserved.
3
+
4
+  This library is free software; you can redistribute it and/or
5
+  modify it under the terms of the GNU Lesser General Public
6
+  License as published by the Free Software Foundation; either
7
+  version 2.1 of the License, or (at your option) any later version.
8
+
9
+  This library is distributed in the hope that it will be useful,
10
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+  Lesser General Public License for more details.
13
+
14
+  You should have received a copy of the GNU Lesser General Public
15
+  License along with this library; if not, write to the Free Software
16
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+*/
18
+
19
+/**
20
+ * Defines for 16 bit timers used with  Servo library
21
+ *
22
+ * If _useTimerX is defined then TimerX is a 32 bit timer on the current board
23
+ * timer16_Sequence_t enumerates the sequence that the timers should be allocated
24
+ * _Nbr_16timers indicates how many timers are available.
25
+ */
26
+
27
+/**
28
+ * SAM Only definitions
29
+ * --------------------
30
+ */
31
+
32
+// For SAM3X:
33
+//!#define _useTimer1
34
+//!#define _useTimer2
35
+#define _useTimer3
36
+//!#define _useTimer4
37
+#define _useTimer5
38
+
39
+#define TRIM_DURATION       2    // compensation ticks to trim adjust for digitalWrite delays
40
+#define PRESCALER           32   // timer prescaler
41
+
42
+/*
43
+  TC0, chan 0 => TC0_Handler
44
+  TC0, chan 1 => TC1_Handler
45
+  TC0, chan 2 => TC2_Handler
46
+  TC1, chan 0 => TC3_Handler
47
+  TC1, chan 1 => TC4_Handler
48
+  TC1, chan 2 => TC5_Handler
49
+  TC2, chan 0 => TC6_Handler
50
+  TC2, chan 1 => TC7_Handler
51
+  TC2, chan 2 => TC8_Handler
52
+ */
53
+
54
+#ifdef _useTimer1
55
+  #define TC_FOR_TIMER1       TC1
56
+  #define CHANNEL_FOR_TIMER1  0
57
+  #define ID_TC_FOR_TIMER1    ID_TC3
58
+  #define IRQn_FOR_TIMER1     TC3_IRQn
59
+  #define HANDLER_FOR_TIMER1  TC3_Handler
60
+#endif
61
+#ifdef _useTimer2
62
+  #define TC_FOR_TIMER2       TC1
63
+  #define CHANNEL_FOR_TIMER2  1
64
+  #define ID_TC_FOR_TIMER2    ID_TC4
65
+  #define IRQn_FOR_TIMER2     TC4_IRQn
66
+  #define HANDLER_FOR_TIMER2  TC4_Handler
67
+#endif
68
+#ifdef _useTimer3
69
+  #define TC_FOR_TIMER3       TC1
70
+  #define CHANNEL_FOR_TIMER3  2
71
+  #define ID_TC_FOR_TIMER3    ID_TC5
72
+  #define IRQn_FOR_TIMER3     TC5_IRQn
73
+  #define HANDLER_FOR_TIMER3  TC5_Handler
74
+#endif
75
+#ifdef _useTimer4
76
+  #define TC_FOR_TIMER4       TC0
77
+  #define CHANNEL_FOR_TIMER4  2
78
+  #define ID_TC_FOR_TIMER4    ID_TC2
79
+  #define IRQn_FOR_TIMER4     TC2_IRQn
80
+  #define HANDLER_FOR_TIMER4  TC2_Handler
81
+#endif
82
+#ifdef _useTimer5
83
+  #define TC_FOR_TIMER5       TC0
84
+  #define CHANNEL_FOR_TIMER5  0
85
+  #define ID_TC_FOR_TIMER5    ID_TC0
86
+  #define IRQn_FOR_TIMER5     TC0_IRQn
87
+  #define HANDLER_FOR_TIMER5  TC0_Handler
88
+#endif
89
+
90
+//typedef enum { _timer1, _timer2, _timer3, _timer4, _timer5, _Nbr_16timers } timer16_Sequence_t;
91
+typedef enum { _timer3, _timer5, _Nbr_16timers } timer16_Sequence_t;

+ 56
- 0
Marlin/src/HAL/HAL_DUE/spi_pins.h View File

@@ -0,0 +1,56 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
17
+ *
18
+ */
19
+
20
+
21
+#ifndef SPI_PINS_H_
22
+#define SPI_PINS_H_
23
+
24
+/**
25
+ * Define SPI Pins: SCK, MISO, MOSI, SS
26
+ *
27
+ * Available chip select pins for HW SPI are 4 10 52 77
28
+ */
29
+#if (SDSS == 4) || (SDSS == 10) || (SDSS == 52) || (SDSS == 77)
30
+  #if (SDSS == 4)
31
+    #define SPI_PIN         87
32
+    #define SPI_CHAN         1
33
+  #elif (SDSS == 10)
34
+    #define SPI_PIN         77
35
+    #define SPI_CHAN         0
36
+  #elif (SDSS == 52)
37
+    #define SPI_PIN         86
38
+    #define SPI_CHAN         2
39
+  #else
40
+    #define SPI_PIN         77
41
+    #define SPI_CHAN         0
42
+  #endif
43
+  #define SCK_PIN           76
44
+  #define MISO_PIN          74
45
+  #define MOSI_PIN          75
46
+#else
47
+  // defaults
48
+  #define SOFTWARE_SPI
49
+  #define SCK_PIN           52
50
+  #define MISO_PIN          50
51
+  #define MOSI_PIN          51
52
+#endif
53
+
54
+#define SS_PIN            SDSS // A.28, A.29, B.21, C.26, C.29
55
+
56
+#endif /* SPI_PINS_H_ */

+ 39
- 0
Marlin/src/HAL/HAL_DUE/watchdog_Due.cpp View File

@@ -0,0 +1,39 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 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
+#ifdef ARDUINO_ARCH_SAM
24
+ 
25
+#include "../../../MarlinConfig.h"
26
+
27
+#if ENABLED(USE_WATCHDOG)
28
+
29
+  #include "watchdog_Due.h"
30
+
31
+  void watchdogSetup(void) {
32
+    // do whatever. don't remove this function.
33
+  }
34
+
35
+  void watchdog_init(void) { watchdogEnable(4000); }
36
+
37
+#endif // USE_WATCHDOG
38
+
39
+#endif

+ 37
- 0
Marlin/src/HAL/HAL_DUE/watchdog_Due.h View File

@@ -0,0 +1,37 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 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
+#ifndef WATCHDOG_DUE_H
24
+#define WATCHDOG_DUE_H
25
+
26
+//#include "../../../Marlin.h"
27
+
28
+// Arduino Due core now has watchdog support
29
+
30
+// Initialize watchdog with a 4 second interrupt time
31
+void watchdog_init();
32
+
33
+// Reset watchdog. MUST be called at least every 4 seconds after the
34
+// first watchdog_init or AVR will go into emergency procedures.
35
+inline void watchdog_reset() { watchdogReset(); }
36
+
37
+#endif /* WATCHDOG_DUE_H */

+ 7
- 0
platformio.ini View File

@@ -80,3 +80,10 @@ platform = atmelavr
80 80
 framework = arduino
81 81
 board = sanguino_atmega644p
82 82
 lib_deps = ${common.lib_deps}
83
+
84
+[env:DUE]
85
+platform = atmelsam
86
+framework = arduino
87
+board = due
88
+build_flags = -I $BUILDSRC_DIR
89
+lib_deps = ${common.lib_deps}

Loading…
Cancel
Save