소스 검색

Clean up some HAL code

Scott Lahteine 6 년 전
부모
커밋
27cbb939b2

+ 3
- 1
Marlin/src/HAL/HAL_AVR/watchdog_AVR.cpp 파일 보기

@@ -22,12 +22,14 @@
22 22
 
23 23
 #ifdef ARDUINO_ARCH_AVR
24 24
 
25
-#include "../../../Marlin.h"
25
+#include "../../../MarlinConfig.h"
26 26
 
27 27
 #if ENABLED(USE_WATCHDOG)
28 28
 
29 29
 #include "watchdog_AVR.h"
30 30
 
31
+#include "../../../Marlin.h"
32
+
31 33
 // Initialize watchdog with a 4 sec interrupt time
32 34
 void watchdog_init() {
33 35
   #if ENABLED(WATCHDOG_RESET_MANUAL)

+ 1
- 3
Marlin/src/HAL/HAL_AVR/watchdog_AVR.h 파일 보기

@@ -23,8 +23,6 @@
23 23
 #ifndef WATCHDOG_AVR_H
24 24
 #define WATCHDOG_AVR_H
25 25
 
26
-//#include "../../../Marlin.h"
27
-
28 26
 #include <avr/wdt.h>
29 27
 
30 28
 // Initialize watchdog with a 4 second interrupt time
@@ -34,4 +32,4 @@ void watchdog_init();
34 32
 // first watchdog_init or AVR will go into emergency procedures.
35 33
 inline void watchdog_reset() { wdt_reset(); }
36 34
 
37
-#endif
35
+#endif // WATCHDOG_AVR_H

+ 2
- 2
Marlin/src/HAL/HAL_DUE/HAL_Due.cpp 파일 보기

@@ -94,8 +94,8 @@ uint8_t HAL_get_reset_source (void) {
94 94
 }
95 95
 
96 96
 void _delay_ms(int delay_ms) {
97
-  //todo: port for Due?
98
-  delay (delay_ms);
97
+  // todo: port for Due?
98
+  delay(delay_ms);
99 99
 }
100 100
 
101 101
 extern "C" {

+ 0
- 1
Marlin/src/HAL/HAL_DUE/HAL_timers_Due.cpp 파일 보기

@@ -91,7 +91,6 @@ const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
91 91
   Timer_clock4: Prescaler 128 -> 656.25kHz
92 92
 */
93 93
 
94
-
95 94
 void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
96 95
   Tc *tc = TimerConfig[timer_num].pTimerRegs;
97 96
   IRQn_Type irq = TimerConfig[timer_num].IRQ_Id;

+ 0
- 1
Marlin/src/HAL/HAL_DUE/fastio_Due.h 파일 보기

@@ -431,5 +431,4 @@ pins
431 431
 #define DIO100_PIN 11
432 432
 #define DIO100_WPORT PIOC
433 433
 
434
-
435 434
 #endif // _FASTIO_DUE_H

+ 2
- 2
Marlin/src/HAL/HAL_LPC1768/LPC1768_PWM.h 파일 보기

@@ -21,7 +21,7 @@
21 21
  */
22 22
 
23 23
 /**
24
- * The class Servo uses the PWM class to implement it's functions
24
+ * The class Servo uses the PWM class to implement its functions
25 25
  *
26 26
  * All PWMs use the same repetition rate - 20mS because that's the normal servo rate
27 27
 */
@@ -489,7 +489,7 @@ return;
489 489
  *          writes to the LER register
490 490
  *          sets the PWM_table_swap flag active
491 491
  *          re-enables the ISR
492
- *     7) On the next interrupt the ISR changes it's pointer to the work table which is now the old, 
492
+ *     7) On the next interrupt the ISR changes its pointer to the work table which is now the old, 
493 493
  *        unmodified, active table.
494 494
  *     8) On the next MR0 interrupt the ISR:
495 495
  *          switches over to the active table

+ 57
- 67
Marlin/src/HAL/HAL_LPC1768/LPC1768_Servo.cpp 파일 보기

