Browse Source

pinsDebug for 644/1284 & USB646/1286 families

added conditional compilation for PWMs 1C & 3C

add Teensyduino compatibility

==========================================

changes per review - minor formatting changes

1) remove non-printable character at the end of line 687

2) split a really long comment into two lines

3) got rid of some trailing spaces

============================================

Made pinsDebug_Teensyduino.h the same between this PR and PR 5668 which
is for a re-written pinsDebug.h file.

The changes were:
1) added copyright @ GNU license header
2) a blank line crept in.
Bob-the-Kuhn 7 years ago
parent
commit
ae706233a8
2 changed files with 137 additions and 16 deletions
  1. 27
    16
      Marlin/pinsDebug.h
  2. 110
    0
      Marlin/pinsDebug_Teensyduino.h

+ 27
- 16
Marlin/pinsDebug.h View File

@@ -22,6 +22,10 @@
22 22
 
23 23
 bool endstop_monitor_flag = false;
24 24
 
25
+#if !defined(TIMER1B)    // working with Teensyduino extension so need to re-define some things
26
+  #include "pinsDebug_Teensyduino.h"
27
+#endif
28
+
25 29
 #define  NAME_FORMAT "%-28s"   // one place to specify the format of all the sources of names
26 30
                                // "-" left justify, "28" minimum width of name, pad with blanks
27 31
 
