浏览代码

HAL include and other adjustments (#14525)

Scott Lahteine 6 年前
父节点
当前提交
a2ba0aaaac
没有帐户链接到提交者的电子邮件

Marlin/src/HAL/platforms.h → Marlin/src/HAL/HAL.h 查看文件

50
 #define XSTR_(M) #M
50
 #define XSTR_(M) #M
51
 #define XSTR(M) XSTR_(M)
51
 #define XSTR(M) XSTR_(M)
52
 #define HAL_PATH(PATH, NAME) XSTR(PATH/HAL_PLATFORM/NAME)
52
 #define HAL_PATH(PATH, NAME) XSTR(PATH/HAL_PLATFORM/NAME)
53
+
54
+#include HAL_PATH(.,HAL.h)

+ 2
- 2
Marlin/src/HAL/HAL_AVR/HAL.h 查看文件

22
 // Includes
22
 // Includes
23
 // --------------------------------------------------------------------------
23
 // --------------------------------------------------------------------------
24
 
24
 
25
-#include <stdint.h>
26
-
27
 #include "../shared/Marduino.h"
25
 #include "../shared/Marduino.h"
28
 #include "../shared/HAL_SPI.h"
26
 #include "../shared/HAL_SPI.h"
29
 #include "fastio_AVR.h"
27
 #include "fastio_AVR.h"
33
 #ifdef USBCON
31
 #ifdef USBCON
34
   #include "HardwareSerial.h"
32
   #include "HardwareSerial.h"
35
 #else
33
 #else
34
+  #define HardwareSerial_h // Hack to prevent HardwareSerial.h header inclusion
36
   #include "MarlinSerial.h"
35
   #include "MarlinSerial.h"
37
 #endif
36
 #endif
38
 
37
 
38
+#include <stdint.h>
39
 #include <util/delay.h>
39
 #include <util/delay.h>
40
 #include <avr/eeprom.h>
40
 #include <avr/eeprom.h>
41
 #include <avr/pgmspace.h>
41
 #include <avr/pgmspace.h>

+ 0
- 1
Marlin/src/HAL/HAL_AVR/MarlinSerial.h 查看文件

275
 
275
 
276
 #endif // !USBCON
276
 #endif // !USBCON
277
 
277
 
278
-
279
 #ifdef INTERNAL_SERIAL_PORT
278
 #ifdef INTERNAL_SERIAL_PORT
280
   template <uint8_t serial>
279
   template <uint8_t serial>
281
   struct MarlinInternalSerialCfg {
280
   struct MarlinInternalSerialCfg {

+ 0
- 1
Marlin/src/HAL/HAL_AVR/endstop_interrupts.h 查看文件

36
  * (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
36
  * (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino)
37
  */
37
  */
38
 
38
 
39
-#include "../../core/macros.h"
40
 #include "../../module/endstops.h"
39
 #include "../../module/endstops.h"
41
 
40
 
42
 #include <stdint.h>
41
 #include <stdint.h>

+ 2
- 0
Marlin/src/HAL/HAL_DUE/fastio_Due.h 查看文件

39
 
39
 
40
 #include <pins_arduino.h>
40
 #include <pins_arduino.h>
41
 
41
 
42
+#include "../../inc/MarlinConfigPre.h"
43
+
42
 /**
44
 /**
43
  * Utility functions
45
  * Utility functions
44
  */
46
  */

+ 1
- 1
Marlin/src/HAL/HAL_LPC1768/HAL.h 查看文件

34
 #include <stdarg.h>
34
 #include <stdarg.h>
35
 #include <algorithm>
35
 #include <algorithm>
36
 
36
 
37
-extern "C" volatile millis_t _millis;
37
+extern "C" volatile uint32_t _millis;
38
 
38
 
39
 #include "../shared/Marduino.h"
39
 #include "../shared/Marduino.h"
40
 #include "../shared/math_32bit.h"
40
 #include "../shared/math_32bit.h"

+ 2
- 0
Marlin/src/HAL/HAL_STM32F1/HAL_sdio_STM32F1.cpp 查看文件

124
   return false;
124
   return false;
125
 }
125
 }
126
 
126
 
127
+uint32_t millis();
128
+
127
 bool SDIO_WriteBlock(uint32_t blockAddress, const uint8_t *data) {
129
 bool SDIO_WriteBlock(uint32_t blockAddress, const uint8_t *data) {
128
   if (SDIO_GetCardState() != SDIO_CARD_TRANSFER) return false;
130
   if (SDIO_GetCardState() != SDIO_CARD_TRANSFER) return false;
129
   if (blockAddress >= SdCard.LogBlockNbr) return false;
131
   if (blockAddress >= SdCard.LogBlockNbr) return false;

+ 19
- 1
Marlin/src/HAL/HAL_TEENSY31_32/persistent_store_impl.cpp 查看文件

1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ */
1
 #ifdef __MK20DX256__
19
 #ifdef __MK20DX256__
2
 
20
 
3
 #include "../../inc/MarlinConfig.h"
21
 #include "../../inc/MarlinConfig.h"
4
 
22
 
5
 #if ENABLED(EEPROM_SETTINGS)
23
 #if ENABLED(EEPROM_SETTINGS)
6
 
24
 
7
-#include "../persistent_store_api.h"
25
+#include "../shared/persistent_store_api.h"
8
 
26
 
9
 namespace HAL {
27
 namespace HAL {
10
 namespace PersistentStore {
28
 namespace PersistentStore {

+ 1
- 1
Marlin/src/HAL/shared/I2cEeprom.cpp 查看文件

33
 // Includes
33
 // Includes
34
 // --------------------------------------------------------------------------
34
 // --------------------------------------------------------------------------
35
 
35
 
36
-#include HAL_PATH(.., HAL.h)
36
+#include "../HAL.h"
37
 #include <Wire.h>
37
 #include <Wire.h>
38
 
38
 
39
 // --------------------------------------------------------------------------
39
 // --------------------------------------------------------------------------

+ 1
- 1
Marlin/src/HAL/shared/SpiEeprom.cpp 查看文件

29
 
29
 
30
 #if ENABLED(SPI_EEPROM)
30
 #if ENABLED(SPI_EEPROM)
31
 
31
 
32
-#include HAL_PATH(.., HAL.h)
32
+#include "../HAL.h"
33
 
33
 
34
 #define CMD_WREN  6   // WREN
34
 #define CMD_WREN  6   // WREN
35
 #define CMD_READ  2   // WRITE
35
 #define CMD_READ  2   // WRITE

+ 63
- 4
Marlin/src/core/macros.h 查看文件

21
  */
21
  */
22
 #pragma once
22
 #pragma once
23
 
23
 
24
-#include "minmax.h"
25
-
26
 #define NUM_AXIS 4
24
 #define NUM_AXIS 4
27
 #define ABCE 4
25
 #define ABCE 4
28
 #define XYZE 4
26
 #define XYZE 4
75
 #undef _BV
73
 #undef _BV
76
 #define _BV(n) (1<<(n))
74
 #define _BV(n) (1<<(n))
77
 #define TEST(n,b) !!((n)&_BV(b))
75
 #define TEST(n,b) !!((n)&_BV(b))
78
-#define SBI(n,b) (n |= _BV(b))
79
-#define CBI(n,b) (n &= ~_BV(b))
80
 #define SET_BIT_TO(N,B,TF) do{ if (TF) SBI(N,B); else CBI(N,B); }while(0)
76
 #define SET_BIT_TO(N,B,TF) do{ if (TF) SBI(N,B); else CBI(N,B); }while(0)
81
 
77
 
78
+#ifndef SBI
79
+  #define SBI(A,B) (A |= (1 << (B)))
80
+#endif
81
+
82
+#ifndef CBI
83
+  #define CBI(A,B) (A &= ~(1 << (B)))
84
+#endif
85
+
82
 #define _BV32(b) (1UL << (b))
86
 #define _BV32(b) (1UL << (b))
83
 #define TEST32(n,b) !!((n)&_BV32(b))
87
 #define TEST32(n,b) !!((n)&_BV32(b))
84
 #define SBI32(n,b) (n |= _BV32(b))
88
 #define SBI32(n,b) (n |= _BV32(b))
269
 #else
273
 #else
270
   #define I2C_ADDRESS(A) A
274
   #define I2C_ADDRESS(A) A
271
 #endif
275
 #endif
276
+
277
+// Use NUM_ARGS(__VA_ARGS__) to get the number of variadic arguments
278
+#define _NUM_ARGS(_0,_24_,_23,_22,_21,_20,_19,_18,_17,_16,_15,_14,_13,_12,_11,_10,_9,_8,_7,_6,_5,_4,_3,_2,_1,N,...) N
279
+#define NUM_ARGS(V...) _NUM_ARGS(0,V,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
280
+
281
+#ifdef __cplusplus
282
+
283
+  #ifndef _MINMAX_H_
284
+  #define _MINMAX_H_
285
+
286
+    extern "C++" {
287
+
288
+      // C++11 solution that is standards compliant. Return type is deduced automatically
289
+      template <class L, class R> static inline constexpr auto _MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
290
+        return lhs < rhs ? lhs : rhs;
291
+      }
292
+      template <class L, class R> static inline constexpr auto _MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) {
293
+        return lhs > rhs ? lhs : rhs;
294
+      }
295
+      template<class T, class ... Ts> static inline constexpr const T _MIN(T V, Ts... Vs) { return _MIN(V, _MIN(Vs...)); }
296
+      template<class T, class ... Ts> static inline constexpr const T _MAX(T V, Ts... Vs) { return _MAX(V, _MAX(Vs...)); }
297
+
298
+    }
299
+
300
+  #endif
301
+
302
+#else
303
+
304
+  #define MIN_2(a,b)      ((a)<(b)?(a):(b))
305
+  #define MIN_3(a,...)    MIN_2(a,MIN_2(__VA_ARGS__))
306
+  #define MIN_4(a,...)    MIN_2(a,MIN_3(__VA_ARGS__))
307
+  #define MIN_5(a,...)    MIN_2(a,MIN_4(__VA_ARGS__))
308
+  #define MIN_6(a,...)    MIN_2(a,MIN_5(__VA_ARGS__))
309
+  #define MIN_7(a,...)    MIN_2(a,MIN_6(__VA_ARGS__))
310
+  #define MIN_8(a,...)    MIN_2(a,MIN_7(__VA_ARGS__))
311
+  #define MIN_9(a,...)    MIN_2(a,MIN_8(__VA_ARGS__))
312
+  #define MIN_10(a,...)   MIN_2(a,MIN_9(__VA_ARGS__))
313
+  #define __MIN_N(N, ...) MIN_##N(__VA_ARGS__)
314
+  #define _MIN_N(N, ...)  __MIN_N(N,__VA_ARGS__)
315
+  #define _MIN(...)       _MIN_N(NUM_ARGS(__VA_ARGS__), __VA_ARGS__)
316
+
317
+  #define MAX_2(a,b)      ((a)>(b)?(a):(b))
318
+  #define MAX_3(a,...)    MAX_2(a,MAX_2(__VA_ARGS__))
319
+  #define MAX_4(a,...)    MAX_2(a,MAX_3(__VA_ARGS__))
320
+  #define MAX_5(a,...)    MAX_2(a,MAX_4(__VA_ARGS__))
321
+  #define MAX_6(a,...)    MAX_2(a,MAX_5(__VA_ARGS__))
322
+  #define MAX_7(a,...)    MAX_2(a,MAX_6(__VA_ARGS__))
323
+  #define MAX_8(a,...)    MAX_2(a,MAX_7(__VA_ARGS__))
324
+  #define MAX_9(a,...)    MAX_2(a,MAX_8(__VA_ARGS__))
325
+  #define MAX_10(a,...)   MAX_2(a,MAX_9(__VA_ARGS__))
326
+  #define __MAX_N(N, ...) MAX_##N(__VA_ARGS__)
327
+  #define _MAX_N(N, ...)  __MAX_N(N,__VA_ARGS__)
328
+  #define _MAX(...)       _MAX_N(NUM_ARGS(__VA_ARGS__), __VA_ARGS__)
329
+
330
+#endif

+ 0
- 77
Marlin/src/core/minmax.h 查看文件

1
-/**
2
- * Marlin 3D Printer Firmware
3
- * Copyright (c) 2019 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
-#pragma once
23
-
24
-// Use NUM_ARGS(__VA_ARGS__) to get the number of variadic arguments
25
-#define _NUM_ARGS(_0,_24_,_23,_22,_21,_20,_19,_18,_17,_16,_15,_14,_13,_12,_11,_10,_9,_8,_7,_6,_5,_4,_3,_2,_1,N,...) N
26
-#define NUM_ARGS(V...) _NUM_ARGS(0,V,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
27
-
28
-#ifdef __cplusplus
29
-
30
-  #ifndef _MINMAX_H_
31
-  #define _MINMAX_H_
32
-
33
-    extern "C++" {
34
-
35
-      // C++11 solution that is standards compliant. Return type is deduced automatically
36
-      template <class L, class R> static inline constexpr auto _MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
37
-        return lhs < rhs ? lhs : rhs;
38
-      }
39
-      template <class L, class R> static inline constexpr auto _MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) {
40
-        return lhs > rhs ? lhs : rhs;
41
-      }
42
-      template<class T, class ... Ts> static inline constexpr const T _MIN(T V, Ts... Vs) { return _MIN(V, _MIN(Vs...)); }
43
-      template<class T, class ... Ts> static inline constexpr const T _MAX(T V, Ts... Vs) { return _MAX(V, _MAX(Vs...)); }
44
-
45
-    }
46
-
47
-  #endif
48
-
49
-#else
50
-
51
-  #define MIN_2(a,b)      ((a)<(b)?(a):(b))
52
-  #define MIN_3(a,...)    MIN_2(a,MIN_2(__VA_ARGS__))
53
-  #define MIN_4(a,...)    MIN_2(a,MIN_3(__VA_ARGS__))
54
-  #define MIN_5(a,...)    MIN_2(a,MIN_4(__VA_ARGS__))
55
-  #define MIN_6(a,...)    MIN_2(a,MIN_5(__VA_ARGS__))
56
-  #define MIN_7(a,...)    MIN_2(a,MIN_6(__VA_ARGS__))
57
-  #define MIN_8(a,...)    MIN_2(a,MIN_7(__VA_ARGS__))
58
-  #define MIN_9(a,...)    MIN_2(a,MIN_8(__VA_ARGS__))
59
-  #define MIN_10(a,...)   MIN_2(a,MIN_9(__VA_ARGS__))
60
-  #define __MIN_N(N, ...) MIN_##N(__VA_ARGS__)
61
-  #define _MIN_N(N, ...)  __MIN_N(N,__VA_ARGS__)
62
-  #define MIN(...)        _MIN_N(NUM_ARGS(__VA_ARGS__), __VA_ARGS__)
63
-
64
-  #define MAX_2(a,b)      ((a)>(b)?(a):(b))
65
-  #define MAX_3(a,...)    MAX_2(a,MAX_2(__VA_ARGS__))
66
-  #define MAX_4(a,...)    MAX_2(a,MAX_3(__VA_ARGS__))
67
-  #define MAX_5(a,...)    MAX_2(a,MAX_4(__VA_ARGS__))
68
-  #define MAX_6(a,...)    MAX_2(a,MAX_5(__VA_ARGS__))
69
-  #define MAX_7(a,...)    MAX_2(a,MAX_6(__VA_ARGS__))
70
-  #define MAX_8(a,...)    MAX_2(a,MAX_7(__VA_ARGS__))
71
-  #define MAX_9(a,...)    MAX_2(a,MAX_8(__VA_ARGS__))
72
-  #define MAX_10(a,...)   MAX_2(a,MAX_9(__VA_ARGS__))
73
-  #define __MAX_N(N, ...) MAX_##N(__VA_ARGS__)
74
-  #define _MAX_N(N, ...)  __MAX_N(N,__VA_ARGS__)
75
-  #define MAX(...)        _MAX_N(NUM_ARGS(__VA_ARGS__), __VA_ARGS__)
76
-
77
-#endif

+ 6
- 3
Marlin/src/core/serial.h 查看文件

21
  */
21
  */
22
 #pragma once
22
 #pragma once
23
 
23
 
24
-#include "../inc/MarlinConfigPre.h"
25
-#include "../core/minmax.h"
26
-#include HAL_PATH(../HAL, HAL.h)
24
+//#include <stdint.h>
25
+
26
+//#include "../inc/MarlinConfigPre.h"
27
+#include "../HAL/HAL.h"
28
+
29
+// #include "../core/macros.h"
27
 
30
 
28
 /**
31
 /**
29
  * Define debug bit-masks
32
  * Define debug bit-masks

+ 1
- 6
Marlin/src/inc/MarlinConfig.h 查看文件

27
 
27
 
28
 #include "MarlinConfigPre.h"
28
 #include "MarlinConfigPre.h"
29
 
29
 
30
-#include HAL_PATH(../HAL, HAL.h)
30
+#include "../HAL/HAL.h"
31
 
31
 
32
 #include "../pins/pins.h"
32
 #include "../pins/pins.h"
33
 
33
 
34
 #include HAL_PATH(../HAL, spi_pins.h)
34
 #include HAL_PATH(../HAL, spi_pins.h)
35
 
35
 
36
-#if defined(__AVR__) && !defined(USBCON)
37
-  #define HardwareSerial_h // trick to disable the standard HWserial
38
-#endif
39
-
40
 #include "Conditionals_post.h"
36
 #include "Conditionals_post.h"
41
 #include "SanityCheck.h"
37
 #include "SanityCheck.h"
42
 
38
 
47
 #include "../core/language.h"
43
 #include "../core/language.h"
48
 #include "../core/utility.h"
44
 #include "../core/utility.h"
49
 #include "../core/serial.h"
45
 #include "../core/serial.h"
50
-#include "../core/minmax.h"

+ 0
- 1
Marlin/src/inc/MarlinConfigPre.h 查看文件

27
 // Prefix header to acquire configurations
27
 // Prefix header to acquire configurations
28
 //
28
 //
29
 
29
 
30
-#include "../HAL/platforms.h"
31
 #include "../core/boards.h"
30
 #include "../core/boards.h"
32
 #include "../core/macros.h"
31
 #include "../core/macros.h"
33
 #include "../core/millis_t.h"
32
 #include "../core/millis_t.h"

+ 4
- 3
Marlin/src/pins/pinsDebug.h 查看文件

17
  *
17
  *
18
  */
18
  */
19
 
19
 
20
+#include "../inc/MarlinConfig.h"
21
+
20
 #define MAX_NAME_LENGTH  39    // one place to specify the format of all the sources of names
22
 #define MAX_NAME_LENGTH  39    // one place to specify the format of all the sources of names
21
                                // "-" left justify, "39" minimum width of name, pad with blanks
23
                                // "-" left justify, "39" minimum width of name, pad with blanks
22
 
24
 
40
 #define REPORT_NAME_ANALOG(COUNTER, NAME) _ADD_PIN(#NAME, COUNTER)
42
 #define REPORT_NAME_ANALOG(COUNTER, NAME) _ADD_PIN(#NAME, COUNTER)
41
 
43
 
42
 #include "pinsDebug_list.h"
44
 #include "pinsDebug_list.h"
43
-#line 47
45
+#line 46
44
 
46
 
45
 // manually add pins that have names that are macros which don't play well with these macros
47
 // manually add pins that have names that are macros which don't play well with these macros
46
 #if SERIAL_PORT == 0 && (AVR_ATmega2560_FAMILY || AVR_ATmega1284_FAMILY || defined(ARDUINO_ARCH_SAM))
48
 #if SERIAL_PORT == 0 && (AVR_ATmega2560_FAMILY || AVR_ATmega1284_FAMILY || defined(ARDUINO_ARCH_SAM))
92
   #endif
94
   #endif
93
 
95
 
94
   #include "pinsDebug_list.h"
96
   #include "pinsDebug_list.h"
95
-  #line 99
97
+  #line 98
96
 
98
 
97
 };
99
 };
98
 
100
 
99
-
100
 #include HAL_PATH(../HAL, pinsDebug.h)  // get the correct support file for this CPU
101
 #include HAL_PATH(../HAL, pinsDebug.h)  // get the correct support file for this CPU
101
 
102
 
102
 #ifndef M43_NEVER_TOUCH
103
 #ifndef M43_NEVER_TOUCH

+ 1
- 1
Marlin/src/pins/pinsDebug_list.h 查看文件

24
 
24
 
25
 // Pin lists 1.1.x and 2.0.x synchronized 2018-02-17
25
 // Pin lists 1.1.x and 2.0.x synchronized 2018-02-17
26
 
26
 
27
-#line 31 // set __LINE__ to a known value for both passes
27
+#line 28 // set __LINE__ to a known value for both passes
28
 
28
 
29
 //
29
 //
30
 // Analog Pin Assignments
30
 // Analog Pin Assignments

+ 1
- 1
Marlin/src/pins/pins_BIGTREE_SKR_V1.3.h 查看文件

115
 #endif
115
 #endif
116
 
116
 
117
 #if HAS_TMC220x
117
 #if HAS_TMC220x
118
-    /**
118
+  /**
119
    * TMC2208/TMC2209 stepper drivers
119
    * TMC2208/TMC2209 stepper drivers
120
    *
120
    *
121
    * Hardware serial communication ports.
121
    * Hardware serial communication ports.

+ 4
- 1
Marlin/src/sd/SdVolume.h 查看文件

33
  * This file is part of the Arduino Sd2Card Library
33
  * This file is part of the Arduino Sd2Card Library
34
  */
34
  */
35
 
35
 
36
+#include <stdint.h>
37
+
38
+#include "../inc/MarlinConfigPre.h"
39
+
36
 #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
40
 #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
37
   #include "usb_flashdrive/Sd2Card_FlashDrive.h"
41
   #include "usb_flashdrive/Sd2Card_FlashDrive.h"
38
 #elif ENABLED(SDIO_SUPPORT)
42
 #elif ENABLED(SDIO_SUPPORT)
43
 
47
 
44
 #include "SdFatConfig.h"
48
 #include "SdFatConfig.h"
45
 #include "SdFatStructs.h"
49
 #include "SdFatStructs.h"
46
-#include <stdint.h>
47
 
50
 
48
 //==============================================================================
51
 //==============================================================================
49
 // SdVolume class
52
 // SdVolume class

正在加载...
取消
保存