diff --git a/Marlin/src/HAL/HAL_LPC1768/DebugMonitor_LPC1768.cpp b/Marlin/src/HAL/HAL_LPC1768/DebugMonitor_LPC1768.cpp index cded8a16a..6798d60cc 100644 --- a/Marlin/src/HAL/HAL_LPC1768/DebugMonitor_LPC1768.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/DebugMonitor_LPC1768.cpp @@ -315,4 +315,4 @@ __attribute__((naked)) void RSTC_Handler(void) { ); } } -#endif // ARDUINO_ARCH_SAM +#endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL.h b/Marlin/src/HAL/HAL_LPC1768/HAL.h index cb757bb8c..5eda2ac72 100644 --- a/Marlin/src/HAL/HAL_LPC1768/HAL.h +++ b/Marlin/src/HAL/HAL_LPC1768/HAL.h @@ -151,6 +151,8 @@ using FilteredADC = LPC176x::ADC; // Parse a G-code word into a pin index int16_t PARSED_PIN_INDEX(const char code, const int16_t dval); +// P0.6 thru P0.9 are for the onboard SD card +#define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09 #define HAL_IDLETASK 1 void HAL_idletask(void); diff --git a/Marlin/src/HAL/HAL_LPC1768/servo_private.h b/Marlin/src/HAL/HAL_LPC1768/MarlinServo.h similarity index 85% rename from Marlin/src/HAL/HAL_LPC1768/servo_private.h rename to Marlin/src/HAL/HAL_LPC1768/MarlinServo.h index 97c89bd47..6a6fae1fb 100644 --- a/Marlin/src/HAL/HAL_LPC1768/servo_private.h +++ b/Marlin/src/HAL/HAL_LPC1768/MarlinServo.h @@ -50,25 +50,24 @@ #ifndef SERVO_PRIVATE_H #define SERVO_PRIVATE_H -#include +#include class MarlinServo: public Servo { + public: void move(const int value) { constexpr uint16_t servo_delay[] = SERVO_DELAY; static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long."); - if (this->attach(0) >= 0) { // notice the pin number is zero here - this->write(value); - - safe_delay(servo_delay[this->servoIndex]); + if (this->attach(servo_info[this->servoIndex].Pin.nbr) >= 0) { // try to reattach + this->write(value); + safe_delay(servo_delay[this->servoIndex]); // delay to allow servo to reach position #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) this->detach(); - LPC1768_PWM_detach_pin(servo_info[this->servoIndex].Pin.nbr); // shut down the PWM signal - LPC1768_PWM_attach_pin(servo_info[this->servoIndex].Pin.nbr, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH, this->servoIndex); // make sure no one else steals the slot #endif } + } -} +}; #define HAL_SERVO_LIB MarlinServo diff --git a/Marlin/src/HAL/HAL_LPC1768/main.cpp b/Marlin/src/HAL/HAL_LPC1768/main.cpp index 0a0df2697..f1f9ed405 100644 --- a/Marlin/src/HAL/HAL_LPC1768/main.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/main.cpp @@ -1,6 +1,5 @@ #ifdef TARGET_LPC1768 -#include #include #include #include @@ -84,7 +83,6 @@ void HAL_init() { #endif HAL_timer_init(); - LPC1768_PWM_init(); } // HAL idle task diff --git a/Marlin/src/HAL/HAL_LPC1768/spi_pins.h b/Marlin/src/HAL/HAL_LPC1768/spi_pins.h index d67a70700..76c19c117 100644 --- a/Marlin/src/HAL/HAL_LPC1768/spi_pins.h +++ b/Marlin/src/HAL/HAL_LPC1768/spi_pins.h @@ -50,7 +50,7 @@ #ifndef SS_PIN #define SS_PIN P1_23 #endif -#if !defined(SDSS) || SDSS == P_NC // get defaulted in pins.h +#if !defined(SDSS) || SDSS == P_NC // gets defaulted in pins.h #undef SDSS #define SDSS SS_PIN #endif diff --git a/Marlin/src/HAL/shared/servo.h b/Marlin/src/HAL/shared/servo.h index 68af7e221..93a10aaf6 100644 --- a/Marlin/src/HAL/shared/servo.h +++ b/Marlin/src/HAL/shared/servo.h @@ -73,7 +73,7 @@ #elif IS_TEENSY35 || IS_TEENSY36 #include "../HAL_TEENSY35_36/HAL_Servo_Teensy.h" #elif defined(TARGET_LPC1768) - #include "../HAL_LPC1768/servo_private.h" + #include "../HAL_LPC1768/MarlinServo.h" #elif defined(__STM32F1__) || defined(TARGET_STM32F1) #include "../HAL_STM32F1/HAL_Servo_STM32F1.h" #elif defined(STM32GENERIC) && defined(STM32F4) diff --git a/Marlin/src/module/servo.h b/Marlin/src/module/servo.h index bd7e2acf5..04582431d 100644 --- a/Marlin/src/module/servo.h +++ b/Marlin/src/module/servo.h @@ -27,6 +27,7 @@ #ifndef _SERVO_H_ #define _SERVO_H_ +#include "../inc/MarlinConfig.h" #include "../HAL/shared/servo.h" extern HAL_SERVO_LIB servo[NUM_SERVOS]; @@ -35,8 +36,6 @@ extern void servo_init(); #define MOVE_SERVO(I, P) servo[I].move(P) -#include "../inc/MarlinConfig.h" - #if HAS_Z_SERVO_PROBE #define DEPLOY_Z_SERVO() MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][0]) #define STOW_Z_SERVO() MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][1])