@@ -1,85 +1,79 @@
1 1
 /**
2
-  * Marlin 3D Printer Firmware
3
-  * Copyright (C) 2016, 2017 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
-  *
5
-  * Based on Sprinter and grbl.
6
-  * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
-  *
8
-  * This program is free software: you can redistribute it and/or modify
9
-  * it under the terms of the GNU General Public License as published by
10
-  * the Free Software Foundation, either version 3 of the License, or
11
-  * (at your option) any later version.
12
-  *
13
-  * This program is distributed in the hope that it will be useful,
14
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
-  * GNU General Public License for more details.
17
-  *
18
-  * You should have received a copy of the GNU General Public License
19
-  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
-  *
21
-*/
22
-
23
-/**
24
-  * Based on servo.cpp - Interrupt driven Servo library for Arduino using 16 bit
25
-  * timers- Version 2  Copyright (c) 2009 Michael Margolis.  All right reserved.
26
-*/
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
27 22
 
28 23
 /**
29
-  * A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method.
30
-  * The servos are pulsed in the background using the value most recently written using the write() method
31
-  *
32
-  * Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached.
33
-  * Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four.
34
-  *
35
-  * The methods are:
36
-  *
37
-  * Servo - Class for manipulating servo motors connected to Arduino pins.
38
-  *
39
-  * attach(pin)           - Attach a servo motor to an i/o pin.
40
-  * attach(pin, min, max) - Attach to a pin, setting min and max values in microseconds
41
-  *                         Default min is 544, max is 2400
42
-  *
43
-  * write()               - Set the servo angle in degrees. (Invalid angles —over MIN_PULSE_WIDTH— are treated as µs.)
44
-  * writeMicroseconds()   - Set the servo pulse width in microseconds.
45
-  * move(pin, angle)      - Sequence of attach(pin), write(angle), delay(SERVO_DELAY).
46
-  *                         With DEACTIVATE_SERVOS_AFTER_MOVE it detaches after SERVO_DELAY.
47
-  * read()                - Get the last-written servo pulse width as an angle between 0 and 180.
48
-  * readMicroseconds()    - Get the last-written servo pulse width in microseconds.
49
-  * attached()            - Return true if a servo is attached.
50
-  * detach()              - Stop an attached servo from pulsing its i/o pin.
51
-  *
52
-*/
24
+ * Based on servo.cpp - Interrupt driven Servo library for Arduino using 16 bit
25
+ * timers- Version 2  Copyright (c) 2009 Michael Margolis.  All right reserved.
26
+ */
53 27
 
54 28
 /**
55
- *  The only time that this library wants physical movement is when a WRITE
56
- *  command is issued.  Before that all the attach & detach activity is solely
57
- *  within the data base.
29
+ * A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method.
30
+ * The servos are pulsed in the background using the value most recently written using the write() method
31
+ *
32
+ * Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached.
33
+ * Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four.
34
+ *
35
+ * The methods are:
36
+ *
37
+ * Servo - Class for manipulating servo motors connected to Arduino pins.
58 38
  *
59
- *  The PWM output is inactive until the first WRITE.  After that it stays active
60
- *  unless DEACTIVATE_SERVOS_AFTER_MOVE is enabled and a MOVE command was issued.
39
+ * attach(pin)           - Attach a servo motor to an i/o pin.
40
+ * attach(pin, min, max) - Attach to a pin, setting min and max values in microseconds
41
+ *                         Default min is 544, max is 2400
42
+ *
43
+ * write()               - Set the servo angle in degrees. (Invalid angles —over MIN_PULSE_WIDTH— are treated as µs.)
44
+ * writeMicroseconds()   - Set the servo pulse width in microseconds.
45
+ * move(pin, angle)      - Sequence of attach(pin), write(angle), delay(SERVO_DELAY).
46
+ *                         With DEACTIVATE_SERVOS_AFTER_MOVE it detaches after SERVO_DELAY.
47
+ * read()                - Get the last-written servo pulse width as an angle between 0 and 180.
48
+ * readMicroseconds()    - Get the last-written servo pulse width in microseconds.
49
+ * attached()            - Return true if a servo is attached.
50
+ * detach()              - Stop an attached servo from pulsing its i/o pin.
61 51
  *
62 52
  */
