From 5d0570cea05711754f89b97701c4b9021fba8543 Mon Sep 17 00:00:00 2001
From: Scott Lahteine <sourcetree@thinkyhead.com>
Date: Sat, 19 Mar 2016 18:44:08 -0700
Subject: [PATCH] Make digitalPotWrite depend on HAS_DIGIPOTSS

---
 Marlin/Marlin_main.cpp | 10 ++++++----
 Marlin/stepper.cpp     | 15 +++++++--------
 Marlin/stepper.h       |  4 +++-
 3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp
index 143f483f53..9ba8e9a368 100644
--- a/Marlin/Marlin_main.cpp
+++ b/Marlin/Marlin_main.cpp
@@ -5660,10 +5660,12 @@ inline void gcode_M907() {
    * M908: Control digital trimpot directly (M908 P<pin> S<current>)
    */
   inline void gcode_M908() {
-    digitalPotWrite(
-      code_seen('P') ? code_value() : 0,
-      code_seen('S') ? code_value() : 0
-    );
+    #if HAS_DIGIPOTSS
+      digitalPotWrite(
+        code_seen('P') ? code_value() : 0,
+        code_seen('S') ? code_value() : 0
+      );
+    #endif
     #ifdef DAC_STEPPER_CURRENT
       dac_current_raw(
         code_seen('P') ? code_value_long() : -1,
diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp
index 5e0ca1e81b..a88d7c80cb 100644
--- a/Marlin/stepper.cpp
+++ b/Marlin/stepper.cpp
@@ -1174,19 +1174,18 @@ void quickStop() {
 
 #endif //BABYSTEPPING
 
-// From Arduino DigitalPotControl example
-void digitalPotWrite(int address, int value) {
-  #if HAS_DIGIPOTSS
+#if HAS_DIGIPOTSS
+
+  // From Arduino DigitalPotControl example
+  void digitalPotWrite(int address, int value) {
     digitalWrite(DIGIPOTSS_PIN, LOW); // take the SS pin low to select the chip
     SPI.transfer(address); //  send in the address and value via SPI:
     SPI.transfer(value);
     digitalWrite(DIGIPOTSS_PIN, HIGH); // take the SS pin high to de-select the chip:
     //delay(10);
-  #else
-    UNUSED(address);
-    UNUSED(value);
-  #endif
-}
+  }
+
+#endif //HAS_DIGIPOTSS
 
 // Initialize Digipot Motor Current
 void digipot_init() {
diff --git a/Marlin/stepper.h b/Marlin/stepper.h
index 1dfe79bfcb..a582ae14cc 100644
--- a/Marlin/stepper.h
+++ b/Marlin/stepper.h
@@ -62,7 +62,9 @@ extern block_t* current_block;  // A pointer to the block currently being traced
 
 void quickStop();
 
-void digitalPotWrite(int address, int value);
+#if HAS_DIGIPOTSS
+  void digitalPotWrite(int address, int value);
+#endif
 void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2);
 void microstep_mode(uint8_t driver, uint8_t stepping);
 void digipot_init();