Browse Source

Pins Debugging for STM32 — NEEDS TESTING (#14309)

Bob Kuhn 4 years ago
parent
commit
dc02d0720d

+ 1
- 1
Marlin/src/HAL/HAL_AVR/pinsDebug.h View File

@@ -400,4 +400,4 @@ static void pwm_details(uint8_t pin) {
400 400
 
401 401
 #endif
402 402
 
403
-#define PRINT_PIN(p) do {sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer);} while (0)
403
+#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)

+ 2
- 2
Marlin/src/HAL/HAL_DUE/pinsDebug.h View File

@@ -63,8 +63,8 @@
63 63
 #define digitalRead_mod(p) extDigitalRead(p)  // AVR digitalRead disabled PWM before it read the pin
64 64
 #define PRINT_PORT(p)
65 65
 #define NAME_FORMAT(p) PSTR("%-##p##s")
66
-#define PRINT_ARRAY_NAME(x)  do {sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer);} while (0)
67
-#define PRINT_PIN(p) do {sprintf_P(buffer, PSTR("%02d"), p); SERIAL_ECHO(buffer);} while (0)
66
+#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
67
+#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%02d"), p); SERIAL_ECHO(buffer); }while(0)
68 68
 #define GET_ARRAY_PIN(p) pin_array[p].pin
69 69
 #define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital
70 70
 #define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL ? 1 : 0)

+ 2
- 2
Marlin/src/HAL/HAL_LINUX/pinsDebug.h View File

@@ -33,8 +33,8 @@
33 33
 #define PRINT_PORT(p)
34 34
 #define GET_ARRAY_PIN(p) pin_array[p].pin
35 35
 #define NAME_FORMAT(p) PSTR("%-##p##s")
36
-#define PRINT_ARRAY_NAME(x)  do {sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer);} while (0)
37
-#define PRINT_PIN(p) do {sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer);} while (0)
36
+#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
37
+#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
38 38
 #define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
39 39
 
40 40
 // active ADC function/mode/code values for PINSEL registers

+ 2
- 2
Marlin/src/HAL/HAL_LPC1768/pinsDebug.h View File

@@ -33,8 +33,8 @@
33 33
 #define PRINT_PORT(p)
34 34
 #define GET_ARRAY_PIN(p) pin_array[p].pin
35 35
 #define NAME_FORMAT(p) PSTR("%-##p##s")
36
-#define PRINT_ARRAY_NAME(x)  do {sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer);} while (0)
37
-#define PRINT_PIN(p) do {sprintf_P(buffer, PSTR("%d.%02d"), LPC1768_PIN_PORT(p), LPC1768_PIN_PIN(p)); SERIAL_ECHO(buffer);} while (0)
36
+#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
37
+#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%d.%02d"), LPC1768_PIN_PORT(p), LPC1768_PIN_PIN(p)); SERIAL_ECHO(buffer); }while(0)
38 38
 #define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
39 39
 
40 40
 // pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities

+ 34
- 1
Marlin/src/HAL/HAL_STM32/pinsDebug.h View File

@@ -1 +1,34 @@
1
-#error "PINS_DEBUGGING is not yet supported for STM32!"
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2019 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
+#pragma once
20
+
21
+#if !(defined(NUM_DIGITAL_PINS) || defined(BOARD_NR_GPIO_PINS))
22
+  #error "M43 not supported for this board"
23
+#endif
24
+
25
+// Strange - STM32F4 comes to HAL_STM32 rather than HAL_STM32F4 for these files
26
+#ifdef STM32F4
27
+  #ifdef NUM_DIGITAL_PINS            // Only in ST's Arduino core (STM32duino, STM32Core)
28
+    #include "pinsDebug_STM32duino.h"
29
+  #elif defined(BOARD_NR_GPIO_PINS)  // Only in STM32GENERIC (Maple)
30
+    #include "pinsDebug_STM32GENERIC.h"
31
+  #else
32
+    #error "M43 not supported for this board"
33
+  #endif
34
+#endif

+ 138
- 0
Marlin/src/HAL/HAL_STM32/pinsDebug_STM32GENERIC.h View File

@@ -0,0 +1,138 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2019 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
+#pragma once
20
+
21
+/**
22
+ * Support routines for STM32GENERIC (Maple)
23
+ */
24
+
25
+/**
26
+ * Translation of routines & variables used by pinsDebug.h
27
+ */
28
+
29
+#ifdef BOARD_NR_GPIO_PINS  // Only in STM32GENERIC (Maple)
30
+
31
+#ifdef __STM32F1__
32
+  #include "../HAL_STM32F1/fastio_STM32F1.h"
33
+#elif defined(STM32F4)
34
+  #include "../HAL_STM32F4/fastio_STM32F4.h"
35
+#elif defined(STM32F7)
36
+  #include "../HAL_STM32F7/fastio_STM32F7.h"
37
+#endif
38
+
39
+extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS];
40
+
41
+#define NUM_DIGITAL_PINS BOARD_NR_GPIO_PINS
42
+#define NUMBER_PINS_TOTAL BOARD_NR_GPIO_PINS
43
+#define VALID_PIN(pin) (pin >= 0 && pin < BOARD_NR_GPIO_PINS)
44
+#define GET_ARRAY_PIN(p) pin_t(pin_array[p].pin)
45
+#define pwm_status(pin) PWM_PIN(pin)
46
+#define digitalRead_mod(p) extDigitalRead(p)
47
+#define NAME_FORMAT(p) PSTR("%-##p##s")
48
+#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3hd "), int16_t(p)); SERIAL_ECHO(buffer); }while(0)
49
+#define PRINT_PORT(p) print_port(p)
50
+#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
51
+#define MULTI_NAME_PAD 20 // space needed to be pretty if not first name assigned to a pin
52
+
53
+// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities
54
+#ifndef M43_NEVER_TOUCH
55
+  #define M43_NEVER_TOUCH(Q) (Q >= 9 && Q <= 12) // SERIAL/USB pins PA9(TX) PA10(RX)
56
+#endif
57
+
58
+static inline int8_t get_pin_mode(pin_t pin) {
59
+  return VALID_PIN(pin) ? _GET_MODE(pin) : -1;
60
+}
61
+
62
+static inline pin_t DIGITAL_PIN_TO_ANALOG_PIN(pin_t pin) {
63
+  if (!VALID_PIN(pin)) return -1;
64
+  int8_t adc_channel = int8_t(PIN_MAP[pin].adc_channel);
65
+  #ifdef NUM_ANALOG_INPUTS
66
+    if (adc_channel >= NUM_ANALOG_INPUTS) adc_channel = ADCx;
67
+  #endif
68
+  return pin_t(adc_channel);
69
+}
70
+
71
+static inline bool IS_ANALOG(pin_t pin) {
72
+  if (!VALID_PIN(pin)) return false;
73
+  if (PIN_MAP[pin].adc_channel != ADCx) {
74
+    #ifdef NUM_ANALOG_INPUTS
75
+      if (PIN_MAP[pin].adc_channel >= NUM_ANALOG_INPUTS) return false;
76
+    #endif
77
+    return _GET_MODE(pin) == GPIO_INPUT_ANALOG && !M43_NEVER_TOUCH(pin);
78
+  }
79
+  return false;
80
+}
81
+
82
+static inline bool GET_PINMODE(const pin_t pin) {
83
+  return VALID_PIN(pin) && !IS_INPUT(pin);
84
+}
85
+
86
+static inline bool GET_ARRAY_IS_DIGITAL(const int16_t array_pin) {
87
+  const pin_t pin = GET_ARRAY_PIN(array_pin);
88
+  return (!IS_ANALOG(pin)
89
+    #ifdef NUM_ANALOG_INPUTS
90
+      || PIN_MAP[pin].adc_channel >= NUM_ANALOG_INPUTS
91
+    #endif
92
+  );
93
+}
94
+
95
+static inline void pwm_details(const pin_t pin) {
96
+  if (PWM_PIN(pin)) {
97
+    timer_dev * const tdev = PIN_MAP[pin].timer_device;
98
+    const uint8_t channel = PIN_MAP[pin].timer_channel;
99
+    const char num = (
100
+      #ifdef STM32_HIGH_DENSITY
101
+        tdev == &timer8 ? '8' :
102
+        tdev == &timer5 ? '5' :
103
+      #endif
104
+      tdev == &timer4 ? '4' :
105
+      tdev == &timer3 ? '3' :
106
+      tdev == &timer2 ? '2' :
107
+      tdev == &timer1 ? '1' : '?'
108
+    );
109
+    char buffer[10];
110
+    sprintf_P(buffer, PSTR(" TIM%c CH%c"), num, ('0' + channel));
111
+    SERIAL_ECHO(buffer);
112
+  }
113
+}
114
+
115
+static inline void print_port(pin_t pin) {
116
+  const char port = 'A' + char(pin >> 4); // pin div 16
117
+  /* seems not to be required for our devices
118
+  gpio_dev * const gp = PIN_MAP[pin].gpio_device;
119
+  const char port = (
120
+    #if STM32_NR_GPIO_PORTS > 4
121
+      gp == &gpiog ? 'G' :
122
+      gp == &gpiof ? 'F' :
123
+      gp == &gpioe ? 'E' :
124
+    #endif
125
+    gp == &gpiod ? 'D' :
126
+    gp == &gpioc ? 'C' :
127
+    gp == &gpiob ? 'B' :
128
+    gp == &gpioa ? 'A' : '?'
129
+  );
130
+  */
131
+  const int16_t gbit = PIN_MAP[pin].gpio_bit;
132
+  char buffer[6];
133
+  sprintf_P(buffer, PSTR("P%c%hd "), port, gbit);
134
+  if (gbit < 10) SERIAL_CHAR(' ');
135
+  SERIAL_ECHO(buffer);
136
+}
137
+
138
+#endif // BOARD_NR_GPIO_PINS

+ 276
- 0
Marlin/src/HAL/HAL_STM32/pinsDebug_STM32duino.h View File

@@ -0,0 +1,276 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2019 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
+#pragma once
20
+
21
+#include <Arduino.h>
22
+
23
+#ifdef NUM_DIGITAL_PINS  // Only in ST's Arduino core (STM32duino, STM32Core)
24
+
25
+/**
26
+ *  Life gets complicated if you want an easy to use 'M43 I' output (in port/pin order)
27
+ *  because the variants in this platform do not always define all the I/O port/pins
28
+ *  that a CPU has.
29
+ *
30
+ *  VARIABLES:
31
+ *     Ard_num - Arduino pin number - defined by the platform. It is used by digitalRead and
32
+ *               digitalWrite commands and by M42.
33
+ *             - does not contain port/pin info
34
+ *             - is not in port/pin order
35
+ *             - typically a variant will only assign Ard_num to port/pins that are actually used
36
+ *     Index - M43 counter - only used to get Ard_num
37
+ *     x - a parameter/argument used to search the pin_array to try to find a signal name
38
+ *         associated with a Ard_num
39
+ *     Port_pin - port number and pin number for use with CPU registers and printing reports
40
+ *
41
+ *  Since M43 uses digitalRead and digitalWrite commands, only the Port_pins with an Ard_num
42
+ *  are accessed and/or displayed.
43
+ *
44
+ *  Three arrays are used.
45
+ *
46
+ *  digitalPin[] is provided by the platform.  It consists of the Port_pin numbers in
47
+ *  Arduino pin number order.
48
+ *
49
+ *  pin_array is a structure generated by the pins/pinsDebug.h header file.  It is generated by
50
+ *  the preprocessor. Only the signals associated with enabled options are in this table.
51
+ *  It contains:
52
+ *    - name of the signal
53
+ *    - the Ard_num assigned by the pins_YOUR_BOARD.h file using the platform defines.
54
+ *        EXAMPLE:  "#define KILL_PIN  PB1" results in Ard_num of 57.  57 is then used as an
55
+ *                  index into digitalPin[] to get the Port_pin number
56
+ *    - if it is a digital or analog signal.  PWMs are considered digital here.
57
+ *
58
+ *  pin_xref is a structure generated by this header file.  It is generated by the
59
+ *  preprocessor. It is in port/pin order.  It contains just the port/pin numbers defined by the
60
+ *  platform for this variant.
61
+ *    - Ard_num
62
+ *    - printable version of Port_pin
63
+ *
64
+ *  Routines with an "x" as a parameter/argument are used to search the pin_array to try to
65
+ *  find a signal name associated with a port/pin.
66
+ *
67
+ *  NOTE -  the Arduino pin number is what is used by the M42 command, NOT the port/pin for that
68
+ *          signal.  The Arduino pin number is listed by the M43 I command.
69
+ */
70
+
71
+extern const PinName digitalPin[];  // provided by the platform
72
+
73
+////////////////////////////////////////////////////////
74
+//
75
+// make a list of the Arduino pin numbers in the Port/Pin order
76
+//
77
+
78
+#define _PIN_ADD_2(NAME_ALPHA, ARDUINO_NUM) { {NAME_ALPHA}, ARDUINO_NUM },
79
+#define _PIN_ADD(NAME_ALPHA, ARDUINO_NUM) { NAME_ALPHA, ARDUINO_NUM },
80
+#define PIN_ADD(NAME) _PIN_ADD(#NAME, NAME)
81
+
82
+typedef struct {
83
+  char Port_pin_alpha[5];
84
+  pin_t Ard_num;
85
+} XrefInfo;
86
+
87
+const XrefInfo pin_xref[] PROGMEM = {
88
+  #include "pins_Xref.h"
89
+};
90
+
91
+////////////////////////////////////////////////////////////
92
+
93
+#define MODE_PIN_INPUT  0 // Input mode (reset state)
94
+#define MODE_PIN_OUTPUT 1 // General purpose output mode
95
+#define MODE_PIN_ALT    2 // Alternate function mode
96
+#define MODE_PIN_ANALOG 3 // Analog mode
97
+
98
+#define PIN_NUM(P) (P & 0x000F)
99
+#define PIN_NUM_ALPHA_LEFT(P) (((P & 0x000F) < 10) ? ('0' + (P & 0x000F)) : '1')
100
+#define PIN_NUM_ALPHA_RIGHT(P) (((P & 0x000F) > 9)  ? ('0' + (P & 0x000F) - 10) : 0 )
101
+#define PORT_NUM(P) ((P  >> 4) & 0x0007)
102
+#define PORT_ALPHA(P) ('A' + (P  >> 4))
103
+
104
+/**
105
+ * Translation of routines & variables used by pinsDebug.h
106
+ */
107
+#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
108
+#define VALID_PIN(ANUM) ((ANUM) >= 0 && (ANUM) < NUMBER_PINS_TOTAL)
109
+#define digitalRead_mod(Ard_num) extDigitalRead(Ard_num)  // must use Arduino pin numbers when doing reads
110
+#define NAME_FORMAT(p) PSTR("%-##p##s")
111
+#define PRINT_PIN(Q)
112
+#define PRINT_PORT(ANUM) port_print(ANUM)
113
+#define DIGITAL_PIN_TO_ANALOG_PIN(ANUM) -1  // will report analog pin number in the print port routine
114
+#define GET_PIN_MAP_PIN_M43(Index) pin_xref[Index].Ard_num
115
+
116
+// x is a variable used to search pin_array
117
+#define GET_ARRAY_IS_DIGITAL(x) ((bool) pin_array[x].is_digital)
118
+#define GET_ARRAY_PIN(x) ((pin_t) pin_array[x].pin)
119
+#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
120
+#define MULTI_NAME_PAD 33 // space needed to be pretty if not first name assigned to a pin
121
+
122
+#ifndef M43_NEVER_TOUCH
123
+  #define _M43_NEVER_TOUCH(Index) (Index >= 9 && Index <= 12) // SERIAL/USB pins: PA9(TX) PA10(RX) PA11(USB_DM) PA12(USB_DP)
124
+  #ifdef KILL_PIN
125
+    #define M43_NEVER_TOUCH(Index) m43_never_touch(Index)
126
+
127
+    bool m43_never_touch(const pin_t Index) {
128
+      static pin_t M43_kill_index = -1;
129
+      if (M43_kill_index < 0)
130
+        for (M43_kill_index = 0; M43_kill_index < NUMBER_PINS_TOTAL; M43_kill_index++)
131
+          if (KILL_PIN == GET_PIN_MAP_PIN_M43(M43_kill_index)) break;
132
+      return _M43_NEVER_TOUCH(Index) || Index == M43_kill_index; // KILL_PIN and SERIAL/USB
133
+    }
134
+  #else
135
+    #define M43_NEVER_TOUCH(Index) _M43_NEVER_TOUCH(Index)
136
+  #endif
137
+#endif
138
+
139
+uint8_t get_pin_mode(const pin_t Ard_num) {
140
+  uint32_t mode_all = 0;
141
+  const PinName dp = digitalPin[Ard_num];
142
+  switch (PORT_ALPHA(dp)) {
143
+    case 'A' : mode_all = GPIOA->MODER; break;
144
+    case 'B' : mode_all = GPIOB->MODER; break;
145
+    case 'C' : mode_all = GPIOC->MODER; break;
146
+    case 'D' : mode_all = GPIOD->MODER; break;
147
+    #ifdef PE_0
148
+      case 'E' : mode_all = GPIOE->MODER; break;
149
+    #elif defined (PF_0)
150
+      case 'F' : mode_all = GPIOF->MODER; break;
151
+    #elif defined (PG_0)
152
+      case 'G' : mode_all = GPIOG->MODER; break;
153
+    #elif defined (PH_0)
154
+      case 'H' : mode_all = GPIOH->MODER; break;
155
+    #elif defined (PI_0)
156
+      case 'I' : mode_all = GPIOI->MODER; break;
157
+    #elif defined (PJ_0)
158
+      case 'J' : mode_all = GPIOJ->MODER; break;
159
+    #elif defined (PK_0)
160
+      case 'K' : mode_all = GPIOK->MODER; break;
161
+    #elif defined (PL_0)
162
+      case 'L' : mode_all = GPIOL->MODER; break;
163
+    #endif
164
+  }
165
+  return (mode_all >> (2 * uint8_t(PIN_NUM(dp)))) & 0x03;
166
+}
167
+
168
+bool GET_PINMODE(const pin_t Ard_num) {
169
+  const uint8_t pin_mode = get_pin_mode(Ard_num);
170
+  return pin_mode == MODE_PIN_OUTPUT || pin_mode == MODE_PIN_ALT;  // assume all alt definitions are PWM
171
+}
172
+
173
+int8_t digital_pin_to_analog_pin(pin_t Ard_num) {
174
+  Ard_num -= NUM_ANALOG_FIRST;
175
+  return (Ard_num >= 0 && Ard_num < NUM_ANALOG_INPUTS) ? Ard_num : -1;
176
+}
177
+
178
+bool IS_ANALOG(const pin_t Ard_num) {
179
+  return get_pin_mode(Ard_num) == MODE_PIN_ANALOG;
180
+}
181
+
182
+bool is_digital(const pin_t x) {
183
+  const uint8_t pin_mode = get_pin_mode(pin_array[x].pin);
184
+  return pin_mode == MODE_PIN_INPUT || pin_mode == MODE_PIN_OUTPUT;
185
+}
186
+
187
+void port_print(const pin_t Ard_num) {
188
+  char buffer[16];
189
+  pin_t Index;
190
+  for (Index = 0; Index < NUMBER_PINS_TOTAL; Index++)
191
+    if (Ard_num == GET_PIN_MAP_PIN_M43(Index)) break;
192
+
193
+  char * const ppa = pin_xref[Index].Port_pin_alpha;
194
+  sprintf_P(buffer, PSTR("%s"), ppa);
195
+  SERIAL_ECHO(buffer);
196
+  if (ppa[3] == '\0') SERIAL_CHAR(' ');
197
+
198
+  // print analog pin number
199
+  const int8_t Port_pin = digital_pin_to_analog_pin(Ard_num);
200
+  if (Port_pin >= 0) {
201
+    sprintf_P(buffer, PSTR(" (A%d) "), Port_pin);
202
+    SERIAL_ECHO(buffer);
203
+    if (Port_pin < 10) SERIAL_CHAR(' ');
204
+  }
205
+  else
206
+    SERIAL_ECHO_SP(7);
207
+
208
+  // Print number to be used with M42
209
+  sprintf_P(buffer, PSTR(" M42 P%d "), Ard_num);
210
+  SERIAL_ECHO(buffer);
211
+  if (Ard_num < 10) SERIAL_CHAR(' ');
212
+  if (Ard_num < 100) SERIAL_CHAR(' ');
213
+}
214
+
215
+bool pwm_status(const pin_t Ard_num) {
216
+  return get_pin_mode(Ard_num) == MODE_PIN_ALT;
217
+}
218
+
219
+void pwm_details(const pin_t Ard_num) {
220
+  if (pwm_status(Ard_num)) {
221
+    uint32_t alt_all = 0;
222
+    const PinName dp = digitalPin[Ard_num];
223
+    pin_t pin_number = uint8_t(PIN_NUM(dp));
224
+    const bool over_7 = pin_number >= 8;
225
+    const uint8_t ind = over_7 ? 1 : 0;
226
+    switch (PORT_ALPHA(dp)) {  // get alt function
227
+      case 'A' : alt_all = GPIOA->AFR[ind]; break;
228
+      case 'B' : alt_all = GPIOB->AFR[ind]; break;
229
+      case 'C' : alt_all = GPIOC->AFR[ind]; break;
230
+      case 'D' : alt_all = GPIOD->AFR[ind]; break;
231
+      #ifdef PE_0
232
+        case 'E' : alt_all = GPIOE->AFR[ind]; break;
233
+      #elif defined (PF_0)
234
+        case 'F' : alt_all = GPIOF->AFR[ind]; break;
235
+      #elif defined (PG_0)
236
+        case 'G' : alt_all = GPIOG->AFR[ind]; break;
237
+      #elif defined (PH_0)
238
+        case 'H' : alt_all = GPIOH->AFR[ind]; break;
239
+      #elif defined (PI_0)
240
+        case 'I' : alt_all = GPIOI->AFR[ind]; break;
241
+      #elif defined (PJ_0)
242
+        case 'J' : alt_all = GPIOJ->AFR[ind]; break;
243
+      #elif defined (PK_0)
244
+        case 'K' : alt_all = GPIOK->AFR[ind]; break;
245
+      #elif defined (PL_0)
246
+        case 'L' : alt_all = GPIOL->AFR[ind]; break;
247
+      #endif
248
+    }
249
+    if (over_7) pin_number -= 8;
250
+
251
+    uint8_t alt_func = (alt_all >> (4 * pin_number)) & 0x0F;
252
+    SERIAL_ECHOPAIR("Alt Function: ", alt_func);
253
+    if (alt_func < 10) SERIAL_CHAR(' ');
254
+    SERIAL_ECHOPGM(" - ");
255
+    switch (alt_func) {
256
+      case  0 : SERIAL_ECHOPGM("system (misc. I/O)"); break;
257
+      case  1 : SERIAL_ECHOPGM("TIM1/TIM2 (probably PWM)"); break;
258
+      case  2 : SERIAL_ECHOPGM("TIM3..5 (probably PWM)"); break;
259
+      case  3 : SERIAL_ECHOPGM("TIM8..11 (probably PWM)"); break;
260
+      case  4 : SERIAL_ECHOPGM("I2C1..3"); break;
261
+      case  5 : SERIAL_ECHOPGM("SPI1/SPI2"); break;
262
+      case  6 : SERIAL_ECHOPGM("SPI3"); break;
263
+      case  7 : SERIAL_ECHOPGM("USART1..3"); break;
264
+      case  8 : SERIAL_ECHOPGM("USART4..6"); break;
265
+      case  9 : SERIAL_ECHOPGM("CAN1/CAN2, TIM12..14  (probably PWM)"); break;
266
+      case 10 : SERIAL_ECHOPGM("OTG"); break;
267
+      case 11 : SERIAL_ECHOPGM("ETH"); break;
268
+      case 12 : SERIAL_ECHOPGM("FSMC, SDIO, OTG"); break;
269
+      case 13 : SERIAL_ECHOPGM("DCMI"); break;
270
+      case 14 : SERIAL_ECHOPGM("unused (shouldn't see this)"); break;
271
+      case 15 : SERIAL_ECHOPGM("EVENTOUT"); break;
272
+    }
273
+  }
274
+} // pwm_details
275
+
276
+#endif // NUM_DIGITAL_PINS

+ 612
- 0
Marlin/src/HAL/HAL_STM32/pins_Xref.h View File

@@ -0,0 +1,612 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+//
24
+// make a list of the Arduino pin numbers in the Port/Pin order
25
+//
26
+#ifdef PA0
27
+  PIN_ADD(PA0)
28
+#endif
29
+#ifdef PA1
30
+  PIN_ADD(PA1)
31
+#endif
32
+#ifdef PA2
33
+  PIN_ADD(PA2)
34
+#endif
35
+#ifdef PA3
36
+  PIN_ADD(PA3)
37
+#endif
38
+#ifdef PA4
39
+  PIN_ADD(PA4)
40
+#endif
41
+#ifdef PA5
42
+  PIN_ADD(PA5)
43
+#endif
44
+#ifdef PA6
45
+  PIN_ADD(PA6)
46
+#endif
47
+#ifdef PA7
48
+  PIN_ADD(PA7)
49
+#endif
50
+#ifdef PA8
51
+  PIN_ADD(PA8)
52
+#endif
53
+#ifdef PA9
54
+  PIN_ADD(PA9)
55
+#endif
56
+#ifdef PA10
57
+  PIN_ADD(PA10)
58
+#endif
59
+#ifdef PA11
60
+  PIN_ADD(PA11)
61
+#endif
62
+#ifdef PA12
63
+  PIN_ADD(PA12)
64
+#endif
65
+#ifdef PA13
66
+  PIN_ADD(PA13)
67
+#endif
68
+#ifdef PA14
69
+  PIN_ADD(PA14)
70
+#endif
71
+#ifdef PA15
72
+  PIN_ADD(PA15)
73
+#endif
74
+
75
+#ifdef PB0
76
+  PIN_ADD(PB0)
77
+#endif
78
+#ifdef PB1
79
+  PIN_ADD(PB1)
80
+#endif
81
+#ifdef PB2
82
+  PIN_ADD(PB2)
83
+#endif
84
+#ifdef PB3
85
+  PIN_ADD(PB3)
86
+#endif
87
+#ifdef PB4
88
+  PIN_ADD(PB4)
89
+#endif
90
+#ifdef PB5
91
+  PIN_ADD(PB5)
92
+#endif
93
+#ifdef PB6
94
+  PIN_ADD(PB6)
95
+#endif
96
+#ifdef PB7
97
+  PIN_ADD(PB7)
98
+#endif
99
+#ifdef PB8
100
+  PIN_ADD(PB8)
101
+#endif
102
+#ifdef PB9
103
+  PIN_ADD(PB9)
104
+#endif
105
+#ifdef PB10
106
+  PIN_ADD(PB10)
107
+#endif
108
+#ifdef PB11
109
+  PIN_ADD(PB11)
110
+#endif
111
+#ifdef PB12
112
+  PIN_ADD(PB12)
113
+#endif
114
+#ifdef PB13
115
+  PIN_ADD(PB13)
116
+#endif
117
+#ifdef PB14
118
+  PIN_ADD(PB14)
119
+#endif
120
+#ifdef PB15
121
+  PIN_ADD(PB15)
122
+#endif
123
+
124
+#ifdef PC0
125
+  PIN_ADD(PC0)
126
+#endif
127
+#ifdef PC1
128
+  PIN_ADD(PC1)
129
+#endif
130
+#ifdef PC2
131
+  PIN_ADD(PC2)
132
+#endif
133
+#ifdef PC3
134
+  PIN_ADD(PC3)
135
+#endif
136
+#ifdef PC4
137
+  PIN_ADD(PC4)
138
+#endif
139
+#ifdef PC5
140
+  PIN_ADD(PC5)
141
+#endif
142
+#ifdef PC6
143
+  PIN_ADD(PC6)
144
+#endif
145
+#ifdef PC7
146
+  PIN_ADD(PC7)
147
+#endif
148
+#ifdef PC8
149
+  PIN_ADD(PC8)
150
+#endif
151
+#ifdef PC9
152
+  PIN_ADD(PC9)
153
+#endif
154
+#ifdef PC10
155
+  PIN_ADD(PC10)
156
+#endif
157
+#ifdef PC11
158
+  PIN_ADD(PC11)
159
+#endif
160
+#ifdef PC12
161
+  PIN_ADD(PC12)
162
+#endif
163
+#ifdef PC13
164
+  PIN_ADD(PC13)
165
+#endif
166
+#ifdef PC14
167
+  PIN_ADD(PC14)
168
+#endif
169
+#ifdef PC15
170
+  PIN_ADD(PC15)
171
+#endif
172
+
173
+#ifdef PD0
174
+  PIN_ADD(PD0)
175
+#endif
176
+#ifdef PD1
177
+  PIN_ADD(PD1)
178
+#endif
179
+#ifdef PD2
180
+  PIN_ADD(PD2)
181
+#endif
182
+#ifdef PD3
183
+  PIN_ADD(PD3)
184
+#endif
185
+#ifdef PD4
186
+  PIN_ADD(PD4)
187
+#endif
188
+#ifdef PD5
189
+  PIN_ADD(PD5)
190
+#endif
191
+#ifdef PD6
192
+  PIN_ADD(PD6)
193
+#endif
194
+#ifdef PD7
195
+  PIN_ADD(PD7)
196
+#endif
197
+#ifdef PD8
198
+  PIN_ADD(PD8)
199
+#endif
200
+#ifdef PD9
201
+  PIN_ADD(PD9)
202
+#endif
203
+#ifdef PD10
204
+  PIN_ADD(PD10)
205
+#endif
206
+#ifdef PD11
207
+  PIN_ADD(PD11)
208
+#endif
209
+#ifdef PD12
210
+  PIN_ADD(PD12)
211
+#endif
212
+#ifdef PD13
213
+  PIN_ADD(PD13)
214
+#endif
215
+#ifdef PD14
216
+  PIN_ADD(PD14)
217
+#endif
218
+#ifdef PD15
219
+  PIN_ADD(PD15)
220
+#endif
221
+
222
+#ifdef PE0
223
+  PIN_ADD(PE0)
224
+#endif
225
+#ifdef PE1
226
+  PIN_ADD(PE1)
227
+#endif
228
+#ifdef PE2
229
+  PIN_ADD(PE2)
230
+#endif
231
+#ifdef PE3
232
+  PIN_ADD(PE3)
233
+#endif
234
+#ifdef PE4
235
+  PIN_ADD(PE4)
236
+#endif
237
+#ifdef PE5
238
+  PIN_ADD(PE5)
239
+#endif
240
+#ifdef PE6
241
+  PIN_ADD(PE6)
242
+#endif
243
+#ifdef PE7
244
+  PIN_ADD(PE7)
245
+#endif
246
+#ifdef PE8
247
+  PIN_ADD(PE8)
248
+#endif
249
+#ifdef PE9
250
+  PIN_ADD(PE9)
251
+#endif
252
+#ifdef PE10
253
+  PIN_ADD(PE10)
254
+#endif
255
+#ifdef PE11
256
+  PIN_ADD(PE11)
257
+#endif
258
+#ifdef PE12
259
+  PIN_ADD(PE12)
260
+#endif
261
+#ifdef PE13
262
+  PIN_ADD(PE13)
263
+#endif
264
+#ifdef PE14
265
+  PIN_ADD(PE14)
266
+#endif
267
+#ifdef PE15
268
+  PIN_ADD(PE15)
269
+#endif
270
+
271
+#ifdef PF0
272
+  PIN_ADD(PF0)
273
+#endif
274
+#ifdef PF1
275
+  PIN_ADD(PF1)
276
+#endif
277
+#ifdef PF2
278
+  PIN_ADD(PF2)
279
+#endif
280
+#ifdef PF3
281
+  PIN_ADD(PF3)
282
+#endif
283
+#ifdef PF4
284
+  PIN_ADD(PF4)
285
+#endif
286
+#ifdef PF5
287
+  PIN_ADD(PF5)
288
+#endif
289
+#ifdef PF6
290
+  PIN_ADD(PF6)
291
+#endif
292
+#ifdef PF7
293
+  PIN_ADD(PF7)
294
+#endif
295
+#ifdef PF8
296
+  PIN_ADD(PF8)
297
+#endif
298
+#ifdef PF9
299
+  PIN_ADD(PF9)
300
+#endif
301
+#ifdef PF10
302
+  PIN_ADD(PF10)
303
+#endif
304
+#ifdef PF11
305
+  PIN_ADD(PF11)
306
+#endif
307
+#ifdef PF12
308
+  PIN_ADD(PF12)
309
+#endif
310
+#ifdef PF13
311
+  PIN_ADD(PF13)
312
+#endif
313
+#ifdef PF14
314
+  PIN_ADD(PF14)
315
+#endif
316
+#ifdef PF15
317
+  PIN_ADD(PF15)
318
+#endif
319
+
320
+#ifdef PG0
321
+  PIN_ADD(PG0)
322
+#endif
323
+#ifdef PG1
324
+  PIN_ADD(PG1)
325
+#endif
326
+#ifdef PG2
327
+  PIN_ADD(PG2)
328
+#endif
329
+#ifdef PG3
330
+  PIN_ADD(PG3)
331
+#endif
332
+#ifdef PG4
333
+  PIN_ADD(PG4)
334
+#endif
335
+#ifdef PG5
336
+  PIN_ADD(PG5)
337
+#endif
338
+#ifdef PG6
339
+  PIN_ADD(PG6)
340
+#endif
341
+#ifdef PG7
342
+  PIN_ADD(PG7)
343
+#endif
344
+#ifdef PG8
345
+  PIN_ADD(PG8)
346
+#endif
347
+#ifdef PG9
348
+  PIN_ADD(PG9)
349
+#endif
350
+#ifdef PG10
351
+  PIN_ADD(PG10)
352
+#endif
353
+#ifdef PG11
354
+  PIN_ADD(PG11)
355
+#endif
356
+#ifdef PG12
357
+  PIN_ADD(PG12)
358
+#endif
359
+#ifdef PG13
360
+  PIN_ADD(PG13)
361
+#endif
362
+#ifdef PG14
363
+  PIN_ADD(PG14)
364
+#endif
365
+#ifdef PG15
366
+  PIN_ADD(PG15)
367
+#endif
368
+
369
+#ifdef PH0
370
+  PIN_ADD(PH0)
371
+#endif
372
+#ifdef PH1
373
+  PIN_ADD(PH1)
374
+#endif
375
+#ifdef PH2
376
+  PIN_ADD(PH2)
377
+#endif
378
+#ifdef PH3
379
+  PIN_ADD(PH3)
380
+#endif
381
+#ifdef PH4
382
+  PIN_ADD(PH4)
383
+#endif
384
+#ifdef PH5
385
+  PIN_ADD(PH5)
386
+#endif
387
+#ifdef PH6
388
+  PIN_ADD(PH6)
389
+#endif
390
+#ifdef PH7
391
+  PIN_ADD(PH7)
392
+#endif
393
+#ifdef PH8
394
+  PIN_ADD(PH8)
395
+#endif
396
+#ifdef PH9
397
+  PIN_ADD(PH9)
398
+#endif
399
+#ifdef PH10
400
+  PIN_ADD(PH10)
401
+#endif
402
+#ifdef PH11
403
+  PIN_ADD(PH11)
404
+#endif
405
+#ifdef PH12
406
+  PIN_ADD(PH12)
407
+#endif
408
+#ifdef PH13
409
+  PIN_ADD(PH13)
410
+#endif
411
+#ifdef PH14
412
+  PIN_ADD(PH14)
413
+#endif
414
+#ifdef PH15
415
+  PIN_ADD(PH15)
416
+#endif
417
+
418
+#ifdef PI0
419
+  PIN_ADD(PI0)
420
+#endif
421
+#ifdef PI1
422
+  PIN_ADD(PI1)
423
+#endif
424
+#ifdef PI2
425
+  PIN_ADD(PI2)
426
+#endif
427
+#ifdef PI3
428
+  PIN_ADD(PI3)
429
+#endif
430
+#ifdef PI4
431
+  PIN_ADD(PI4)
432
+#endif
433
+#ifdef PI5
434
+  PIN_ADD(PI5)
435
+#endif
436
+#ifdef PI6
437
+  PIN_ADD(PI6)
438
+#endif
439
+#ifdef PI7
440
+  PIN_ADD(PI7)
441
+#endif
442
+#ifdef PI8
443
+  PIN_ADD(PI8)
444
+#endif
445
+#ifdef PI9
446
+  PIN_ADD(PI9)
447
+#endif
448
+#ifdef PI10
449
+  PIN_ADD(PI10)
450
+#endif
451
+#ifdef PI11
452
+  PIN_ADD(PI11)
453
+#endif
454
+#ifdef PI12
455
+  PIN_ADD(PI12)
456
+#endif
457
+#ifdef PI13
458
+  PIN_ADD(PI13)
459
+#endif
460
+#ifdef PI14
461
+  PIN_ADD(PI14)
462
+#endif
463
+#ifdef PI15
464
+  PIN_ADD(PI15)
465
+#endif
466
+
467
+#ifdef PJ0
468
+  PIN_ADD(PJ0)
469
+#endif
470
+#ifdef PJ1
471
+  PIN_ADD(PJ1)
472
+#endif
473
+#ifdef PJ2
474
+  PIN_ADD(PJ2)
475
+#endif
476
+#ifdef PJ3
477
+  PIN_ADD(PJ3)
478
+#endif
479
+#ifdef PJ4
480
+  PIN_ADD(PJ4)
481
+#endif
482
+#ifdef PJ5
483
+  PIN_ADD(PJ5)
484
+#endif
485
+#ifdef PJ6
486
+  PIN_ADD(PJ6)
487
+#endif
488
+#ifdef PJ7
489
+  PIN_ADD(PJ7)
490
+#endif
491
+#ifdef PJ8
492
+  PIN_ADD(PJ8)
493
+#endif
494
+#ifdef PJ9
495
+  PIN_ADD(PJ9)
496
+#endif
497
+#ifdef PJ10
498
+  PIN_ADD(PJ10)
499
+#endif
500
+#ifdef PJ11
501
+  PIN_ADD(PJ11)
502
+#endif
503
+#ifdef PJ12
504
+  PIN_ADD(PJ12)
505
+#endif
506
+#ifdef PJ13
507
+  PIN_ADD(PJ13)
508
+#endif
509
+#ifdef PJ14
510
+  PIN_ADD(PJ14)
511
+#endif
512
+#ifdef PJ15
513
+  PIN_ADD(PJ15)
514
+#endif
515
+
516
+#ifdef PK0
517
+  PIN_ADD(PK0)
518
+#endif
519
+#ifdef PK1
520
+  PIN_ADD(PK1)
521
+#endif
522
+#ifdef PK2
523
+  PIN_ADD(PK2)
524
+#endif
525
+#ifdef PK3
526
+  PIN_ADD(PK3)
527
+#endif
528
+#ifdef PK4
529
+  PIN_ADD(PK4)
530
+#endif
531
+#ifdef PK5
532
+  PIN_ADD(PK5)
533
+#endif
534
+#ifdef PK6
535
+  PIN_ADD(PK6)
536
+#endif
537
+#ifdef PK7
538
+  PIN_ADD(PK7)
539
+#endif
540
+#ifdef PK8
541
+  PIN_ADD(PK8)
542
+#endif
543
+#ifdef PK9
544
+  PIN_ADD(PK9)
545
+#endif
546
+#ifdef PK10
547
+  PIN_ADD(PK10)
548
+#endif
549
+#ifdef PK11
550
+  PIN_ADD(PK11)
551
+#endif
552
+#ifdef PK12
553
+  PIN_ADD(PK12)
554
+#endif
555
+#ifdef PK13
556
+  PIN_ADD(PK13)
557
+#endif
558
+#ifdef PK14
559
+  PIN_ADD(PK14)
560
+#endif
561
+#ifdef PK15
562
+  PIN_ADD(PK15)
563
+#endif
564
+
565
+#ifdef PL0
566
+  PIN_ADD(PL0)
567
+#endif
568
+#ifdef PL1
569
+  PIN_ADD(PL1)
570
+#endif
571
+#ifdef PL2
572
+  PIN_ADD(PL2)
573
+#endif
574
+#ifdef PL3
575
+  PIN_ADD(PL3)
576
+#endif
577
+#ifdef PL4
578
+  PIN_ADD(PL4)
579
+#endif
580
+#ifdef PL5
581
+  PIN_ADD(PL5)
582
+#endif
583
+#ifdef PL6
584
+  PIN_ADD(PL6)
585
+#endif
586
+#ifdef PL7
587
+  PIN_ADD(PL7)
588
+#endif
589
+#ifdef PL8
590
+  PIN_ADD(PL8)
591
+#endif
592
+#ifdef PL9
593
+  PIN_ADD(PL9)
594
+#endif
595
+#ifdef PL10
596
+  PIN_ADD(PL10)
597
+#endif
598
+#ifdef PL11
599
+  PIN_ADD(PL11)
600
+#endif
601
+#ifdef PL12
602
+  PIN_ADD(PL12)
603
+#endif
604
+#ifdef PL13
605
+  PIN_ADD(PL13)
606
+#endif
607
+#ifdef PL14
608
+  PIN_ADD(PL14)
609
+#endif
610
+#ifdef PL15
611
+  PIN_ADD(PL15)
612
+#endif

+ 8
- 108
Marlin/src/HAL/HAL_STM32F1/pinsDebug.h View File

@@ -16,112 +16,12 @@
16 16
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17
  *
18 18
  */
19
-
20
-/**
21
- * Support routines for STM32F1
22
- */
23
-#ifdef __STM32F1__
24
-
25
-/**
26
- * Translation of routines & variables used by pinsDebug.h
27
- */
28
-#include "fastio_STM32F1.h"
29
-
30
-extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS];
31
-
32
-#define NUM_DIGITAL_PINS BOARD_NR_GPIO_PINS
33
-#define NUMBER_PINS_TOTAL BOARD_NR_GPIO_PINS
34
-#define VALID_PIN(pin) (pin >= 0 && pin < BOARD_NR_GPIO_PINS)
35
-#define GET_ARRAY_PIN(p) pin_t(pin_array[p].pin)
36
-#define pwm_status(pin) PWM_PIN(pin)
37
-#define digitalRead_mod(p) extDigitalRead(p)
38
-#define NAME_FORMAT(p) PSTR("%-##p##s")
39
-#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3hd "), int16_t(p)); SERIAL_ECHO(buffer); }while(0)
40
-#define PRINT_PORT(p) print_port(p)
41
-#define PRINT_ARRAY_NAME(x)  do {sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer);} while (0)
42
-#define MULTI_NAME_PAD 20 // spaces needed to be pretty if not first name assigned to a pin
43
-
44
-// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities
45
-#ifndef M43_NEVER_TOUCH
46
-  #define M43_NEVER_TOUCH(Q) (Q >= 9 && Q <= 12) // SERIAL/USB pins PA9(TX) PA10(RX)
19
+#pragma once
20
+
21
+#ifdef NUM_DIGITAL_PINS             // Only in ST's Arduino core (STM32duino, STM32Core)
22
+  #include "../HAL_STM32/pinsDebug_STM32duino.h"
23
+#elif defined(BOARD_NR_GPIO_PINS)   // Only in STM32GENERIC (Maple)
24
+  #include "../HAL_STM32/pinsDebug_STM32GENERIC.h"
25
+#else
26
+  #error "M43 not supported for this board"
47 27
 #endif
