Bob-the-Kuhn 7 年之前
父節點
當前提交
adb9ecf3cc

+ 3
- 0
Marlin/src/HAL/HAL_AVR/pinsDebug_AVR_8_bit.h 查看文件

@@ -29,6 +29,8 @@
29 29
 
30 30
 #include "../../inc/MarlinConfig.h"
31 31
 
32
+#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
33
+
32 34
 #if AVR_AT90USB1286_FAMILY
33 35
   // Working with Teensyduino extension so need to re-define some things
34 36
   #include "pinsDebug_Teensyduino.h"
@@ -57,6 +59,7 @@
57 59
 #define DIGITAL_PIN_TO_ANALOG_PIN(p) int(p - analogInputToDigitalPin(0))
58 60
 #define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && ((P) <= analogInputToDigitalPin(15) || (P) <= analogInputToDigitalPin(7)))
59 61
 #define GET_ARRAY_PIN(p) pgm_read_byte(&pin_array[p].pin)
62
+#define MULTI_NAME_PAD 14 // space needed to be pretty if not first name assigned to a pin
60 63
 
61 64
 void PRINT_ARRAY_NAME(uint8_t x) {
62 65
   char *name_mem_pointer = (char*)pgm_read_ptr(&pin_array[x].name);

+ 190
- 0
Marlin/src/HAL/HAL_DUE/HAL_pinsDebug_Due.h 查看文件

@@ -0,0 +1,190 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2018 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
+ * Support routines for Due
25
+ */
26
+
27
+/**
28
+ * Translation of routines & variables used by pinsDebug.h
29
+ */
30
+
31
+#include "Arduino.h"
32
+
33
+/**
34
+ * Due/Marlin quirks
35
+ *
36
+ * a) determining the state of a pin
37
+ *     The Due/Arduino status definitions for the g_pinStatus[pin] array are:
38
+ *       #define PIN_STATUS_DIGITAL_INPUT_PULLUP  (0x01)
39
+ *       #define PIN_STATUS_DIGITAL_INPUT         (0x02)
40
+ *       #define PIN_STATUS_DIGITAL_OUTPUT        (0x03)
41
+ *       #define PIN_STATUS_ANALOG                (0x04)
42
+ *       #define PIN_STATUS_PWM                   (0x05)
43
+ *       #define PIN_STATUS_TIMER                 (0x06)
44
+ *
45
+ *     These are only valid if the following Due/Arduino provided functions are used:
46
+ *       analogRead
47
+ *       analogWrite
48
+ *       digitalWrite
49
+ *       pinMode
50
+ *
51
+ *     The FASTIO routines do not touch the g_pinStatus[pin] array.
52
+ *
53
+ *     The net result is that both the g_pinStatus[pin] array and the PIO_OSR register
54
+ *     needs to be looked at when determining if a pin is an input or an output.
55
+ *
56
+ * b) Due has only pins 6, 7, 8 & 9 enabled for PWMs.  FYI - they run at 1KHz
57
+ *
58
+ * c) NUM_DIGITAL_PINS does not include the analog pins
59
+ *
60
+ * d) Pins 0-78 are defined for Due but 78 has a comment of "unconnected!".  78 is
61
+ *    included just in case.
62
+ */
63
+
64
+#define NUMBER_PINS_TOTAL PINS_COUNT
65
+
66
+#define digitalRead_mod(p)  digitalRead(p)  // AVR digitalRead disabled PWM before it read the pin
67
+#define PRINT_PORT(p)
68
+#define NAME_FORMAT(p) PSTR("%-##p##s")
69
+#define PRINT_ARRAY_NAME(x)  do {sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer);} while (0)
70
+#define PRINT_PIN(p) do {sprintf_P(buffer, PSTR("%02d"), p); SERIAL_ECHO(buffer);} while (0)
71
+#define GET_ARRAY_PIN(p) pin_array[p].pin
72
+#define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL ? 1 : 0)
73
+#define DIGITAL_PIN_TO_ANALOG_PIN(p) int(p - analogInputToDigitalPin(0))
74
+#define IS_ANALOG(P) (((P) >= analogInputToDigitalPin(0)) && ((P) <= analogInputToDigitalPin(NUM_ANALOG_INPUTS - 1)))
75
+#define pwm_status(pin) ((g_pinStatus[pin] & 0xF) == PIN_STATUS_PWM) && \
76
+                        ((g_APinDescription[pin].ulPinAttribute & PIN_ATTR_PWM) == PIN_ATTR_PWM)
77
+#define MULTI_NAME_PAD 14 // space needed to be pretty if not first name assigned to a pin
78
+
79
+bool GET_PINMODE(int8_t pin) {  // 1: output, 0: input
80
+  volatile Pio* port = g_APinDescription[pin].pPort;
81
+  uint32_t mask = g_APinDescription[pin].ulPin;
82
+  uint8_t pin_status = g_pinStatus[pin] & 0xF;
83
+  return (  (pin_status == 0 && (port->PIO_OSR & mask))
84
+          || pin_status == PIN_STATUS_DIGITAL_OUTPUT
85
+          || pwm_status(pin));
86
+}
87
+
88
+bool GET_ARRAY_IS_DIGITAL(int8_t pin) {
89
+  uint8_t pin_status = g_pinStatus[pin] & 0xF;
90
+  return  !(pin_status == PIN_STATUS_ANALOG);
91
+}
92
+
93
+void pwm_details(int32_t pin) {
94
+  if (pwm_status(pin)) {
95
+    uint32_t chan = g_APinDescription[pin].ulPWMChannel;
96
+    SERIAL_PROTOCOLPAIR("PWM = ", PWM_INTERFACE->PWM_CH_NUM[chan].PWM_CDTY);
97
+  }
98
+}
99
+
100
+/**
101
+ * DUE Board pin   |  PORT  | Label
102
+ * ----------------+--------+-------
103
+ *   0             |  PA8   | "RX0"
104
+ *   1             |  PA9   | "TX0"
105
+ *   2       TIOA0 |  PB25  |
106
+ *   3       TIOA7 |  PC28  |
107
+ *   4       NPCS1 |  PA29  |
108
+ *           TIOB6 |  PC26  |
109
+ *   5       TIOA6 |  PC25  |
110
+ *   6       PWML7 |  PC24  |
111
+ *   7       PWML6 |  PC23  |
112
+ *   8       PWML5 |  PC22  |
113
+ *   9       PWML4 |  PC21  |
114
+ *  10       NPCS0 |  PA28  |
115
+ *           TIOB7 |  PC29  |
116
+ *  11       TIOA8 |  PD7   |
117
+ *  12       TIOB8 |  PD8   |
118
+ *  13       TIOB0 |  PB27  | LED AMBER "L"
119
+ *  14       TXD3  |  PD4   | "TX3"
120
+ *  15       RXD3  |  PD5   | "RX3"
121
+ *  16       TXD1  |  PA13  | "TX2"
122
+ *  17       RXD1  |  PA12  | "RX2"
123
+ *  18       TXD0  |  PA11  | "TX1"
124
+ *  19       RXD0  |  PA10  | "RX1"
125
+ *  20             |  PB12  | "SDA"
126
+ *  21             |  PB13  | "SCL"
127
+ *  22             |  PB26  |
128
+ *  23             |  PA14  |
129
+ *  24             |  PA15  |
130
+ *  25             |  PD0   |
131
+ *  26             |  PD1   |
132
+ *  27             |  PD2   |
133
+ *  28             |  PD3   |
134
+ *  29             |  PD6   |
135
+ *  30             |  PD9   |
136
+ *  31             |  PA7   |
137
+ *  32             |  PD10  |
138
+ *  33             |  PC1   |
139
+ *  34             |  PC2   |
140
+ *  35             |  PC3   |
141
+ *  36             |  PC4   |
142
+ *  37             |  PC5   |
143
+ *  38             |  PC6   |
144
+ *  39             |  PC7   |
145
+ *  40             |  PC8   |
146
+ *  41             |  PC9   |
147
+ *  42             |  PA19  |
148
+ *  43             |  PA20  |
149
+ *  44             |  PC19  |
150
+ *  45             |  PC18  |
151
+ *  46             |  PC17  |
152
+ *  47             |  PC16  |
153
+ *  48             |  PC15  |
154
+ *  49             |  PC14  |
155
+ *  50             |  PC13  |
156
+ *  51             |  PC12  |
157
+ *  52       NPCS2 |  PB21  |
158
+ *  53             |  PB14  |
159
+ *  54             |  PA16  | "A0"
160
+ *  55             |  PA24  | "A1"
161
+ *  56             |  PA23  | "A2"
162
+ *  57             |  PA22  | "A3"
163
+ *  58       TIOB2 |  PA6   | "A4"
164
+ *  69             |  PA4   | "A5"
165
+ *  60       TIOB1 |  PA3   | "A6"
166
+ *  61       TIOA1 |  PA2   | "A7"
167
+ *  62             |  PB17  | "A8"
168
+ *  63             |  PB18  | "A9"
169
+ *  64             |  PB19  | "A10"
170
+ *  65             |  PB20  | "A11"
171
+ *  66             |  PB15  | "DAC0"
172
+ *  67             |  PB16  | "DAC1"
173
+ *  68             |  PA1   | "CANRX"
174
+ *  69             |  PA0   | "CANTX"
175
+ *  70             |  PA17  | "SDA1"
176
+ *  71             |  PA18  | "SCL1"
177
+ *  72             |  PC30  | LED AMBER "RX"
178
+ *  73             |  PA21  | LED AMBER "TX"
179
+ *  74       MISO  |  PA25  |
180
+ *  75       MOSI  |  PA26  |
181
+ *  76       SCLK  |  PA27  |
182
+ *  77       NPCS0 |  PA28  |
183
+ *  78       NPCS3 |  PB23  | unconnected!
184
+ *
185
+ * USB pin         |  PORT
186
+ * ----------------+--------
187
+ *  ID             |  PB11
188
+ *  VBOF           |  PB10
189
+ *
190
+ */

+ 6
- 2
Marlin/src/HAL/HAL_LPC1768/pinmapping.h 查看文件

@@ -248,8 +248,12 @@ constexpr pin_t adc_pin_table[] = {
248 248
   #endif
249 249
 };
250 250
 
251
-constexpr int16_t NUM_ANALOG_INPUTS = COUNT(adc_pin_table);
252
-
251
+#if SERIAL_PORT != 0
252
+  #define NUM_ANALOG_INPUTS 8
253
+#else
254
+  #define NUM_ANALOG_INPUTS 6
255
+#endif
256
+  
253 257
 // P0.6 thru P0.9 are for the onboard SD card
254 258
 // P0.29 and P0.30 are for the USB port
255 259
 #define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09, P0_29, P0_30

+ 3
- 3
Marlin/src/HAL/HAL_LPC1768/pinsDebug_LPC1768.h 查看文件

@@ -28,17 +28,17 @@
28 28
  * Translation of routines & variables used by pinsDebug.h
29 29
  */
30 30
 
31
+#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
31 32
 #define pwm_details(pin) pin = pin    // do nothing  // print PWM details
32 33
 #define pwm_status(pin) false //Print a pin's PWM status. Return true if it's currently a PWM pin.
33 34
 #define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P) >= 0 ? 1 : 0)
34 35
 #define digitalRead_mod(p)  digitalRead(p)
35
-#define digitalPinToPort_DEBUG(p)  0
36
-#define digitalPinToBitMask_DEBUG(pin) 0
37
-#define PRINT_PORT(p) SERIAL_ECHO_SP(10);
36
+#define PRINT_PORT(p)
38 37
 #define GET_ARRAY_PIN(p) pin_array[p].pin
39 38
 #define NAME_FORMAT(p) PSTR("%-##p##s")
40 39
 #define PRINT_ARRAY_NAME(x)  do {sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer);} while (0)
41 40
 #define PRINT_PIN(p) do {sprintf_P(buffer, PSTR("%d.%02d"), LPC1768_PIN_PORT(p), LPC1768_PIN_PIN(p)); SERIAL_ECHO(buffer);} while (0)
41
+#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
42 42
 
43 43
 // active ADC function/mode/code values for PINSEL registers
44 44
 constexpr int8_t ADC_pin_mode(pin_t pin) {

+ 3
- 0
Marlin/src/HAL/HAL_TEENSY35_36/HAL_pinsDebug_Teensy.h 查看文件

@@ -22,6 +22,9 @@
22 22
 
23 23
 #ifndef HAL_PINSDEBUG_TEENSY_H
24 24
 
25
+#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
26
+#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
27
+
25 28
 #define FTM0_CH0_PIN 22
26 29
 #define FTM0_CH1_PIN 23
27 30
 #define FTM0_CH2_PIN  9

+ 6
- 2
Marlin/src/gcode/config/M43.cpp 查看文件

@@ -260,8 +260,8 @@ void GcodeSuite::M43() {
260 260
   }
261 261
 
262 262
   // Get the range of pins to test or watch
263
-  const uint8_t first_pin = PARSED_PIN_INDEX('P', 0),
264
-                last_pin = parser.seenval('P') ? first_pin : NUM_DIGITAL_PINS - 1;
263
+  uint8_t first_pin = PARSED_PIN_INDEX('P', 0),
264
+          last_pin = parser.seenval('P') ? first_pin : NUMBER_PINS_TOTAL - 1;
265 265
 
266 266
   if (first_pin > last_pin) return;
267 267
 
@@ -270,6 +270,10 @@ void GcodeSuite::M43() {
270 270
   // Watch until click, M108, or reset
271 271
   if (parser.boolval('W')) {
272 272
     SERIAL_PROTOCOLLNPGM("Watching pins");
273
+    
274
+    #ifdef ARDUINO_ARCH_SAM
275
+      NOLESS(first_pin, 2);  // don't hijack the UART pins
276
+    #endif
273 277
     uint8_t pin_state[last_pin - first_pin + 1];
274 278
     for (uint8_t i = first_pin; i <= last_pin; i++) {
275 279
       pin_t pin = GET_PIN_MAP_PIN(i);

+ 3
- 3
Marlin/src/pins/pinsDebug.h 查看文件

@@ -46,7 +46,7 @@
46 46
 #line 47
47 47
 
48 48
 // manually add pins that have names that are macros which don't play well with these macros
49
-#if SERIAL_PORT == 0 && (AVR_ATmega2560_FAMILY || AVR_ATmega1284_FAMILY)
49
+#if SERIAL_PORT == 0 && (AVR_ATmega2560_FAMILY || AVR_ATmega1284_FAMILY || defined(ARDUINO_ARCH_SAM))
50 50
   static const char RXD_NAME[] PROGMEM = { "RXD" };
51 51
   static const char TXD_NAME[] PROGMEM = { "TXD" };
52 52
 #endif
@@ -85,7 +85,7 @@ const PinInfo pin_array[] PROGMEM = {
85 85
 
86 86
   // manually add pins ...
87 87
   #if SERIAL_PORT == 0
88
-    #if AVR_ATmega2560_FAMILY
88
+    #if (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM))
89 89
       { RXD_NAME, 0, true },
90 90
       { TXD_NAME, 1, true },
91 91
     #elif AVR_ATmega1284_FAMILY
@@ -130,7 +130,7 @@ inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = fa
130 130
       }
131 131
       else {
132 132
         SERIAL_CHAR('.');
133
-        SERIAL_ECHO_SP(26 + strlen(start_string));  // add padding if not the first instance found
133
+        SERIAL_ECHO_SP(MULTI_NAME_PAD + strlen(start_string));  // add padding if not the first instance found
134 134
       }
135 135
       PRINT_ARRAY_NAME(x);
136 136
       if (extended) {

+ 8
- 6
Marlin/src/pins/pinsDebug_list.h 查看文件

@@ -27,7 +27,7 @@
27 27
 
28 28
 // Pin list updated from 25 JUL 2017 Re-ARM branch   - max length of pin name is 24
29 29
 
30
-#line 0 // set __LINE__ to a known value for both passes
30
+#line 31 // set __LINE__ to a known value for both passes
31 31
 
32 32
 #if defined(EXT_AUX_A0) &&  EXT_AUX_A0 >= 0 &&  EXT_AUX_A0 < NUM_ANALOG_INPUTS
33 33
   REPORT_NAME_ANALOG(EXT_AUX_A0, __LINE__ )
@@ -50,11 +50,13 @@
50 50
 #if PIN_EXISTS(MAIN_VOLTAGE_MEASURE) &&  MAIN_VOLTAGE_MEASURE_PIN < NUM_ANALOG_INPUTS
51 51
   REPORT_NAME_ANALOG(MAIN_VOLTAGE_MEASURE_PIN, __LINE__ )
52 52
 #endif
53
-#if defined(TC1) &&  TC1 >= 0 &&  TC1 < NUM_ANALOG_INPUTS
54
-  REPORT_NAME_ANALOG(TC1, __LINE__ )
55
-#endif
56
-#if defined(TC2) &&  TC2 >= 0 &&  TC2 < NUM_ANALOG_INPUTS
57
-  REPORT_NAME_ANALOG(TC2, __LINE__ )
53
+#if !defined(ARDUINO_ARCH_SAM)  //TC1 & TC2 are macros in the SAM tool chain
54
+  #if defined(TC1) &&  TC1 >= 0 &&  TC1 < NUM_ANALOG_INPUTS
55
+    REPORT_NAME_ANALOG(TC1, __LINE__ )
56
+  #endif
57
+  #if defined(TC2) &&  TC2 >= 0 &&  TC2 < NUM_ANALOG_INPUTS
58
+    REPORT_NAME_ANALOG(TC2, __LINE__ )
59
+  #endif
58 60
 #endif
59 61
 #if PIN_EXISTS(TEMP_0) &&  TEMP_0_PIN < NUM_ANALOG_INPUTS
60 62
   REPORT_NAME_ANALOG(TEMP_0_PIN, __LINE__ )

+ 2
- 0
Marlin/src/pins/pins_RAMPS_FD_V1.h 查看文件

@@ -96,6 +96,8 @@
96 96
 #define TEMP_0_PIN          1   // Analog Input
97 97
 #define TEMP_1_PIN          2   // Analog Input
98 98
 #define TEMP_2_PIN          3   // Analog Input
99
+#define TEMP_3_PIN         -1   // fewer compiler warnings
100
+#define TEMP_4_PIN         -1   // fewer compiler warnings
99 101
 #define TEMP_BED_PIN        0   // Analog Input
100 102
 
101 103
 // SPI for Max6675 or Max31855 Thermocouple

Loading…
取消
儲存