Browse Source

HAL include and other adjustments (#14525)

Scott Lahteine 4 years ago
parent
commit
a2ba0aaaac
No account linked to committer's email address

Marlin/src/HAL/platforms.h → Marlin/src/HAL/HAL.h View File

@@ -50,3 +50,5 @@
50 50
 #define XSTR_(M) #M
51 51
 #define XSTR(M) XSTR_(M)
52 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 View File

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

+ 0
- 1
Marlin/src/HAL/HAL_AVR/MarlinSerial.h View File

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

+ 0
- 1
Marlin/src/HAL/HAL_AVR/endstop_interrupts.h View File

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

+ 2
- 0
Marlin/src/HAL/HAL_DUE/fastio_Due.h View File

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

+ 1
- 1
Marlin/src/HAL/HAL_LPC1768/HAL.h View File

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

+ 2
- 0
Marlin/src/HAL/HAL_STM32F1/HAL_sdio_STM32F1.cpp View File

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

+ 19
- 1
Marlin/src/HAL/HAL_TEENSY31_32/persistent_store_impl.cpp View File

@@ -1,10 +1,28 @@
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 19
 #ifdef __MK20DX256__
2 20
 
3 21
 #include "../../inc/MarlinConfig.h"
4 22
 
5 23
 #if ENABLED(EEPROM_SETTINGS)
6 24
 
7
-#include "../persistent_store_api.h"
25
+#include "../shared/persistent_store_api.h"
8 26
 
9 27
 namespace HAL {
10 28
 namespace PersistentStore {

+ 1
- 1
Marlin/src/HAL/shared/I2cEeprom.cpp View File

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

+ 1
- 1
Marlin/src/HAL/shared/SpiEeprom.cpp View File

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

+ 63
- 4
Marlin/src/core/macros.h View File

@@ -21,8 +21,6 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-#include "minmax.h"
25
-
26 24
 #define NUM_AXIS 4
27 25
 #define ABCE 4
28 26
 #define XYZE 4
@@ -75,10 +73,16 @@
75 73
 #undef _BV
76 74
 #define _BV(n) (1<<(n))
77 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 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 86
 #define _BV32(b) (1UL << (b))
83 87
 #define TEST32(n,b) !!((n)&_BV32(b))
84 88
 #define SBI32(n,b) (n |= _BV32(b))
@@ -269,3 +273,58 @@
269 273
 #else
270 274
   #define I2C_ADDRESS(A) A
271 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 View File

@@ -1,77 +0,0 @@
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 View File

@@ -21,9 +21,12 @@
21 21
  */
22 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 32
  * Define debug bit-masks

+ 1
- 6
Marlin/src/inc/MarlinConfig.h View File

@@ -27,16 +27,12 @@
27 27
 
28 28
 #include "MarlinConfigPre.h"
29 29
 
30
-#include HAL_PATH(../HAL, HAL.h)
30
+#include "../HAL/HAL.h"
31 31
 
32 32
 #include "../pins/pins.h"
33 33
 
34 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 36
 #include "Conditionals_post.h"
41 37
 #include "SanityCheck.h"
42 38
 
@@ -47,4 +43,3 @@
47 43
 #include "../core/language.h"
48 44
 #include "../core/utility.h"
49 45
 #include "../core/serial.h"
50
-#include "../core/minmax.h"

+ 0
- 1
Marlin/src/inc/MarlinConfigPre.h View File

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

+ 4
- 3
Marlin/src/pins/pinsDebug.h View File

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

+ 1
- 1
Marlin/src/pins/pinsDebug_list.h View File

@@ -24,7 +24,7 @@
24 24
 
25 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 30
 // Analog Pin Assignments

+ 1
- 1
Marlin/src/pins/pins_BIGTREE_SKR_V1.3.h View File

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

+ 4
- 1
Marlin/src/sd/SdVolume.h View File

@@ -33,6 +33,10 @@
33 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 40
 #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
37 41
   #include "usb_flashdrive/Sd2Card_FlashDrive.h"
38 42
 #elif ENABLED(SDIO_SUPPORT)
@@ -43,7 +47,6 @@
43 47
 
44 48
 #include "SdFatConfig.h"
45 49
 #include "SdFatStructs.h"
46
-#include <stdint.h>
47 50
 
48 51
 //==============================================================================
49 52
 // SdVolume class

Loading…
Cancel
Save