48
-
49
-static inline int8_t get_pin_mode(pin_t pin) {
50
-  return VALID_PIN(pin) ? _GET_MODE(pin) : -1;
51
-}
52
-
53
-static inline pin_t DIGITAL_PIN_TO_ANALOG_PIN(pin_t pin) {
54
-  if (!VALID_PIN(pin)) return -1;
55
-  int8_t adc_channel = int8_t(PIN_MAP[pin].adc_channel);
56
-  #ifdef NUM_ANALOG_INPUTS
57
-    if (adc_channel >= NUM_ANALOG_INPUTS) adc_channel = ADCx;
58
-  #endif
59
-  return pin_t(adc_channel);
60
-}
61
-
62
-static inline bool IS_ANALOG(pin_t pin) {
63
-  if (!VALID_PIN(pin)) return false;
64
-  if (PIN_MAP[pin].adc_channel != ADCx) {
65
-    #ifdef NUM_ANALOG_INPUTS
66
-      if (PIN_MAP[pin].adc_channel >= NUM_ANALOG_INPUTS) return false;
67
-    #endif
68
-    return _GET_MODE(pin) == GPIO_INPUT_ANALOG && !M43_NEVER_TOUCH(pin);
69
-  }
70
-  return false;
71
-}
72
-
73
-static inline bool GET_PINMODE(pin_t pin) {
74
-  return VALID_PIN(pin) ? !IS_INPUT(pin) : false;
75
-}
76
-
77
-static inline bool GET_ARRAY_IS_DIGITAL(int16_t array_pin) {
78
-  pin_t pin = GET_ARRAY_PIN(array_pin);
79
-  bool isDigital = !IS_ANALOG(pin);
80
-  #ifdef NUM_ANALOG_INPUTS
81
-    if (!isDigital && PIN_MAP[pin].adc_channel >= NUM_ANALOG_INPUTS)
82
-      isDigital = true;
83
-  #endif
84
-  return isDigital;
85
-}
86
-
87
-static inline void pwm_details(pin_t pin) {
88
-  if (PWM_PIN(pin)) {
89
-    char buffer[16], num = '?';
90
-    timer_dev * const tdev = PIN_MAP[pin].timer_device;
91
-    const uint8_t channel = PIN_MAP[pin].timer_channel;
92
-    if (tdev == &timer1) num = '1';
93
-    else if (tdev == &timer1) num = '1';
94
-    else if (tdev == &timer2) num = '2';
95
-    else if (tdev == &timer3) num = '3';
96
-    else if (tdev == &timer4) num = '4';
97
-    #ifdef STM32_HIGH_DENSITY
98
-      else if (tdev == &timer5) num = '5';
99
-      else if (tdev == &timer8) num = '8';
100
-    #endif
101
-    sprintf_P(buffer, PSTR(" TIM%c CH%c"), num, ('0' + channel));
102
-    SERIAL_ECHO(buffer);
103
-  }
104
-}
105
-
106
-static inline void print_port(pin_t pin) {
107
-  char buffer[8];
108
-  char port = 'A' + char(pin >> 4); // pin div 16
109
-  /* seems not to be required for our devices
110
-    gpio_dev* gp = PIN_MAP[pin].gpio_device;
111
-    if (gp == &gpioa) port = 'A';
112
-    else if (gp == &gpiob) port = 'B';
113
-    else if (gp == &gpioc) port = 'C';
114
-    else if (gp == &gpiod) port = 'D';
115
-    #if STM32_NR_GPIO_PORTS > 4
116
-      else if (gp == &gpioe) port = 'E';
117
-      else if (gp == &gpiof) port = 'F';
118
-      else if (gp == &gpiog) port = 'G';
119
-    #endif
120
-  */
121
-  const int16_t gbit = PIN_MAP[pin].gpio_bit;
122
-  sprintf_P(buffer, PSTR("P%c%hd "), port, gbit);
123
-  if (gbit < 10) SERIAL_CHAR(' ');
124
-  SERIAL_ECHO(buffer);
125
-}
126
-
127
-#endif // __STM32F1__

