Переглянути джерело

Use new attribute macros in more places

Scott Lahteine 7 роки тому
джерело
коміт
34cfbc90cd
6 змінених файлів з 55 додано та 67 видалено
  1. 6
    6
      Marlin/macros.h
  2. 16
    16
      Marlin/nozzle.cpp
  3. 21
    21
      Marlin/nozzle.h
  4. 10
    21
      Marlin/spi.h
  5. 1
    1
      Marlin/temperature.cpp
  6. 1
    2
      Marlin/temperature.h

+ 6
- 6
Marlin/macros.h Переглянути файл

@@ -29,12 +29,12 @@
29 29
 #define XYZ  3
30 30
 
31 31
 #define FORCE_INLINE __attribute__((always_inline)) inline
32
-
33
-#define _O0 __attribute__((optimize("O0")))
34
-#define _Os __attribute__((optimize("Os")))
35
-#define _O1 __attribute__((optimize("O1")))
36
-#define _O2 __attribute__((optimize("O2")))
37
-#define _O3 __attribute__((optimize("O3")))
32
+#define _UNUSED      __attribute__((unused))
33
+#define _O0          __attribute__((optimize("O0")))
34
+#define _Os          __attribute__((optimize("Os")))
35
+#define _O1          __attribute__((optimize("O1")))
36
+#define _O2          __attribute__((optimize("O2")))
37
+#define _O3          __attribute__((optimize("O3")))
38 38
 
39 39
 // Bracket code that shouldn't be interrupted
40 40
 #ifndef CRITICAL_SECTION_START

+ 16
- 16
Marlin/nozzle.cpp Переглянути файл

@@ -12,9 +12,9 @@
12 12
   * @param strokes number of strokes to execute
13 13
   */
