🎨 CONF_SERIAL_IS => SERIAL_IN_USE

This commit is contained in:
Scott Lahteine 2022-10-17 21:41:22 -05:00
parent 485fb77596
commit 2e2abbcb48
5 changed files with 30 additions and 28 deletions

View File

@ -37,22 +37,22 @@
|| X_ENA_PIN == N || Y_ENA_PIN == N || Z_ENA_PIN == N \ || X_ENA_PIN == N || Y_ENA_PIN == N || Z_ENA_PIN == N \
|| BTN_EN1 == N || BTN_EN2 == N \ || BTN_EN1 == N || BTN_EN2 == N \
) )
#if CONF_SERIAL_IS(0) #if SERIAL_IN_USE(0)
// D0-D1. No known conflicts. // D0-D1. No known conflicts.
#endif #endif
#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__) #if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__)
#if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19)) #if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19))
#error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board." #error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board."
#endif #endif
#else #else
#if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11)) #if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11))
#error "Serial Port 1 pin D10 and/or D11 conflicts with another pin on the board." #error "Serial Port 1 pin D10 and/or D11 conflicts with another pin on the board."
#endif #endif
#endif #endif
#if CONF_SERIAL_IS(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17)) #if SERIAL_IN_USE(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17))
#error "Serial Port 2 pin D16 and/or D17 conflicts with another pin on the board." #error "Serial Port 2 pin D16 and/or D17 conflicts with another pin on the board."
#endif #endif
#if CONF_SERIAL_IS(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15)) #if SERIAL_IN_USE(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15))
#error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board." #error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board."
#endif #endif
#undef CHECK_SERIAL_PIN #undef CHECK_SERIAL_PIN

View File

@ -36,15 +36,15 @@
|| X_DIR_PIN == N || Y_DIR_PIN == N || Z_DIR_PIN == N \ || X_DIR_PIN == N || Y_DIR_PIN == N || Z_DIR_PIN == N \
|| X_ENA_PIN == N || Y_ENA_PIN == N || Z_ENA_PIN == N \ || X_ENA_PIN == N || Y_ENA_PIN == N || Z_ENA_PIN == N \
) )
#if CONF_SERIAL_IS(0) // D0-D1. No known conflicts. #if SERIAL_IN_USE(0) // D0-D1. No known conflicts.
#endif #endif
#if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19)) #if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19))
#error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board." #error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board."
#endif #endif
#if CONF_SERIAL_IS(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17)) #if SERIAL_IN_USE(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17))
#error "Serial Port 2 pin D16 and/or D17 conflicts with another pin on the board." #error "Serial Port 2 pin D16 and/or D17 conflicts with another pin on the board."
#endif #endif
#if CONF_SERIAL_IS(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15)) #if SERIAL_IN_USE(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15))
#error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board." #error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board."
#endif #endif
#undef CHECK_SERIAL_PIN #undef CHECK_SERIAL_PIN

View File

@ -95,7 +95,7 @@
static_assert(IS_FLASH_SECTOR(FLASH_SECTOR), "FLASH_SECTOR is invalid"); static_assert(IS_FLASH_SECTOR(FLASH_SECTOR), "FLASH_SECTOR is invalid");
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"); 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");
#endif #endif // FLASH_EEPROM_LEVELING
static bool eeprom_data_written = false; static bool eeprom_data_written = false;
@ -189,15 +189,15 @@ bool PersistentStore::access_finish() {
UNLOCK_FLASH(); UNLOCK_FLASH();
uint32_t offset = 0; uint32_t offset = 0,
uint32_t address = SLOT_ADDRESS(current_slot); address = SLOT_ADDRESS(current_slot),
uint32_t address_end = address + MARLIN_EEPROM_SIZE; address_end = address + MARLIN_EEPROM_SIZE,
uint32_t data = 0; data = 0;
bool success = true; bool success = true;
while (address < address_end) { while (address < address_end) {
memcpy(&data, ram_eeprom + offset, sizeof(uint32_t)); memcpy(&data, ram_eeprom + offset, sizeof(data));
status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, address, data); status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, address, data);
if (status == HAL_OK) { if (status == HAL_OK) {
address += sizeof(uint32_t); address += sizeof(uint32_t);
@ -221,7 +221,8 @@ bool PersistentStore::access_finish() {
return success; return success;
#else #else // !FLASH_EEPROM_LEVELING
// The following was written for the STM32F4 but may work with other MCUs as well. // The following was written for the STM32F4 but may work with other MCUs as well.
// Most STM32F4 flash does not allow reading from flash during erase operations. // Most STM32F4 flash does not allow reading from flash during erase operations.
// This takes about a second on a STM32F407 with a 128kB sector used as EEPROM. // This takes about a second on a STM32F407 with a 128kB sector used as EEPROM.
@ -235,7 +236,8 @@ bool PersistentStore::access_finish() {
TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT()); TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT());
eeprom_data_written = false; eeprom_data_written = false;
#endif
#endif // !FLASH_EEPROM_LEVELING
} }
return true; return true;

View File

@ -2446,7 +2446,7 @@
// //
// Flag the indexed hardware serial ports in use // Flag the indexed hardware serial ports in use
#define CONF_SERIAL_IS(N) ( (defined(SERIAL_PORT) && SERIAL_PORT == N) \ #define SERIAL_IN_USE(N) ( (defined(SERIAL_PORT) && SERIAL_PORT == N) \
|| (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == N) \ || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == N) \
|| (defined(SERIAL_PORT_3) && SERIAL_PORT_3 == N) \ || (defined(SERIAL_PORT_3) && SERIAL_PORT_3 == N) \
|| (defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == N) \ || (defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == N) \
@ -2454,7 +2454,7 @@
// Flag the named hardware serial ports in use // Flag the named hardware serial ports in use
#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)) #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))
#define ANY_SERIAL_IS(N) ( CONF_SERIAL_IS(N) \ #define ANY_SERIAL_IS(N) ( SERIAL_IN_USE(N) \
|| TMC_UART_IS(X, N) || TMC_UART_IS(Y , N) || TMC_UART_IS(Z , N) \ || TMC_UART_IS(X, N) || TMC_UART_IS(Y , N) || TMC_UART_IS(Z , N) \
|| TMC_UART_IS(I, N) || TMC_UART_IS(J , N) || TMC_UART_IS(K , N) \ || TMC_UART_IS(I, N) || TMC_UART_IS(J , N) || TMC_UART_IS(K , N) \
|| TMC_UART_IS(U, N) || TMC_UART_IS(V , N) || TMC_UART_IS(W , N) \ || TMC_UART_IS(U, N) || TMC_UART_IS(V , N) || TMC_UART_IS(W , N) \
@ -2481,7 +2481,7 @@
#define HW_MSerial9 518 #define HW_MSerial9 518
#define HW_MSerial10 519 #define HW_MSerial10 519
#if CONF_SERIAL_IS(-1) #if SERIAL_IN_USE(-1)
#define USING_HW_SERIALUSB 1 #define USING_HW_SERIALUSB 1
#endif #endif
#if ANY_SERIAL_IS(0) #if ANY_SERIAL_IS(0)