63 53
 
64
-#ifdef TARGET_LPC1768
65
-
66
-#if HAS_SERVOS
54
+/**
55
+ * The only time that this library wants physical movement is when a WRITE
56
+ * command is issued.  Before that all the attach & detach activity is solely
57
+ * within the data base.
58
+ *
59
+ * The PWM output is inactive until the first WRITE.  After that it stays active
60
+ * unless DEACTIVATE_SERVOS_AFTER_MOVE is enabled and a MOVE command was issued.
61
+ */
67 62
 
63
+#include "../../../MarlinConfig.h"
68 64
 
69
-#include "LPC1768_Servo.h"
70
-#include "servo_private.h"
65
+#if HAS_SERVOS && defined(TARGET_LPC1768)
71 66
 
67
+  #include "LPC1768_Servo.h"
68
+  #include "servo_private.h"
72 69
 
73 70
   extern bool LPC1768_PWM_attach_pin(uint8_t, uint32_t, uint32_t, uint8_t);
74 71
   extern bool LPC1768_PWM_write(uint8_t, uint32_t);
75 72
   extern bool LPC1768_PWM_detach_pin(uint8_t);
76 73
 
77
-
78
-
79 74
   ServoInfo_t servo_info[MAX_SERVOS];                  // static array of servo info structures
80 75
   uint8_t ServoCount = 0;                              // the total number of attached servos
81 76
 
82
-
83 77
   #define US_TO_PULSE_WIDTH(p) p
84 78
   #define PULSE_WIDTH_TO_US(p) p
85 79
   #define TRIM_DURATION 0
@@ -107,7 +101,6 @@
107 101
                                                               // greater than zero. This way the init routine can
108 102
                                                               // assign the pin and the MOVE command only needs the value.
109 103
 
110
-
111 104
     this->min = MIN_PULSE_WIDTH; //resolution of min/max is 1 uS
112 105
     this->max = MAX_PULSE_WIDTH;
113 106
 
@@ -165,7 +158,4 @@
165 158
     }
166 159
   }
167 160
 
168
-#endif // HAS_SERVOS
169
-
170
-#endif // TARGET_LPC1768
171
-
161
+#endif // HAS_SERVOS && TARGET_LPC1768

+ 30
- 37
Marlin/src/HAL/HAL_LPC1768/LPC1768_Servo.h 파일 보기

@@ -21,7 +21,7 @@
21 21
  */
22 22
 
23 23
 /**
24
- * The class Servo uses the PWM class to implement it's functions
24
+ * The class Servo uses the PWM class to implement its functions
25 25
  *
26 26
  * The PWM1 module is only used to generate interrups at specified times. It
27 27
  * is NOT used to directly toggle pins. The ISR writes to the pin assigned to
@@ -31,39 +31,32 @@
31 31
  *
32 32
  */
33 33
 
