Browse Source

🎨 CONF_SERIAL_IS => SERIAL_IN_USE

Scott Lahteine 1 year ago
parent
commit
e298266eff

+ 5
- 5
Marlin/src/HAL/AVR/inc/SanityCheck.h View File

37
   || X_ENA_PIN  == N || Y_ENA_PIN  == N || Z_ENA_PIN  == N \
37
   || X_ENA_PIN  == N || Y_ENA_PIN  == N || Z_ENA_PIN  == N \
38
   || BTN_EN1    == N || BTN_EN2    == N \
38
   || BTN_EN1    == N || BTN_EN2    == N \
39
 )
39
 )
40
-#if CONF_SERIAL_IS(0)
40
+#if SERIAL_IN_USE(0)
41
   // D0-D1. No known conflicts.
41
   // D0-D1. No known conflicts.
42
 #endif
42
 #endif
43
 #if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__)
43
 #if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__)
44
-  #if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19))
44
+  #if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19))
45
     #error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board."
45
     #error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board."
46
   #endif
46
   #endif
47
 #else
47
 #else
48
-  #if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11))
48
+  #if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11))
49
     #error "Serial Port 1 pin D10 and/or D11 conflicts with another pin on the board."
49
     #error "Serial Port 1 pin D10 and/or D11 conflicts with another pin on the board."
50
   #endif
50
   #endif
51
 #endif
51
 #endif
52
-#if CONF_SERIAL_IS(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17))
52
+#if SERIAL_IN_USE(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17))
53
   #error "Serial Port 2 pin D16 and/or D17 conflicts with another pin on the board."
53
   #error "Serial Port 2 pin D16 and/or D17 conflicts with another pin on the board."
54
 #endif
54
 #endif
55
-#if CONF_SERIAL_IS(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15))
55
+#if SERIAL_IN_USE(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15))
56
   #error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board."
56
   #error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board."
57
 #endif
57
 #endif
58
 #undef CHECK_SERIAL_PIN
58
 #undef CHECK_SERIAL_PIN

+ 4
- 4
Marlin/src/HAL/DUE/inc/SanityCheck.h View File

36
   || X_DIR_PIN  == N || Y_DIR_PIN  == N || Z_DIR_PIN  == N \
36
   || X_DIR_PIN  == N || Y_DIR_PIN  == N || Z_DIR_PIN  == N \
37
   || X_ENA_PIN  == N || Y_ENA_PIN  == N || Z_ENA_PIN  == N \
37
   || X_ENA_PIN  == N || Y_ENA_PIN  == N || Z_ENA_PIN  == N \
38
 )
38
 )
39
-#if CONF_SERIAL_IS(0) // D0-D1. No known conflicts.
39
+#if SERIAL_IN_USE(0) // D0-D1. No known conflicts.
40
 #endif
40
 #endif
41
-#if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19))
41
+#if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19))
42
   #error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board."
42
   #error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board."
43
 #endif
43
 #endif
44
-#if CONF_SERIAL_IS(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17))
44
+#if SERIAL_IN_USE(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17))
45
   #error "Serial Port 2 pin D16 and/or D17 conflicts with another pin on the board."
45
   #error "Serial Port 2 pin D16 and/or D17 conflicts with another pin on the board."
46
 #endif
46
 #endif
47
-#if CONF_SERIAL_IS(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15))
47
+#if SERIAL_IN_USE(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15))
48
   #error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board."
48
   #error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board."
49
 #endif
49
 #endif
50
 #undef CHECK_SERIAL_PIN
50
 #undef CHECK_SERIAL_PIN

+ 10
- 8
Marlin/src/HAL/STM32/eeprom_flash.cpp View File

95
   static_assert(IS_FLASH_SECTOR(FLASH_SECTOR), "FLASH_SECTOR is invalid");
95
   static_assert(IS_FLASH_SECTOR(FLASH_SECTOR), "FLASH_SECTOR is invalid");
96
   static_assert(IS_POWER_OF_2(FLASH_UNIT_SIZE), "FLASH_UNIT_SIZE should be a power of 2, please check your chip's spec sheet");
96
   static_assert(IS_POWER_OF_2(FLASH_UNIT_SIZE), "FLASH_UNIT_SIZE should be a power of 2, please check your chip's spec sheet");
97
 
97
 
98
-#endif
98
+#endif // FLASH_EEPROM_LEVELING
99
 
99
 
100
 static bool eeprom_data_written = false;
100
 static bool eeprom_data_written = false;
101
 
101
 
189
 
189
 
190
       UNLOCK_FLASH();
190
       UNLOCK_FLASH();
191
 
191
 