+ 1
- 1
Marlin/src/HAL/HAL_STM32F4/fastio_STM32F4.h View File

@@ -65,7 +65,7 @@
65 65
 #define PORTD 3
66 66
 #define PORTE 4
67 67
 
68
-#define _STM32_PIN(_PORT,_PIN) ((PORT##_PORT * 16) + _PIN)
68
+#define _STM32_PIN(P,PN) ((PORT##P * 16) + PN)
69 69
 
70 70
 #define PA0  _STM32_PIN(A,  0)
71 71
 #define PA1  _STM32_PIN(A,  1)

+ 27
- 1
Marlin/src/HAL/HAL_STM32F4/pinsDebug.h View File

@@ -1 +1,27 @@
1
-#error Debug pins is not supported on this Platform!
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2019 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
+#pragma once
20
+
21
+#ifdef NUM_DIGITAL_PINS             // Only in ST's Arduino core (STM32duino, STM32Core)
22
+  #include "../HAL_STM32/pinsDebug_STM32duino.h"
23
+#elif defined(BOARD_NR_GPIO_PINS)   // Only in STM32GENERIC (Maple)
24
+  #include "../HAL_STM32/pinsDebug_STM32GENERIC.h"
25
+#else
26
+  #error "M43 not supported for this board"
27
+#endif

