Browse Source

Use fastio for literal pins

Scott Lahteine 8 years ago
parent
commit
cb48292338
5 changed files with 24 additions and 29 deletions
  1. 4
    6
      Marlin/Marlin_main.cpp
  2. 5
    5
      Marlin/Sd2Card.cpp
  3. 12
    12
      Marlin/stepper.cpp
  4. 1
    2
      Marlin/stepper_dac.cpp
  5. 2
    4
      Marlin/ultralcd_impl_DOGM.h

+ 4
- 6
Marlin/Marlin_main.cpp View File

782
 #if ENABLED(FILAMENT_RUNOUT_SENSOR)
782
 #if ENABLED(FILAMENT_RUNOUT_SENSOR)
783
 
783
 
784
   void setup_filrunoutpin() {
784
   void setup_filrunoutpin() {
785
-    pinMode(FIL_RUNOUT_PIN, INPUT);
785
+    SET_INPUT(FIL_RUNOUT_PIN);
786
     #if ENABLED(ENDSTOPPULLUP_FIL_RUNOUT)
786
     #if ENABLED(ENDSTOPPULLUP_FIL_RUNOUT)
787
       WRITE(FIL_RUNOUT_PIN, HIGH);
787
       WRITE(FIL_RUNOUT_PIN, HIGH);
788
     #endif
788
     #endif
860
  */
860
  */
861
 #if HAS_STEPPER_RESET
861
 #if HAS_STEPPER_RESET
862
   void disableStepperDrivers() {
862
   void disableStepperDrivers() {
863
-    pinMode(STEPPER_RESET_PIN, OUTPUT);
864
-    digitalWrite(STEPPER_RESET_PIN, LOW);  // drive it down to hold in reset motor driver chips
863
+    OUT_WRITE(STEPPER_RESET_PIN, LOW);  // drive it down to hold in reset motor driver chips
865
   }
864
   }
866
-  void enableStepperDrivers() { pinMode(STEPPER_RESET_PIN, INPUT); }  // set to input, which allows it to be pulled high by pullups
865
+  void enableStepperDrivers() { SET_INPUT(STEPPER_RESET_PIN); }  // set to input, which allows it to be pulled high by pullups
867
 #endif
866
 #endif
868
 
867
 
869
 #if ENABLED(EXPERIMENTAL_I2CBUS) && I2C_SLAVE_ADDRESS > 0
868
 #if ENABLED(EXPERIMENTAL_I2CBUS) && I2C_SLAVE_ADDRESS > 0
9194
   #endif
9193
   #endif
9195
 
9194
 
9196
   #if ENABLED(Z_PROBE_SLED) && PIN_EXISTS(SLED)
9195
   #if ENABLED(Z_PROBE_SLED) && PIN_EXISTS(SLED)
9197
-    pinMode(SLED_PIN, OUTPUT);
9198
-    digitalWrite(SLED_PIN, LOW); // turn it off
9196
+    OUT_WRITE(SLED_PIN, LOW); // turn it off
9199
   #endif // Z_PROBE_SLED
9197
   #endif // Z_PROBE_SLED
9200
 
9198
 
9201
   setup_homepin();
9199
   setup_homepin();

+ 5
- 5
Marlin/Sd2Card.cpp View File

302
   // set pin modes
302
   // set pin modes
303
   pinMode(chipSelectPin_, OUTPUT);
303
   pinMode(chipSelectPin_, OUTPUT);
304
   chipSelectHigh();
304
   chipSelectHigh();
305
-  pinMode(SPI_MISO_PIN, INPUT);
306
-  pinMode(SPI_MOSI_PIN, OUTPUT);
307
-  pinMode(SPI_SCK_PIN, OUTPUT);
305
+  SET_INPUT(SPI_MISO_PIN);
306
+  SET_OUTPUT(SPI_MOSI_PIN);
307
+  SET_OUTPUT(SPI_SCK_PIN);
308
 
308
 
309
   #if DISABLED(SOFTWARE_SPI)
309
   #if DISABLED(SOFTWARE_SPI)
310
     // SS must be in output mode even it is not chip select
310
     // SS must be in output mode even it is not chip select
311
-    pinMode(SS_PIN, OUTPUT);
311
+    SET_OUTPUT(SS_PIN);
312
     // set SS high - may be chip select for another SPI device
312
     // set SS high - may be chip select for another SPI device
313
     #if SET_SPI_SS_HIGH
313
     #if SET_SPI_SS_HIGH
314
-      digitalWrite(SS_PIN, HIGH);
314
+      WRITE(SS_PIN, HIGH);
315
     #endif  // SET_SPI_SS_HIGH
315
     #endif  // SET_SPI_SS_HIGH
316
     // set SCK rate for initialization commands
316
     // set SCK rate for initialization commands
317
     spiRate_ = SPI_SD_INIT_RATE;
317
     spiRate_ = SPI_SD_INIT_RATE;

+ 12
- 12
Marlin/stepper.cpp View File

1155
 
1155
 
1156
   // From Arduino DigitalPotControl example
1156
   // From Arduino DigitalPotControl example
1157
   void Stepper::digitalPotWrite(int address, int value) {
1157
   void Stepper::digitalPotWrite(int address, int value) {
1158
-    digitalWrite(DIGIPOTSS_PIN, LOW); // take the SS pin low to select the chip
1158
+    WRITE(DIGIPOTSS_PIN, LOW); // take the SS pin low to select the chip
1159
     SPI.transfer(address); //  send in the address and value via SPI:
1159
     SPI.transfer(address); //  send in the address and value via SPI:
1160
     SPI.transfer(value);
1160
     SPI.transfer(value);
1161
-    digitalWrite(DIGIPOTSS_PIN, HIGH); // take the SS pin high to de-select the chip:
1161
+    WRITE(DIGIPOTSS_PIN, HIGH); // take the SS pin high to de-select the chip:
1162
     //delay(10);
1162
     //delay(10);
1163
   }
1163
   }
1164
 
1164
 
1275
 void Stepper::microstep_readings() {
1275
 void Stepper::microstep_readings() {
1276
   SERIAL_PROTOCOLLNPGM("MS1,MS2 Pins");
1276
   SERIAL_PROTOCOLLNPGM("MS1,MS2 Pins");
1277
   SERIAL_PROTOCOLPGM("X: ");
1277
   SERIAL_PROTOCOLPGM("X: ");
1278
-  SERIAL_PROTOCOL(digitalRead(X_MS1_PIN));
1279
-  SERIAL_PROTOCOLLN(digitalRead(X_MS2_PIN));
1278
+  SERIAL_PROTOCOL(READ(X_MS1_PIN));
1279
+  SERIAL_PROTOCOLLN(READ(X_MS2_PIN));
1280
   SERIAL_PROTOCOLPGM("Y: ");
1280
   SERIAL_PROTOCOLPGM("Y: ");
1281
-  SERIAL_PROTOCOL(digitalRead(Y_MS1_PIN));
1282
-  SERIAL_PROTOCOLLN(digitalRead(Y_MS2_PIN));
1281
+  SERIAL_PROTOCOL(READ(Y_MS1_PIN));
1282
+  SERIAL_PROTOCOLLN(READ(Y_MS2_PIN));
1283
   SERIAL_PROTOCOLPGM("Z: ");
1283
   SERIAL_PROTOCOLPGM("Z: ");
1284
-  SERIAL_PROTOCOL(digitalRead(Z_MS1_PIN));
1285
-  SERIAL_PROTOCOLLN(digitalRead(Z_MS2_PIN));
1284
+  SERIAL_PROTOCOL(READ(Z_MS1_PIN));
1285
+  SERIAL_PROTOCOLLN(READ(Z_MS2_PIN));
1286
   SERIAL_PROTOCOLPGM("E0: ");
1286
   SERIAL_PROTOCOLPGM("E0: ");
1287
-  SERIAL_PROTOCOL(digitalRead(E0_MS1_PIN));
1288
-  SERIAL_PROTOCOLLN(digitalRead(E0_MS2_PIN));
1287
+  SERIAL_PROTOCOL(READ(E0_MS1_PIN));
1288
+  SERIAL_PROTOCOLLN(READ(E0_MS2_PIN));
1289
   #if HAS_MICROSTEPS_E1
1289
   #if HAS_MICROSTEPS_E1
1290
     SERIAL_PROTOCOLPGM("E1: ");
1290
     SERIAL_PROTOCOLPGM("E1: ");
1291
-    SERIAL_PROTOCOL(digitalRead(E1_MS1_PIN));
1292
-    SERIAL_PROTOCOLLN(digitalRead(E1_MS2_PIN));
1291
+    SERIAL_PROTOCOL(READ(E1_MS1_PIN));
1292
+    SERIAL_PROTOCOLLN(READ(E1_MS2_PIN));
1293
   #endif
1293
   #endif
1294
 }
1294
 }
1295
 
1295
 

+ 1
- 2
Marlin/stepper_dac.cpp View File

52
 
52
 
53
   int dac_init() {
53
   int dac_init() {
54
     #if PIN_EXISTS(DAC_DISABLE)
54
     #if PIN_EXISTS(DAC_DISABLE)
55
-      pinMode(DAC_DISABLE_PIN, OUTPUT);
56
-      digitalWrite(DAC_DISABLE_PIN, LOW);  // set pin low to enable DAC
55
+      OUT_WRITE(DAC_DISABLE_PIN, LOW);  // set pin low to enable DAC
57
     #endif
56
     #endif
58
 
57
 
59
     mcp4728_init();
58
     mcp4728_init();

+ 2
- 4
Marlin/ultralcd_impl_DOGM.h View File

221
 static void lcd_implementation_init() {
221
 static void lcd_implementation_init() {
222
 
222
 
223
   #if PIN_EXISTS(LCD_BACKLIGHT) // Enable LCD backlight
223
   #if PIN_EXISTS(LCD_BACKLIGHT) // Enable LCD backlight
224
-    pinMode(LCD_BACKLIGHT_PIN, OUTPUT);
225
-    digitalWrite(LCD_BACKLIGHT_PIN, HIGH);
224
+    OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH);
226
   #endif
225
   #endif
227
 
226
 
228
   #if PIN_EXISTS(LCD_RESET)
227
   #if PIN_EXISTS(LCD_RESET)
229
-    pinMode(LCD_RESET_PIN, OUTPUT);
230
-    digitalWrite(LCD_RESET_PIN, HIGH);
228
+    OUT_WRITE(LCD_RESET_PIN, HIGH);
231
   #endif
229
   #endif
232
 
230
 
233
   #if DISABLED(MINIPANEL) // setContrast not working for Mini Panel
231
   #if DISABLED(MINIPANEL) // setContrast not working for Mini Panel

Loading…
Cancel
Save