View File

@ -49,19 +49,19 @@
// manually add pins that have names that are macros which don't play well with these macros // manually add pins that have names that are macros which don't play well with these macros
#if ANY(AVR_ATmega2560_FAMILY, AVR_ATmega1284_FAMILY, ARDUINO_ARCH_SAM, TARGET_LPC1768) #if ANY(AVR_ATmega2560_FAMILY, AVR_ATmega1284_FAMILY, ARDUINO_ARCH_SAM, TARGET_LPC1768)
#if CONF_SERIAL_IS(0) #if SERIAL_IN_USE(0)
static const char RXD_NAME_0[] PROGMEM = { "RXD0" }; static const char RXD_NAME_0[] PROGMEM = { "RXD0" };
static const char TXD_NAME_0[] PROGMEM = { "TXD0" }; static const char TXD_NAME_0[] PROGMEM = { "TXD0" };
#endif #endif
#if CONF_SERIAL_IS(1) #if SERIAL_IN_USE(1)
static const char RXD_NAME_1[] PROGMEM = { "RXD1" }; static const char RXD_NAME_1[] PROGMEM = { "RXD1" };
static const char TXD_NAME_1[] PROGMEM = { "TXD1" }; static const char TXD_NAME_1[] PROGMEM = { "TXD1" };
#endif #endif
#if CONF_SERIAL_IS(2) #if SERIAL_IN_USE(2)
static const char RXD_NAME_2[] PROGMEM = { "RXD2" }; static const char RXD_NAME_2[] PROGMEM = { "RXD2" };
static const char TXD_NAME_2[] PROGMEM = { "TXD2" }; static const char TXD_NAME_2[] PROGMEM = { "TXD2" };
#endif #endif
#if CONF_SERIAL_IS(3) #if SERIAL_IN_USE(3)
static const char RXD_NAME_3[] PROGMEM = { "RXD3" }; static const char RXD_NAME_3[] PROGMEM = { "RXD3" };
static const char TXD_NAME_3[] PROGMEM = { "TXD3" }; static const char TXD_NAME_3[] PROGMEM = { "TXD3" };
#endif #endif
@ -99,7 +99,7 @@ const PinInfo pin_array[] PROGMEM = {
* 2 bytes containing the digital/analog bool flag * 2 bytes containing the digital/analog bool flag
*/ */
#if CONF_SERIAL_IS(0) #if SERIAL_IN_USE(0)
#if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
{ RXD_NAME_0, 0, true }, { RXD_NAME_0, 0, true },
{ TXD_NAME_0, 1, true }, { TXD_NAME_0, 1, true },
@ -112,7 +112,7 @@ const PinInfo pin_array[] PROGMEM = {
#endif #endif
#endif #endif
#if CONF_SERIAL_IS(1) #if SERIAL_IN_USE(1)
#if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
{ RXD_NAME_1, 19, true }, { RXD_NAME_1, 19, true },
{ TXD_NAME_1, 18, true }, { TXD_NAME_1, 18, true },
@ -130,7 +130,7 @@ const PinInfo pin_array[] PROGMEM = {
#endif #endif
#endif #endif
#if CONF_SERIAL_IS(2) #if SERIAL_IN_USE(2)
#if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
{ RXD_NAME_2, 17, true }, { RXD_NAME_2, 17, true },
{ TXD_NAME_2, 16, true }, { TXD_NAME_2, 16, true },
@ -145,7 +145,7 @@ const PinInfo pin_array[] PROGMEM = {
#endif #endif
#endif #endif
#if CONF_SERIAL_IS(3) #if SERIAL_IN_USE(3)
#if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
{ RXD_NAME_3, 15, true }, { RXD_NAME_3, 15, true },
{ TXD_NAME_3, 14, true }, { TXD_NAME_3, 14, true },