Browse Source

servo update

pull/1/head
Christopher Pepper 6 years ago
parent
commit
254b68fe2c
  1. 2
      Marlin/src/HAL/HAL_LPC1768/DebugMonitor_LPC1768.cpp
  2. 2
      Marlin/src/HAL/HAL_LPC1768/HAL.h
  3. 15
      Marlin/src/HAL/HAL_LPC1768/MarlinServo.h
  4. 2
      Marlin/src/HAL/HAL_LPC1768/main.cpp
  5. 2
      Marlin/src/HAL/HAL_LPC1768/spi_pins.h
  6. 2
      Marlin/src/HAL/shared/servo.h
  7. 3
      Marlin/src/module/servo.h

2
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

2
Marlin/src/HAL/HAL_LPC1768/HAL.h

@ -151,6 +151,8 @@ using FilteredADC = LPC176x::ADC<ADC_LOWPASS_K_VALUE, ADC_MEDIAN_FILTER_SIZE>;
// Parse a G-code word into a pin index // Parse a G-code word into a pin index
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval); 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 #define HAL_IDLETASK 1
void HAL_idletask(void); void HAL_idletask(void);

15
Marlin/src/HAL/HAL_LPC1768/servo_private.h → Marlin/src/HAL/HAL_LPC1768/MarlinServo.h

@ -50,25 +50,24 @@
#ifndef SERVO_PRIVATE_H #ifndef SERVO_PRIVATE_H
#define SERVO_PRIVATE_H #define SERVO_PRIVATE_H
#include <LPC1768_Servo.h> #include <Servo.h>
class MarlinServo: public Servo { class MarlinServo: public Servo {
public:
void move(const int value) { void move(const int value) {
constexpr uint16_t servo_delay[] = SERVO_DELAY; constexpr uint16_t servo_delay[] = SERVO_DELAY;
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long."); 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) #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach(); 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 #endif
} }
} }
} };
#define HAL_SERVO_LIB MarlinServo #define HAL_SERVO_LIB MarlinServo

2
Marlin/src/HAL/HAL_LPC1768/main.cpp

@ -1,6 +1,5 @@
#ifdef TARGET_LPC1768 #ifdef TARGET_LPC1768
#include <LPC1768_PWM.h>
#include <usb/usb.h> #include <usb/usb.h>
#include <usb/usbcfg.h> #include <usb/usbcfg.h>
#include <usb/usbhw.h> #include <usb/usbhw.h>
@ -84,7 +83,6 @@ void HAL_init() {
#endif #endif
HAL_timer_init(); HAL_timer_init();
LPC1768_PWM_init();
} }
// HAL idle task // HAL idle task

2
Marlin/src/HAL/HAL_LPC1768/spi_pins.h

@ -50,7 +50,7 @@
#ifndef SS_PIN #ifndef SS_PIN
#define SS_PIN P1_23 #define SS_PIN P1_23
#endif #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 #undef SDSS
#define SDSS SS_PIN #define SDSS SS_PIN
#endif #endif

2
Marlin/src/HAL/shared/servo.h

@ -73,7 +73,7 @@
#elif IS_TEENSY35 || IS_TEENSY36 #elif IS_TEENSY35 || IS_TEENSY36
#include "../HAL_TEENSY35_36/HAL_Servo_Teensy.h" #include "../HAL_TEENSY35_36/HAL_Servo_Teensy.h"
#elif defined(TARGET_LPC1768) #elif defined(TARGET_LPC1768)
#include "../HAL_LPC1768/servo_private.h" #include "../HAL_LPC1768/MarlinServo.h"
#elif defined(__STM32F1__) || defined(TARGET_STM32F1) #elif defined(__STM32F1__) || defined(TARGET_STM32F1)
#include "../HAL_STM32F1/HAL_Servo_STM32F1.h" #include "../HAL_STM32F1/HAL_Servo_STM32F1.h"
#elif defined(STM32GENERIC) && defined(STM32F4) #elif defined(STM32GENERIC) && defined(STM32F4)

3
Marlin/src/module/servo.h

@ -27,6 +27,7 @@
#ifndef _SERVO_H_ #ifndef _SERVO_H_
#define _SERVO_H_ #define _SERVO_H_
#include "../inc/MarlinConfig.h"
#include "../HAL/shared/servo.h" #include "../HAL/shared/servo.h"
extern HAL_SERVO_LIB servo[NUM_SERVOS]; extern HAL_SERVO_LIB servo[NUM_SERVOS];
@ -35,8 +36,6 @@ extern void servo_init();
#define MOVE_SERVO(I, P) servo[I].move(P) #define MOVE_SERVO(I, P) servo[I].move(P)
#include "../inc/MarlinConfig.h"
#if HAS_Z_SERVO_PROBE #if HAS_Z_SERVO_PROBE
#define DEPLOY_Z_SERVO() MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][0]) #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]) #define STOW_Z_SERVO() MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][1])

Loading…
Cancel
Save