192
-      uint32_t offset = 0;
193
-      uint32_t address = SLOT_ADDRESS(current_slot);
194
-      uint32_t address_end = address + MARLIN_EEPROM_SIZE;
195
-      uint32_t data = 0;
192
+      uint32_t offset = 0,
193
+               address = SLOT_ADDRESS(current_slot),
194
+               address_end = address + MARLIN_EEPROM_SIZE,
195
+               data = 0;
196
 
196
 
197
       bool success = true;
197
       bool success = true;
198
 
198
 
199
       while (address < address_end) {
199
       while (address < address_end) {
200
-        memcpy(&data, ram_eeprom + offset, sizeof(uint32_t));
200
+        memcpy(&data, ram_eeprom + offset, sizeof(data));
201
         status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, address, data);
201
         status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, address, data);
202
         if (status == HAL_OK) {
202
         if (status == HAL_OK) {
203
           address += sizeof(uint32_t);
203
           address += sizeof(uint32_t);
221
 
221
 
222
       return success;
222
       return success;
223
 
223
 
224
-    #else
224
+    #else !FLASH_EEPROM_LEVELING
225
+
225
       // The following was written for the STM32F4 but may work with other MCUs as well.
226
       // The following was written for the STM32F4 but may work with other MCUs as well.
226
       // Most STM32F4 flash does not allow reading from flash during erase operations.
227
       // Most STM32F4 flash does not allow reading from flash during erase operations.
227
       // This takes about a second on a STM32F407 with a 128kB sector used as EEPROM.
228
       // This takes about a second on a STM32F407 with a 128kB sector used as EEPROM.
235
       TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT());
236
       TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT());
236
 
237
 
237
       eeprom_data_written = false;
238
       eeprom_data_written = false;
238
-    #endif
239
+
240
+    #endif // !FLASH_EEPROM_LEVELING
239
   }
241
   }
240
 
242
 
241
   return true;
243
   return true;

+ 3
- 3
Marlin/src/inc/Conditionals_post.h View File

2446
 //
2446
 //
2447
 
2447
 
2448
 // Flag the indexed hardware serial ports in use
2448
 // Flag the indexed hardware serial ports in use
2449
-#define CONF_SERIAL_IS(N) (  (defined(SERIAL_PORT)      && SERIAL_PORT == N) \
2449
+#define SERIAL_IN_USE(N) (  (defined(SERIAL_PORT)      && SERIAL_PORT == N) \
2450
                           || (defined(SERIAL_PORT_2)    && SERIAL_PORT_2 == N) \
2450
                           || (defined(SERIAL_PORT_2)    && SERIAL_PORT_2 == N) \
2451
                           || (defined(SERIAL_PORT_3)    && SERIAL_PORT_3 == N) \
2451
                           || (defined(SERIAL_PORT_3)    && SERIAL_PORT_3 == N) \
2452
                           || (defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == N) \
2452
                           || (defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == N) \
2454
 
2454
 
2455
 // Flag the named hardware serial ports in use
2455
 // Flag the named hardware serial ports in use
2456
 #define TMC_UART_IS(A,N) (defined(A##_HARDWARE_SERIAL) && (CAT(HW_,A##_HARDWARE_SERIAL) == HW_Serial##N || CAT(HW_,A##_HARDWARE_SERIAL) == HW_MSerial##N))
2456
 #define TMC_UART_IS(A,N) (defined(A##_HARDWARE_SERIAL) && (CAT(HW_,A##_HARDWARE_SERIAL) == HW_Serial##N || CAT(HW_,A##_HARDWARE_SERIAL) == HW_MSerial##N))
2457
-#define ANY_SERIAL_IS(N) (  CONF_SERIAL_IS(N) \
2457
+#define ANY_SERIAL_IS(N) (  SERIAL_IN_USE(N) \
2458
                          || TMC_UART_IS(X,  N) || TMC_UART_IS(Y , N) || TMC_UART_IS(Z , N) \
2458
                          || TMC_UART_IS(X,  N) || TMC_UART_IS(Y , N) || TMC_UART_IS(Z , N) \
2459
                          || TMC_UART_IS(I,  N) || TMC_UART_IS(J , N) || TMC_UART_IS(K , N) \
2459
                          || TMC_UART_IS(I,  N) || TMC_UART_IS(J , N) || TMC_UART_IS(K , N) \
2460
                          || TMC_UART_IS(U,  N) || TMC_UART_IS(V , N) || TMC_UART_IS(W , N) \
2460
                          || TMC_UART_IS(U,  N) || TMC_UART_IS(V , N) || TMC_UART_IS(W , N) \
2481
 #define HW_MSerial9  518
2481
 #define HW_MSerial9  518
2482
 #define HW_MSerial10 519
2482
 #define HW_MSerial10 519