+ 27
- 1
Marlin/src/HAL/HAL_STM32F7/pinsDebug.h View File

@@ -1 +1,27 @@
1
-#error Debug pins is not supported on this Platform!
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2019 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
+#pragma once
20
+
21
+#ifdef NUM_DIGITAL_PINS             // Only in ST's Arduino core (STM32duino, STM32Core)
22
+  #include "../HAL_STM32/pinsDebug_STM32duino.h"
23
+#elif defined(BOARD_NR_GPIO_PINS)   // Only in STM32GENERIC (Maple)
24
+  #include "../HAL_STM32/pinsDebug_STM32GENERIC.h"
25
+#else
26
+  #error "M43 not supported for this board"
27
+#endif

+ 8
- 4
Marlin/src/gcode/config/M43.cpp View File

@@ -42,6 +42,10 @@
42 42
   #include "../../feature/host_actions.h"
43 43
 #endif
44 44
 
45
+#ifndef GET_PIN_MAP_PIN_M43
46
+  #define GET_PIN_MAP_PIN_M43(Q) GET_PIN_MAP_PIN(Q)
47
+#endif
48
+
45 49
 inline void toggle_pins() {
46 50
   const bool ignore_protection = parser.boolval('I');
47 51
   const int repeat = parser.intval('R', 1),
@@ -50,7 +54,7 @@ inline void toggle_pins() {
50 54
             wait = parser.intval('W', 500);
51 55
 
52 56
   for (uint8_t i = start; i <= end; i++) {
53
-    pin_t pin = GET_PIN_MAP_PIN(i);
57
+    pin_t pin = GET_PIN_MAP_PIN_M43(i);
54 58
     if (!VALID_PIN(pin)) continue;
55 59
     if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) {
56 60
       report_pin_state_extended(pin, ignore_protection, true, "Untouched ");
@@ -306,7 +310,7 @@ void GcodeSuite::M43() {
306 310
     #endif
307 311
     uint8_t pin_state[last_pin - first_pin + 1];
308 312
     for (uint8_t i = first_pin; i <= last_pin; i++) {
309
-      pin_t pin = GET_PIN_MAP_PIN(i);
313
+      pin_t pin = GET_PIN_MAP_PIN_M43(i);
310 314
       if (!VALID_PIN(pin)) continue;
311 315
       if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue;
312 316
       pinMode(pin, INPUT_PULLUP);
@@ -329,7 +333,7 @@ void GcodeSuite::M43() {
329 333
 
330 334
     for (;;) {
331 335
       for (uint8_t i = first_pin; i <= last_pin; i++) {
332
-        pin_t pin = GET_PIN_MAP_PIN(i);
336
+        pin_t pin = GET_PIN_MAP_PIN_M43(i);
333 337
         if (!VALID_PIN(pin)) continue;
334 338
         if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue;
335 339
         const byte val =
@@ -355,7 +359,7 @@ void GcodeSuite::M43() {
355 359
   else {
356 360
     // Report current state of selected pin(s)
357 361
     for (uint8_t i = first_pin; i <= last_pin; i++) {
358
-      pin_t pin = GET_PIN_MAP_PIN(i);
362
+      pin_t pin = GET_PIN_MAP_PIN_M43(i);
359 363
       if (VALID_PIN(pin)) report_pin_state_extended(pin, ignore_protection, true);
360 364
     }
361 365
   }

+ 10
- 4
Marlin/src/pins/pinsDebug.h View File

@@ -121,7 +121,7 @@ inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = fa
121 121
         SERIAL_ECHO(buffer);
122 122
         PRINT_PIN(pin);
123 123
         PRINT_PORT(pin);
124
-        if (IS_ANALOG(pin)) {
124
+        if (int8_t(DIGITAL_PIN_TO_ANALOG_PIN(pin)) >= 0) {
125 125
           sprintf_P(buffer, PSTR(" (A%2d)  "), DIGITAL_PIN_TO_ANALOG_PIN(pin));    // analog pin number
126 126
           SERIAL_ECHO(buffer);
127 127
         }
@@ -183,7 +183,7 @@ inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = fa
183 183
     SERIAL_ECHO(buffer);
184 184
     PRINT_PIN(pin);
185 185
     PRINT_PORT(pin);
186
-    if (IS_ANALOG(pin)) {
186
+    if (int8_t(DIGITAL_PIN_TO_ANALOG_PIN(pin)) >= 0) {
187 187
       sprintf_P(buffer, PSTR(" (A%2d)  "), DIGITAL_PIN_TO_ANALOG_PIN(pin));    // analog pin number
188 188
       SERIAL_ECHO(buffer);
189 189
     }
@@ -206,7 +206,10 @@ inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = fa
206 206
         else
207 207
       #endif
208 208
       {
209
-        if (GET_PINMODE(pin)) {
209
+        if (pwm_status(pin)) {
210
+          // do nothing
211
+        }
212
+        else if (GET_PINMODE(pin)) {
210 213
           SERIAL_ECHO_SP(MAX_NAME_LENGTH - 16);
211 214
           print_input_or_output(true);
212 215
           SERIAL_ECHO(digitalRead_mod(pin));
@@ -224,7 +227,10 @@ inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = fa
224 227
           SERIAL_ECHO(digitalRead_mod(pin));
225 228
         }
226 229
         //if (!pwm_status(pin)) SERIAL_CHAR(' ');    // add padding if it's not a PWM pin
227
-        if (extended) pwm_details(pin);  // report PWM capabilities only if doing an extended report
230
+        if (extended) {
231
+          SERIAL_ECHO_SP(MAX_NAME_LENGTH - 16);
232
+          pwm_details(pin);  // report PWM capabilities only if doing an extended report
233
+        }
228 234
       }
229 235
     }
230 236
     SERIAL_EOL();

+ 25
- 24
buildroot/share/atom/auto_build.py View File

@@ -947,7 +947,7 @@ class output_window(Text):
947 947
         Text.__init__(self, self.frame, borderwidth=3, relief="sunken")
948 948
         self.config(tabs=(400,))  # configure Text widget tab stops
949 949
         self.config(background = 'black', foreground = 'white', font= ("consolas", 12), wrap = 'word', undo = 'True')
950
-#        self.config(background = 'black', foreground = 'white', font= ("consolas", 12), wrap = 'none', undo = 'True')
950
+        #self.config(background = 'black', foreground = 'white', font= ("consolas", 12), wrap = 'none', undo = 'True')
951 951
         self.config(height  = 24, width = 100)
952 952
         self.config(insertbackground = 'pale green')  # keyboard insertion point
953 953
         self.pack(side='left', fill='both', expand=True)
@@ -970,24 +970,24 @@ class output_window(Text):
970 970
         self.config(yscrollcommand=scrb.set)
971 971
         scrb.pack(side='right', fill='y')
972 972
 
973
-#        self.scrb_Y = tk.Scrollbar(self.frame, orient='vertical', command=self.yview)
974
-#        self.scrb_Y.config(yscrollcommand=self.scrb_Y.set)
975
-#        self.scrb_Y.pack(side='right', fill='y')
976
-#
977
-#        self.scrb_X = tk.Scrollbar(self.frame, orient='horizontal', command=self.xview)
978
-#        self.scrb_X.config(xscrollcommand=self.scrb_X.set)
979
-#        self.scrb_X.pack(side='bottom', fill='x')
973
+        #self.scrb_Y = tk.Scrollbar(self.frame, orient='vertical', command=self.yview)
974
+        #self.scrb_Y.config(yscrollcommand=self.scrb_Y.set)
975
+        #self.scrb_Y.pack(side='right', fill='y')
980 976
 
981
-#        scrb_X = tk.Scrollbar(self, orient=tk.HORIZONTAL, command=self.xview)  # tk.HORIZONTAL now have a horizsontal scroll bar BUT... shrinks it to a postage stamp and hides far right behind the vertical scroll bar
982
-#        self.config(xscrollcommand=scrb_X.set)
983
-#        scrb_X.pack(side='bottom', fill='x')
984
-#
985
-#        scrb= tk.Scrollbar(self, orient='vertical', command=self.yview)
986
-#        self.config(yscrollcommand=scrb.set)
987
-#        scrb.pack(side='right', fill='y')
977
+        #self.scrb_X = tk.Scrollbar(self.frame, orient='horizontal', command=self.xview)
978
+        #self.scrb_X.config(xscrollcommand=self.scrb_X.set)
979
+        #self.scrb_X.pack(side='bottom', fill='x')
980
+
981
+        #scrb_X = tk.Scrollbar(self, orient=tk.HORIZONTAL, command=self.xview)  # tk.HORIZONTAL now have a horizsontal scroll bar BUT... shrinks it to a postage stamp and hides far right behind the vertical scroll bar
982
+        #self.config(xscrollcommand=scrb_X.set)
983
+        #scrb_X.pack(side='bottom', fill='x')
988 984
 
989
-#        self.config(height  = 240, width = 1000)            # didn't get the size baCK TO NORMAL
990
-#        self.pack(side='left', fill='both', expand=True)    # didn't get the size baCK TO NORMAL
985
+        #scrb= tk.Scrollbar(self, orient='vertical', command=self.yview)
986
+        #self.config(yscrollcommand=scrb.set)
987
+        #scrb.pack(side='right', fill='y')
988
+
989
+        #self.config(height  = 240, width = 1000)            # didn't get the size baCK TO NORMAL
990
+        #self.pack(side='left', fill='both', expand=True)    # didn't get the size baCK TO NORMAL
991 991
 
992 992
 
993 993
         # pop-up menu
@@ -1003,7 +1003,7 @@ class output_window(Text):
1003 1003
         self.popup.add_separator()
1004 1004
         self.popup.add_command(label='Save As', command=self._file_save_as)
1005 1005
         self.popup.add_separator()
1006
- #       self.popup.add_command(label='Repeat Build(CTL-shift-r)', command=self._rebuild)
1006
+        #self.popup.add_command(label='Repeat Build(CTL-shift-r)', command=self._rebuild)
1007 1007
         self.popup.add_command(label='Repeat Build', command=self._rebuild)
1008 1008
         self.popup.add_separator()
1009 1009
         self.popup.add_command(label='Scroll Errors (CTL-shift-e)', command=self._scroll_errors)
@@ -1199,12 +1199,13 @@ class output_window(Text):
1199 1199
 
1200 1200
 
1201 1201
     def _clear_all(self):
1202
-        '''erases all text'''
1203
-
1204
-        isok = askokcancel('Clear All', 'Erase all text?', frame=self,
1205
-                           default='ok')
1206
-        if isok:
1207
-            self.delete('1.0', 'end')
1202
+        #'''erases all text'''
1203
+        #
1204
+        #isok = askokcancel('Clear All', 'Erase all text?', frame=self,
1205
+        #                   default='ok')
1206
+        #if isok:
1207
+        #    self.delete('1.0', 'end')
1208
+        self.delete('1.0', 'end')
1208 1209
 
1209 1210
 
1210 1211
 # end - output_window

Loading…
Cancel
Save