@@ -683,7 +687,9 @@ static bool pwm_status(uint8_t pin) {
683 687
     #if defined(TCCR1A) && defined(COM1A1)
684 688
       PWM_CASE(1,A);
685 689
       PWM_CASE(1,B);
686
-      PWM_CASE(1,C);
690
+      #if defined(COM1C1) && defined(TIMER1C)
691
+        PWM_CASE(1,C);
692
+      #endif
687 693
     #endif
688 694
 
689 695
     #if defined(TCCR2A) && defined(COM2A1)
@@ -694,7 +700,9 @@ static bool pwm_status(uint8_t pin) {
694 700
     #if defined(TCCR3A) && defined(COM3A1)
695 701
       PWM_CASE(3,A);
696 702
       PWM_CASE(3,B);
697
-      PWM_CASE(3,C);
703
+      #if defined(COM3C1)
704
+        PWM_CASE(3,C);
705
+      #endif
698 706
     #endif
699 707
 
700 708
     #ifdef TCCR4A
@@ -778,13 +786,15 @@ static void pwm_details(uint8_t pin) {
778 786
         else if (TIMSK1 & (_BV(TOIE1) | _BV(ICIE1))) err_prob_interrupt();
779 787
         else can_be_used();
780 788
         break;
781
-      case TIMER1C:
782
-        TIMER_PREFIX(1,C,4);
783
-        if (WGM_TEST2) err_is_counter();
784
-        else if (TEST(TIMSK1, OCIE1C)) err_is_interrupt();
785
-        else if (TIMSK1 & (_BV(TOIE1) | _BV(ICIE1))) err_prob_interrupt();
786
-        else can_be_used();
787
-        break;
789
+      #if defined(COM1C1) && defined(TIMER1C)
790
+        case TIMER1C:
791
+          TIMER_PREFIX(1,C,4);
792
+          if (WGM_TEST2) err_is_counter();
793
+          else if (TEST(TIMSK1, OCIE1C)) err_is_interrupt();
794
+          else if (TIMSK1 & (_BV(TOIE1) | _BV(ICIE1))) err_prob_interrupt();
795
+          else can_be_used();
796
+          break;
797
+      #endif
788 798
     #endif
789 799
 
790 800
     #if defined(TCCR2A) && defined(COM2A1)
@@ -819,13 +829,15 @@ static void pwm_details(uint8_t pin) {
819 829
         else if (TIMSK3 & (_BV(TOIE3) | _BV(ICIE3))) err_prob_interrupt();
820 830
         else can_be_used();
821 831
         break;
832
+      #if defined(COM3C1)
822 833
       case TIMER3C:
823
-        TIMER_PREFIX(3,C,3);
824
-        if (WGM_TEST2) err_is_counter();
825
-        else if (TEST(TIMSK3, OCIE3C)) err_is_interrupt();
826
-        else if (TIMSK3 & (_BV(TOIE3) | _BV(ICIE3))) err_prob_interrupt();
827
-        else can_be_used();
828
-        break;
834
+          TIMER_PREFIX(3,C,3);
835
+          if (WGM_TEST2) err_is_counter();
836
+          else if (TEST(TIMSK3, OCIE3C)) err_is_interrupt();
837
+          else if (TIMSK3 & (_BV(TOIE3) | _BV(ICIE3))) err_prob_interrupt();
838
+          else can_be_used();
839
+          break;
840
+      #endif
829 841
     #endif
830 842
 
831 843
     #ifdef TCCR4A
@@ -942,4 +954,3 @@ inline void report_pin_state_extended(int8_t pin, bool ignore) {
942 954
   pwm_details(pin);
943 955
   SERIAL_EOL;
944 956
 }
945
-

+ 110
- 0
Marlin/pinsDebug_Teensyduino.h View File

@@ -0,0 +1,110 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2017 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
+//  some of the pin mapping functions of the Teensduino extension to the Arduino IDE
25
+//  do not function the same as the other Arduino extensions
26
+//
27
+
28
+
29
+#define TEENSYDUINO_IDE
30
+
31
+//digitalPinToTimer(pin) function works like Arduino but Timers are not defined
32
+#define TIMER0B 1
33
+#define TIMER1A 7
34
+#define TIMER1B 8
35
+#define TIMER1C 9
36
+#define TIMER2A 6
37
+#define TIMER2B 2
38
+#define TIMER3A 5
39
+#define TIMER3B 4
40
+#define TIMER3C 3
41
+
42
+// digitalPinToPort function just returns the pin number so need to create our own
43
+#define PA 1
44
+#define PB 2
45
+#define PC 3
46
+#define PD 4
47
+#define PE 5
48
+#define PF 6
49
+
50
+#undef digitalPinToPort
51
+
52
+const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
53
+  PD, // 0  - PD0 - INT0 - PWM
54
+  PD, // 1  - PD1 - INT1 - PWM
55
+  PD, // 2  - PD2 - INT2 - RX
56
+  PD, // 3  - PD3 - INT3 - TX
57
+  PD, // 4  - PD4
58
+  PD, // 5  - PD5
59
+  PD, // 6  - PD6
60
+  PD, // 7  - PD7
61
+  PE, // 8  - PE0
62
+  PE, // 9  - PE1
63
+  PC, // 10 - PC0
64
+  PC, // 11 - PC1
65
+  PC, // 12 - PC2
66
+  PC, // 13 - PC3
67
+  PC, // 14 - PC4 - PWM
68
+  PC, // 15 - PC5 - PWM
69
+  PC, // 16 - PC6 - PWM
70
+  PC, // 17 - PC7
71
+  PE, // 18 - PE6 - INT6
72
+  PE, // 19 - PE7 - INT7
73
+  PB, // 20 - PB0
74
+  PB, // 21 - PB1
75
+  PB, // 22 - PB2
76
+  PB, // 23 - PB3
77
+  PB, // 24 - PB4 - PWM
78
+  PB, // 25 - PB5 - PWM
79
+  PB, // 26 - PB6 - PWM
80
+  PB, // 27 - PB7 - PWM
81
+  PA, // 28 - PA0
82
+  PA, // 29 - PA1
83
+  PA, // 30 - PA2
84
+  PA, // 31 - PA3
85
+  PA, // 32 - PA4
86
+  PA, // 33 - PA5
87
+  PA, // 34 - PA6
88
+  PA, // 35 - PA7
89
+  PE, // 36 - PE4 - INT4
90
+  PE, // 37 - PE5 - INT5
91
+  PF, // 38 - PF0 - A0
92
+  PF, // 39 - PF1 - A1
93
+  PF, // 40 - PF2 - A2
94
+  PF, // 41 - PF3 - A3
95
+  PF, // 42 - PF4 - A4
96
+  PF, // 43 - PF5 - A5
97
+  PF, // 44 - PF6 - A6
98
+  PF, // 45 - PF7 - A7
99
+  PE, // 46 - PE2 (not defined in teensyduino)
100
+  PE, // 47 - PE3 (not defined in teensyduino)
101
+};
102
+
103
+#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
104
+
105
+// digitalPinToBitMask(pin) is OK
106
+
107
+#define digitalRead_mod(p)  digitalRead(p)   // Teensyduino's version of digitalRead doesn't
108
+                                             // disable the PWMs so we can use it as is
109
+
110
+// portModeRegister(pin) is OK

Loading…
Cancel
Save