2483
 
2483
 
2484
-#if CONF_SERIAL_IS(-1)
2484
+#if SERIAL_IN_USE(-1)
2485
   #define USING_HW_SERIALUSB 1
2485
   #define USING_HW_SERIALUSB 1
2486
 #endif
2486
 #endif
2487
 #if ANY_SERIAL_IS(0)
2487
 #if ANY_SERIAL_IS(0)

+ 8
- 8
Marlin/src/pins/pinsDebug.h View File

49
 
49
 
50
 // manually add pins that have names that are macros which don't play well with these macros
50
 // manually add pins that have names that are macros which don't play well with these macros
51
 #if ANY(AVR_ATmega2560_FAMILY, AVR_ATmega1284_FAMILY, ARDUINO_ARCH_SAM, TARGET_LPC1768)
51
 #if ANY(AVR_ATmega2560_FAMILY, AVR_ATmega1284_FAMILY, ARDUINO_ARCH_SAM, TARGET_LPC1768)
52
-  #if CONF_SERIAL_IS(0)
52
+  #if SERIAL_IN_USE(0)
53
     static const char RXD_NAME_0[] PROGMEM = { "RXD0" };
53
     static const char RXD_NAME_0[] PROGMEM = { "RXD0" };
54
     static const char TXD_NAME_0[] PROGMEM = { "TXD0" };
54
     static const char TXD_NAME_0[] PROGMEM = { "TXD0" };
55
   #endif
55
   #endif
56
-  #if CONF_SERIAL_IS(1)
56
+  #if SERIAL_IN_USE(1)
57
     static const char RXD_NAME_1[] PROGMEM = { "RXD1" };
57
     static const char RXD_NAME_1[] PROGMEM = { "RXD1" };
58
     static const char TXD_NAME_1[] PROGMEM = { "TXD1" };
58
     static const char TXD_NAME_1[] PROGMEM = { "TXD1" };
59
   #endif
59
   #endif
60
-  #if CONF_SERIAL_IS(2)
60
+  #if SERIAL_IN_USE(2)
61
     static const char RXD_NAME_2[] PROGMEM = { "RXD2" };
61
     static const char RXD_NAME_2[] PROGMEM = { "RXD2" };
62
     static const char TXD_NAME_2[] PROGMEM = { "TXD2" };
62
     static const char TXD_NAME_2[] PROGMEM = { "TXD2" };
63
   #endif
63
   #endif
64
-  #if CONF_SERIAL_IS(3)
64
+  #if SERIAL_IN_USE(3)
65
     static const char RXD_NAME_3[] PROGMEM = { "RXD3" };
65
     static const char RXD_NAME_3[] PROGMEM = { "RXD3" };
66
     static const char TXD_NAME_3[] PROGMEM = { "TXD3" };
66
     static const char TXD_NAME_3[] PROGMEM = { "TXD3" };
67
   #endif
67
   #endif
99
    *     2 bytes containing the digital/analog bool flag
99
    *     2 bytes containing the digital/analog bool flag
100
    */
100
    */
101
 
101
 
102
-  #if CONF_SERIAL_IS(0)
102
+  #if SERIAL_IN_USE(0)
103
     #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
103
     #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
104
       { RXD_NAME_0, 0, true },
104
       { RXD_NAME_0, 0, true },
105
       { TXD_NAME_0, 1, true },
105
       { TXD_NAME_0, 1, true },
112
     #endif
112
     #endif
113
   #endif
113
   #endif
114
 
114
 
115
-  #if CONF_SERIAL_IS(1)
115
+  #if SERIAL_IN_USE(1)
116
     #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
116
     #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
117
       { RXD_NAME_1, 19, true },
117
       { RXD_NAME_1, 19, true },
118
       { TXD_NAME_1, 18, true },
118
       { TXD_NAME_1, 18, true },
130
     #endif
130
     #endif
131
   #endif
131
   #endif
132
 
132
 
133
-  #if CONF_SERIAL_IS(2)
133
+  #if SERIAL_IN_USE(2)
134
     #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
134
     #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
135
       { RXD_NAME_2, 17, true },
135
       { RXD_NAME_2, 17, true },
136
       { TXD_NAME_2, 16, true },
136
       { TXD_NAME_2, 16, true },
145
     #endif
145
     #endif
146
   #endif
146
   #endif
147
 
147
 
148
-  #if CONF_SERIAL_IS(3)
148
+  #if SERIAL_IN_USE(3)
149
     #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
149
     #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
150
       { RXD_NAME_3, 15, true },
150
       { RXD_NAME_3, 15, true },
151
       { TXD_NAME_3, 14, true },
151
       { TXD_NAME_3, 14, true },

Loading…
Cancel
Save