14 14
 void Nozzle::stroke(
15
-  __attribute__((unused)) point_t const &start,
16
-  __attribute__((unused)) point_t const &end,
17
-  __attribute__((unused)) uint8_t const &strokes
15
+  _UNUSED point_t const &start,
16
+  _UNUSED point_t const &end,
17
+  _UNUSED uint8_t const &strokes
18 18
 ) {
19 19
   #if ENABLED(NOZZLE_CLEAN_FEATURE)
20 20
 
@@ -56,10 +56,10 @@ void Nozzle::stroke(
56 56
   * @param objects number of objects to create
57 57
   */
58 58
 void Nozzle::zigzag(
59
-  __attribute__((unused)) point_t const &start,
60
-  __attribute__((unused)) point_t const &end,
61
-  __attribute__((unused)) uint8_t const &strokes,
62
-  __attribute__((unused)) uint8_t const &objects
59
+  _UNUSED point_t const &start,
60
+  _UNUSED point_t const &end,
61
+  _UNUSED uint8_t const &strokes,
62
+  _UNUSED uint8_t const &objects
63 63
 ) {
64 64
   #if ENABLED(NOZZLE_CLEAN_FEATURE)
65 65
     const float A = nozzle_clean_horizontal ? nozzle_clean_height : nozzle_clean_length, // [twice the] Amplitude
@@ -114,10 +114,10 @@ void Nozzle::zigzag(
114 114
   * @param radius radius of circle
115 115
   */
116 116
 void Nozzle::circle(
117
-  __attribute__((unused)) point_t const &start,
118
-  __attribute__((unused)) point_t const &middle,
119
-  __attribute__((unused)) uint8_t const &strokes,
120
-  __attribute__((unused)) float const &radius
117
+  _UNUSED point_t const &start,
118
+  _UNUSED point_t const &middle,
119
+  _UNUSED uint8_t const &strokes,
120
+  _UNUSED float const &radius
121 121
 ) {
122 122
   #if ENABLED(NOZZLE_CLEAN_FEATURE)
123 123
     if (strokes == 0) return;
@@ -177,10 +177,10 @@ void Nozzle::circle(
177 177
   * @param argument depends on the cleaning pattern
178 178
   */
179 179
 void Nozzle::clean(
180
-  __attribute__((unused)) uint8_t const &pattern,
181
-  __attribute__((unused)) uint8_t const &strokes,
182
-  __attribute__((unused)) float const &radius,
183
-  __attribute__((unused)) uint8_t const &objects
180
+  _UNUSED uint8_t const &pattern,
181
+  _UNUSED uint8_t const &strokes,
182
+  _UNUSED float const &radius,
183
+  _UNUSED uint8_t const &objects
184 184
 ) {
185 185
   #if ENABLED(NOZZLE_CLEAN_FEATURE)
186 186
     #if ENABLED(DELTA)
@@ -209,7 +209,7 @@ void Nozzle::clean(
209 209
 }
210 210
 
211 211
 void Nozzle::park(
212
-  __attribute__((unused)) uint8_t const &z_action
212
+  _UNUSED uint8_t const &z_action
213 213
 ) {
214 214
   #if ENABLED(NOZZLE_PARK_FEATURE)
215 215
     float const z = current_position[Z_AXIS];

+ 21
- 21
Marlin/nozzle.h Переглянути файл

@@ -50,10 +50,10 @@ class Nozzle {
50 50
      * @param strokes number of strokes to execute
51 51
      */
52 52
     static void stroke(
53
-      __attribute__((unused)) point_t const &start,
54
-      __attribute__((unused)) point_t const &end,
55
-      __attribute__((unused)) uint8_t const &strokes
56
-    ) __attribute__((optimize ("Os")));
53
+      _UNUSED point_t const &start,
54
+      _UNUSED point_t const &end,
55
+      _UNUSED uint8_t const &strokes
56
+    ) _Os;
57 57
 
58 58
     /**
59 59
      * @brief Zig-zag clean pattern
@@ -65,11 +65,11 @@ class Nozzle {
65 65
      * @param objects number of objects to create
66 66
      */
67 67
     static void zigzag(
68
-      __attribute__((unused)) point_t const &start,
69
-      __attribute__((unused)) point_t const &end,
70
-      __attribute__((unused)) uint8_t const &strokes,
71
-      __attribute__((unused)) uint8_t const &objects
72
-    ) __attribute__((optimize ("Os")));
68
+      _UNUSED point_t const &start,
69
+      _UNUSED point_t const &end,
70
+      _UNUSED uint8_t const &strokes,
71
+      _UNUSED uint8_t const &objects
72
+    ) _Os;
73 73
 
74 74
     /**
75 75
      * @brief Circular clean pattern
@@ -80,11 +80,11 @@ class Nozzle {
80 80
      * @param radius radius of circle
81 81
      */
82 82
     static void circle(
83
-      __attribute__((unused)) point_t const &start,
84
-      __attribute__((unused)) point_t const &middle,
85
-      __attribute__((unused)) uint8_t const &strokes,
86
-      __attribute__((unused)) float const &radius
87
-    ) __attribute__((optimize ("Os")));
83
+      _UNUSED point_t const &start,
84
+      _UNUSED point_t const &middle,
85
+      _UNUSED uint8_t const &strokes,
86
+      _UNUSED float const &radius
87
+    ) _Os;
88 88
 
89 89
   public:
90 90
     /**
@@ -95,15 +95,15 @@ class Nozzle {
95 95
      * @param argument depends on the cleaning pattern
96 96
      */
97 97
     static void clean(
98
-      __attribute__((unused)) uint8_t const &pattern,
99
-      __attribute__((unused)) uint8_t const &strokes,
100
-      __attribute__((unused)) float const &radius,
101
-      __attribute__((unused)) uint8_t const &objects = 0
102
-    ) __attribute__((optimize ("Os")));
98
+      _UNUSED uint8_t const &pattern,
99
+      _UNUSED uint8_t const &strokes,
100
+      _UNUSED float const &radius,
101
+      _UNUSED uint8_t const &objects = 0
102
+    ) _Os;
103 103
 
104 104
     static void park(
105
-      __attribute__((unused)) uint8_t const &z_action
106
-    ) __attribute__((optimize ("Os")));
105
+      _UNUSED uint8_t const &z_action
106
+    ) _Os;
107 107
 };
108 108
 
109 109
 #endif

+ 10
- 21
Marlin/spi.h Переглянути файл

@@ -27,37 +27,26 @@
27 27
 #include "softspi.h"
28 28
 
29 29
 template<uint8_t MisoPin, uint8_t MosiPin, uint8_t SckPin>
30
-class Spi {
31
-  static SoftSPI<MisoPin, MosiPin, SckPin> softSpi;
30
+class SPI {
31
+  static SoftSPI<MisoPin, MosiPin, SckPin> softSPI;
32 32
   public:
33
-    inline __attribute__((always_inline))
34
-    static void init() {
35
-        softSpi.begin();
36
-    }
37
-    inline __attribute__((always_inline))
38
-    static void send(uint8_t data) {
39
-        softSpi.send(data);
40
-    }
41
-    inline __attribute__((always_inline))
42
-    static uint8_t receive() {
43
-        return softSpi.receive();
44
-    }
33
+    FORCE_INLINE static void init() { softSPI.begin(); }
34
+    FORCE_INLINE static void send(uint8_t data) { softSPI.send(data); }
35
+    FORCE_INLINE static uint8_t receive() { return softSPI.receive(); }
45 36
 };
46 37
 
47 38
 
48
-//hardware spi
39
+// Hardware SPI
49 40
 template<>
50
-class Spi<MISO_PIN, MOSI_PIN, SCK_PIN> {
41
+class SPI<MISO_PIN, MOSI_PIN, SCK_PIN> {
51 42
   public:
52
-    inline __attribute__((always_inline))
53
-    static void init() {
43
+    FORCE_INLINE static void init() {
54 44
         OUT_WRITE(SCK_PIN, LOW);
55 45
         OUT_WRITE(MOSI_PIN, HIGH);
56 46
         SET_INPUT(MISO_PIN);
57 47
         WRITE(MISO_PIN, HIGH);
58 48
     }
59
-    inline __attribute__((always_inline))
60
-    static uint8_t receive() {
49
+    FORCE_INLINE static uint8_t receive() {
61 50
       SPDR = 0;
62 51
       for (;!TEST(SPSR, SPIF););
63 52
       return SPDR;
@@ -65,4 +54,4 @@ class Spi<MISO_PIN, MOSI_PIN, SCK_PIN> {
65 54
 
66 55
 };
67 56
 
68
-#endif
57
+#endif // __SPI_H__

+ 1
- 1
Marlin/temperature.cpp Переглянути файл

@@ -935,7 +935,7 @@ void Temperature::updateTemperaturesFromRawValues() {
935 935
   #ifndef MAX6675_DO_PIN
936 936
     #define MAX6675_DO_PIN MISO_PIN
937 937
   #endif
938
-  Spi<MAX6675_DO_PIN, MOSI_PIN, MAX6675_SCK_PIN> max6675_spi;
938
+  SPI<MAX6675_DO_PIN, MOSI_PIN, MAX6675_SCK_PIN> max6675_spi;
939 939
 #endif
940 940
 
941 941
 /**

+ 1
- 2
Marlin/temperature.h Переглянути файл

@@ -288,8 +288,7 @@ class Temperature {
288 288
     /**
289 289
      * Call periodically to manage heaters
290 290
      */
291
-    //static void manage_heater(); // changed to address compiler error
292
-    static void manage_heater()  __attribute__((__optimize__("O2")));
291
+    static void manage_heater() _O2; // Added _O2 to work around a compiler error
293 292
 
294 293
     /**
295 294
      * Preheating hotends

Завантаження…
Відмінити
Зберегти