34
-#ifndef LPC1768_SERVO_h
35
-  #define LPC1768_SERVO_h
36
-
37
-  #ifdef TARGET_LPC1768
38
-    #include <inttypes.h>
39
-
40
-
41
-    class Servo {
42
-      public:
43
-        Servo();
44
-        int8_t attach(int pin);            // attach the given pin to the next free channel, set pinMode, return channel number (-1 on fail)
45
-        int8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes.
46
-        void detach();
47
-        void write(int value);             // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
48
-        void writeMicroseconds(int value); // write pulse width in microseconds
49
-        void move(int value);              // attach the servo, then move to value
50
-                                           // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
51
-                                           // if DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DELAY, then detach
52
-        int read();                        // returns current pulse width as an angle between 0 and 180 degrees
53
-        int readMicroseconds();            // returns current pulse width in microseconds for this servo (was read_us() in first release)
54
-        bool attached();                   // return true if this servo is attached, otherwise false
55
-
56
-      private:
57
-        uint8_t servoIndex;               // index into the channel data for this servo
58
-        int min;
59
-        int max;
60
-    };
61
-
62
-
63
-    #define HAL_SERVO_LIB Servo
64
-
65
-  #endif
66
-#endif
67
-
68
-
69
-
34
+#ifndef LPC1768_SERVO_H
35
+#define LPC1768_SERVO_H
36
+
37
+#include <inttypes.h>
38
+
39
+class Servo {
40
+  public:
41
+    Servo();
42
+    int8_t attach(int pin);            // attach the given pin to the next free channel, set pinMode, return channel number (-1 on fail)
43
+    int8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes.
44
+    void detach();
45
+    void write(int value);             // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
46
+    void writeMicroseconds(int value); // write pulse width in microseconds
47
+    void move(int value);              // attach the servo, then move to value
48
+                                       // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
49
+                                       // if DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DELAY, then detach
50
+    int read();                        // returns current pulse width as an angle between 0 and 180 degrees
51
+    int readMicroseconds();            // returns current pulse width in microseconds for this servo (was read_us() in first release)
52
+    bool attached();                   // return true if this servo is attached, otherwise false
53
+
54
+  private:
55
+    uint8_t servoIndex;               // index into the channel data for this servo
56
+    int min;
57
+    int max;
58
+};
59
+
60
+#define HAL_SERVO_LIB Servo
61
+
62
+#endif // LPC1768_SERVO_H

+ 13
- 14
Marlin/src/HAL/HAL_pinsDebug.h 파일 보기

@@ -21,19 +21,18 @@
21 21
  */
22 22
 
23 23
 #ifndef HAL_PINSDEBUG_H
24
+#define HAL_PINSDEBUG_H
24 25
 
25
-#if defined(PINS_DEBUGGING)
26
-  #ifdef ARDUINO_ARCH_AVR
27
-    #include "HAL_AVR/pinsDebug_AVR_8_bit.h"
28
-  #elif defined(ARDUINO_ARCH_SAM)
29
-    #include "HAL_DUE/HAL_pinsDebug_Due.h"
30
-  #elif IS_32BIT_TEENSY
31
-    #include "HAL_TEENSY35_36/HAL_pinsDebug_Teensy.h"
32
-  #elif defined(TARGET_LPC1768)
33
-    #include "HAL_LPC1768/pinsDebug_Re_ARM.h"
34
-  #else
35
-    #error Unsupported Platform!
36
-  #endif
37
-#endif  
38
-
26
+#ifdef ARDUINO_ARCH_AVR
27
+  #include "HAL_AVR/pinsDebug_AVR_8_bit.h"
28
+#elif defined(ARDUINO_ARCH_SAM)
29
+  #include "HAL_DUE/HAL_pinsDebug_Due.h"
30
+#elif IS_32BIT_TEENSY
31
+  #include "HAL_TEENSY35_36/HAL_pinsDebug_Teensy.h"
32
+#elif defined(TARGET_LPC1768)
33
+  #include "HAL_LPC1768/pinsDebug_Re_ARM.h"
34
+#else
35
+  #error Unsupported Platform!
39 36
 #endif
37
+
38
+#endif // HAL_PINSDEBUG_H

+ 1
- 1
Marlin/src/HAL/HAL_spi_pins.h 파일 보기

@@ -41,4 +41,4 @@
41 41
   #error "Unsupported Platform!"
42 42
 #endif
43 43
 
44
-#endif /* HAL_SPI_PINS_H_ */
44
+#endif // HAL_SPI_PINS_H_

+ 34
- 35
Marlin/src/HAL/servo.h 파일 보기

@@ -66,48 +66,47 @@
66 66
                    With DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DELAY and detach.
67 67
  */
68 68
 
