Browse Source

Use SET_INPUT_PULLUP where appropriate

Scott Lahteine 7 years ago
parent
commit
2defb1d748
4 changed files with 37 additions and 34 deletions
  1. 5
    6
      Marlin/Marlin_main.cpp
  2. 27
    18
      Marlin/endstops.cpp
  3. 1
    2
      Marlin/temperature.cpp
  4. 4
    8
      Marlin/ultralcd.cpp

+ 5
- 6
Marlin/Marlin_main.cpp View File

@@ -858,17 +858,17 @@ bool enqueue_and_echo_command(const char* cmd, bool say_ok/*=false*/) {
858 858
 
859 859
 void setup_killpin() {
860 860
   #if HAS_KILL
861
-    SET_INPUT(KILL_PIN);
862
-    WRITE(KILL_PIN, HIGH);
861
+    SET_INPUT_PULLUP(KILL_PIN);
863 862
   #endif
864 863
 }
865 864
 
866 865
 #if ENABLED(FILAMENT_RUNOUT_SENSOR)
867 866
 
868 867
   void setup_filrunoutpin() {
869
-    SET_INPUT(FIL_RUNOUT_PIN);
870 868
     #if ENABLED(ENDSTOPPULLUP_FIL_RUNOUT)
871
-      WRITE(FIL_RUNOUT_PIN, HIGH);
869
+      SET_INPUT_PULLUP(FIL_RUNOUT_PIN);
870
+    #else
871
+      SET_INPUT(FIL_RUNOUT_PIN);
872 872
     #endif
873 873
   }
874 874
 
@@ -877,8 +877,7 @@ void setup_killpin() {
877 877
 // Set home pin
878 878
 void setup_homepin(void) {
879 879
   #if HAS_HOME
880
-    SET_INPUT(HOME_PIN);
881
-    WRITE(HOME_PIN, HIGH);
880
+    SET_INPUT_PULLUP(HOME_PIN);
882 881
   #endif
883 882
 }
884 883
 

+ 27
- 18
Marlin/endstops.cpp View File

@@ -67,65 +67,74 @@ volatile char Endstops::endstop_hit_bits; // use X_MIN, Y_MIN, Z_MIN and Z_MIN_P
67 67
 void Endstops::init() {
68 68
 
69 69
   #if HAS_X_MIN
70
-    SET_INPUT(X_MIN_PIN);
71 70
     #if ENABLED(ENDSTOPPULLUP_XMIN)
72
-      WRITE(X_MIN_PIN,HIGH);
71
+      SET_INPUT_PULLUP(X_MIN_PIN);
72
+    #else
73
+      SET_INPUT(X_MIN_PIN);
73 74
     #endif
74 75
   #endif
75 76
 
76 77
   #if HAS_Y_MIN
77
-    SET_INPUT(Y_MIN_PIN);
78 78
     #if ENABLED(ENDSTOPPULLUP_YMIN)
79
-      WRITE(Y_MIN_PIN,HIGH);
79
+      SET_INPUT_PULLUP(Y_MIN_PIN);
80
+    #else
81
+      SET_INPUT(Y_MIN_PIN);
80 82
     #endif
81 83
   #endif
82 84
 
83 85
   #if HAS_Z_MIN
84
-    SET_INPUT(Z_MIN_PIN);
85 86
     #if ENABLED(ENDSTOPPULLUP_ZMIN)
86
-      WRITE(Z_MIN_PIN,HIGH);
87
+      SET_INPUT_PULLUP(Z_MIN_PIN);
88
+    #else
89
+      SET_INPUT(Z_MIN_PIN);
87 90
     #endif
88 91
   #endif
89 92
 
90 93
   #if HAS_Z2_MIN
91
-    SET_INPUT(Z2_MIN_PIN);
92 94
     #if ENABLED(ENDSTOPPULLUP_ZMIN)
93
-      WRITE(Z2_MIN_PIN,HIGH);
95
+      SET_INPUT_PULLUP(Z2_MIN_PIN);
96
+    #else
97
+      SET_INPUT(Z2_MIN_PIN);
94 98
     #endif
95 99
   #endif
96 100
 
97 101
   #if HAS_X_MAX
98
-    SET_INPUT(X_MAX_PIN);
99 102
     #if ENABLED(ENDSTOPPULLUP_XMAX)
100
-      WRITE(X_MAX_PIN,HIGH);
103
+      SET_INPUT_PULLUP(X_MAX_PIN);
104
+    #else
105
+      SET_INPUT(X_MAX_PIN);
101 106
     #endif
102 107
   #endif
103 108
 
104 109
   #if HAS_Y_MAX
105
-    SET_INPUT(Y_MAX_PIN);
106 110
     #if ENABLED(ENDSTOPPULLUP_YMAX)
107
-      WRITE(Y_MAX_PIN,HIGH);
111
+      SET_INPUT_PULLUP(Y_MAX_PIN);
112
+    #else
113
+      SET_INPUT(Y_MAX_PIN);
108 114
     #endif
109 115
   #endif
110 116
 
111 117
   #if HAS_Z_MAX
112
-    SET_INPUT(Z_MAX_PIN);
113 118
     #if ENABLED(ENDSTOPPULLUP_ZMAX)
114
-      WRITE(Z_MAX_PIN,HIGH);
119
+      SET_INPUT_PULLUP(Z_MAX_PIN);
120
+    #else
121
+      SET_INPUT(Z_MAX_PIN);
115 122
     #endif
116 123
   #endif
117 124
 
118 125
   #if HAS_Z2_MAX
119
-    SET_INPUT(Z2_MAX_PIN);
120 126
     #if ENABLED(ENDSTOPPULLUP_ZMAX)
121
-      WRITE(Z2_MAX_PIN,HIGH);
127
+      SET_INPUT_PULLUP(Z2_MAX_PIN);
128
+    #else
129
+      SET_INPUT(Z2_MAX_PIN);
122 130
     #endif
123 131
   #endif
124 132
 
125 133
   #if ENABLED(Z_MIN_PROBE_ENDSTOP)
126
-    SET_INPUT(Z_MIN_PROBE_PIN);
127 134
     #if ENABLED(ENDSTOPPULLUP_ZMIN_PROBE)
128
-      WRITE(Z_MIN_PROBE_PIN,HIGH);
135
+      SET_INPUT_PULLUP(Z_MIN_PROBE_PIN);
136
+    #else
137
+      SET_INPUT(Z_MIN_PROBE_PIN);
129 138
     #endif
130 139
   #endif
131 140
 

+ 1
- 2
Marlin/temperature.cpp View File

@@ -998,8 +998,7 @@ void Temperature::init() {
998 998
 
999 999
     OUT_WRITE(SCK_PIN, LOW);
1000 1000
     OUT_WRITE(MOSI_PIN, HIGH);
1001
-    SET_INPUT(MISO_PIN);
1002
-    WRITE(MISO_PIN, HIGH);
1001
+    SET_INPUT_PULLUP(MISO_PIN);
1003 1002
     OUT_WRITE(SS_PIN, HIGH);
1004 1003
 
1005 1004
     OUT_WRITE(MAX6675_SS, HIGH);

+ 4
- 8
Marlin/ultralcd.cpp View File

@@ -2973,18 +2973,15 @@ void lcd_init() {
2973 2973
 
2974 2974
   #if ENABLED(NEWPANEL)
2975 2975
     #if BUTTON_EXISTS(EN1)
2976
-      SET_INPUT(BTN_EN1);
2977
-      WRITE(BTN_EN1, HIGH);
2976
+      SET_INPUT_PULLUP(BTN_EN1);
2978 2977
     #endif
2979 2978
 
2980 2979
     #if BUTTON_EXISTS(EN2)
2981
-      SET_INPUT(BTN_EN2);
2982
-      WRITE(BTN_EN2, HIGH);
2980
+      SET_INPUT_PULLUP(BTN_EN2);
2983 2981
     #endif
2984 2982
 
2985 2983
     #if BUTTON_EXISTS(ENC)
2986
-      SET_INPUT(BTN_ENC);
2987
-      WRITE(BTN_ENC, HIGH);
2984
+      SET_INPUT_PULLUP(BTN_ENC);
2988 2985
     #endif
2989 2986
 
2990 2987
     #if ENABLED(REPRAPWORLD_KEYPAD)
@@ -3021,8 +3018,7 @@ void lcd_init() {
3021 3018
   #endif // !NEWPANEL
3022 3019
 
3023 3020
   #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
3024
-    SET_INPUT(SD_DETECT_PIN);
3025
-    WRITE(SD_DETECT_PIN, HIGH);
3021
+    SET_INPUT_PULLUP(SD_DETECT_PIN);
3026 3022
     lcd_sd_status = 2; // UNKNOWN
3027 3023
   #endif
3028 3024
 

Loading…
Cancel
Save