69
-#ifndef servo_h
70
-#define servo_h
69
+#ifndef SERVO_H
70
+#define SERVO_H
71 71
 
72 72
 #if IS_32BIT_TEENSY
73 73
   #include "HAL_TEENSY35_36/HAL_Servo_Teensy.h" // Teensy HAL uses an inherited library
74 74
 
75 75
 #elif defined(TARGET_LPC1768)
76
-  #include "HAL_LPC1768/LPC1768_Servo.cpp"
76
+  #include "HAL_LPC1768/LPC1768_Servo.h"
77 77
 
78 78
 #else
79
+  #include <inttypes.h>
80
+
81
+  #if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_SAM)
82
+    // we're good to go
83
+  #else
84
+    #error "This library only supports boards with an AVR or SAM3X processor."
85
+  #endif
86
+
87
+  #define Servo_VERSION           2     // software version of this library
88
+
89
+  class Servo {
90
+    public:
91
+      Servo();
92
+      int8_t attach(int pin);            // attach the given pin to the next free channel, set pinMode, return channel number (-1 on fail)
93
+      int8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes.
94
+      void detach();
95
+      void write(int value);             // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
96
+      void writeMicroseconds(int value); // write pulse width in microseconds
97
+      void move(int value);              // attach the servo, then move to value
98
+                                         // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
99
+                                         // if DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DELAY, then detach
100
+      int read();                        // returns current pulse width as an angle between 0 and 180 degrees
101
+      int readMicroseconds();            // returns current pulse width in microseconds for this servo (was read_us() in first release)
102
+      bool attached();                   // return true if this servo is attached, otherwise false
103
+
104
+    private:
105
+      uint8_t servoIndex;               // index into the channel data for this servo
106
+      int8_t min;                       // minimum is this value times 4 added to MIN_PULSE_WIDTH
107
+      int8_t max;                       // maximum is this value times 4 added to MAX_PULSE_WIDTH
108
+  };
79 109
 
80
-#include <inttypes.h>
81
-
82
-#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_SAM)
83
-  // we're good to go
84
-#else
85
-  #error "This library only supports boards with an AVR or SAM3X processor."
86 110
 #endif
87 111
 
88
-#define Servo_VERSION           2     // software version of this library
89
-
90
-class Servo {
91
-  public:
92
-    Servo();
93
-    int8_t attach(int pin);            // attach the given pin to the next free channel, set pinMode, return channel number (-1 on fail)
94
-    int8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes.
95
-    void detach();
96
-    void write(int value);             // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
97
-    void writeMicroseconds(int value); // write pulse width in microseconds
98
-    void move(int value);              // attach the servo, then move to value
99
-                                       // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
100
-                                       // if DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DELAY, then detach
101
-    int read();                        // returns current pulse width as an angle between 0 and 180 degrees
102
-    int readMicroseconds();            // returns current pulse width in microseconds for this servo (was read_us() in first release)
103
-    bool attached();                   // return true if this servo is attached, otherwise false
104
-
105
-  private:
106
-    uint8_t servoIndex;               // index into the channel data for this servo
107
-    int8_t min;                       // minimum is this value times 4 added to MIN_PULSE_WIDTH
108
-    int8_t max;                       // maximum is this value times 4 added to MAX_PULSE_WIDTH
109
-};
110
-
111
-#endif // !TEENSY
112
-
113
-#endif
112
+#endif // SERVO_H

+ 2
- 5
Marlin/stepper.cpp 파일 보기

@@ -355,11 +355,8 @@ void Stepper::isr() {
355 355
       }
356 356
 
357 357
       _NEXT_ISR(ocr_val);
358
-      #ifdef CPU_32_BIT
359
-        //todo: HAL?
360
-      #else
361
-        NOLESS(OCR1A, TCNT1 + 16);
362
-      #endif
358
+
359
+      NOLESS(OCR1A, TCNT1 + 16);
363 360
 
364 361
       HAL_ENABLE_ISRs(); // re-enable ISRs
365 362
       return;

Loading…
취소
저장