Simplify TMC sanity-checks

This commit is contained in:
Scott Lahteine 2018-11-02 01:06:06 -05:00
parent f5b31e218d
commit 3eb9838dca
2 changed files with 45 additions and 41 deletions

View File

@ -32,7 +32,7 @@
#if ENABLED(MONITOR_DRIVER_STATUS) #if ENABLED(MONITOR_DRIVER_STATUS)
#define M91x_USE(ST) (AXIS_DRIVER_TYPE(ST, TMC2130) || (AXIS_DRIVER_TYPE(ST, TMC2208) && PIN_EXISTS(ST##_SERIAL_RX))) #define M91x_USE(ST) (AXIS_DRIVER_TYPE(ST, TMC2130) || AXIS_DRIVER_TYPE(ST, TMC2208))
#define M91x_USE_E(N) (E_STEPPERS > N && M91x_USE(E##N)) #define M91x_USE_E(N) (E_STEPPERS > N && M91x_USE(E##N))
#define M91x_SOME_X (M91x_USE(X) || M91x_USE(X2)) #define M91x_SOME_X (M91x_USE(X) || M91x_USE(X2))
@ -41,7 +41,7 @@
#define M91x_SOME_E (M91x_USE_E(0) || M91x_USE_E(1) || M91x_USE_E(2) || M91x_USE_E(3) || M91x_USE_E(4) || M91x_USE_E(5)) #define M91x_SOME_E (M91x_USE_E(0) || M91x_USE_E(1) || M91x_USE_E(2) || M91x_USE_E(3) || M91x_USE_E(4) || M91x_USE_E(5))
#if !M91x_SOME_X && !M91x_SOME_Y && !M91x_SOME_Z && !M91x_SOME_E #if !M91x_SOME_X && !M91x_SOME_Y && !M91x_SOME_Z && !M91x_SOME_E
#error "MONITOR_DRIVER_STATUS requires at least one TMC2130 or serial-connected TMC2208." #error "MONITOR_DRIVER_STATUS requires at least one TMC2130 or TMC2208."
#endif #endif
/** /**

View File

@ -1704,64 +1704,68 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE && Y_MAX_LENGTH >= Y_BED_SIZE,
/** /**
* Check existing CS pins against enabled TMC SPI drivers. * Check existing CS pins against enabled TMC SPI drivers.
*/ */
#if AXIS_DRIVER_TYPE(X, TMC2130) && !PIN_EXISTS(X_CS) #define INVALID_TMC2130(ST) (AXIS_DRIVER_TYPE(ST, TMC2130) && !PIN_EXISTS(ST##_CS))
#if INVALID_TMC2130(X)
#error "TMC2130 on X requires X_CS_PIN." #error "TMC2130 on X requires X_CS_PIN."
#elif AXIS_DRIVER_TYPE(X2, TMC2130) && !PIN_EXISTS(X2_CS) #elif INVALID_TMC2130(X2)
#error "TMC2130 on X2 requires X2_CS_PIN." #error "TMC2130 on X2 requires X2_CS_PIN."
#elif AXIS_DRIVER_TYPE(Y, TMC2130) && !PIN_EXISTS(Y_CS) #elif INVALID_TMC2130(Y)
#error "TMC2130 on Y requires Y_CS_PIN." #error "TMC2130 on Y requires Y_CS_PIN."
#elif AXIS_DRIVER_TYPE(Y2, TMC2130) && !PIN_EXISTS(Y2_CS) #elif INVALID_TMC2130(Y2)
#error "TMC2130 on Y2 requires Y2_CS_PIN." #error "TMC2130 on Y2 requires Y2_CS_PIN."
#elif AXIS_DRIVER_TYPE(Z, TMC2130) && !PIN_EXISTS(Z_CS) #elif INVALID_TMC2130(Z)
#error "TMC2130 on Z requires Z_CS_PIN." #error "TMC2130 on Z requires Z_CS_PIN."
#elif AXIS_DRIVER_TYPE(Z2, TMC2130) && !PIN_EXISTS(Z2_CS) #elif INVALID_TMC2130(Z2)
#error "TMC2130 on Z2 requires Z2_CS_PIN." #error "TMC2130 on Z2 requires Z2_CS_PIN."
#elif AXIS_DRIVER_TYPE(Z3, TMC2130) && !PIN_EXISTS(Z3_CS) #elif INVALID_TMC2130(Z3)
#error "TMC2130 on Z3 requires Z3_CS_PIN." #error "TMC2130 on Z3 requires Z3_CS_PIN."
#elif AXIS_DRIVER_TYPE(E0, TMC2130) && !PIN_EXISTS(E0_CS) #elif INVALID_TMC2130(E0)
#error "TMC2130 on E0 requires E0_CS_PIN." #error "TMC2130 on E0 requires E0_CS_PIN."
#elif AXIS_DRIVER_TYPE(E1, TMC2130) && !PIN_EXISTS(E1_CS) #elif INVALID_TMC2130(E1)
#error "TMC2130 on E1 requires E1_CS_PIN." #error "TMC2130 on E1 requires E1_CS_PIN."
#elif AXIS_DRIVER_TYPE(E2, TMC2130) && !PIN_EXISTS(E2_CS) #elif INVALID_TMC2130(E2)
#error "TMC2130 on E2 requires E2_CS_PIN." #error "TMC2130 on E2 requires E2_CS_PIN."
#elif AXIS_DRIVER_TYPE(E3, TMC2130) && !PIN_EXISTS(E3_CS) #elif INVALID_TMC2130(E3)
#error "TMC2130 on E3 requires E3_CS_PIN." #error "TMC2130 on E3 requires E3_CS_PIN."
#elif AXIS_DRIVER_TYPE(E4, TMC2130) && !PIN_EXISTS(E4_CS) #elif INVALID_TMC2130(E4)
#error "TMC2130 on E4 requires E4_CS_PIN." #error "TMC2130 on E4 requires E4_CS_PIN."
#elif AXIS_DRIVER_TYPE(E5, TMC2130) && !PIN_EXISTS(E5_CS) #elif INVALID_TMC2130(E5)
#error "TMC2130 on E5 requires E5_CS_PIN." #error "TMC2130 on E5 requires E5_CS_PIN."
#endif #endif
#undef INVALID_TMC2130
/** /**
* Check existing RX/TX pins against enable TMC UART drivers. * Check existing RX/TX pins against enable TMC UART drivers.
*/ */
#if AXIS_DRIVER_TYPE(X, TMC2208) && !(defined(X_HARDWARE_SERIAL) || (PIN_EXISTS(X_SERIAL_RX) && PIN_EXISTS(X_SERIAL_TX))) #define INVALID_TMC2208(ST) (AXIS_DRIVER_TYPE(ST, TMC2208) && !(defined(ST##_HARDWARE_SERIAL) || (PIN_EXISTS(ST##_SERIAL_RX) && PIN_EXISTS(ST##_SERIAL_TX))))
#error "TMC2208 on X requires X_HARDWARE_SERIAL or both X_SERIAL_RX_PIN and X_SERIAL_TX_PIN." #if INVALID_TMC2208(X)
#elif AXIS_DRIVER_TYPE(X2, TMC2208) && !(defined(X2_HARDWARE_SERIAL) || (PIN_EXISTS(X2_SERIAL_RX) && PIN_EXISTS(X2_SERIAL_TX))) #error "TMC2208 on X requires X_HARDWARE_SERIAL or X_SERIAL_(RX|TX)_PIN."
#error "TMC2208 on X2 requires X2_HARDWARE_SERIAL or both X2_SERIAL_RX_PIN and X2_SERIAL_TX_PIN." #elif INVALID_TMC2208(X2)
#elif AXIS_DRIVER_TYPE(Y, TMC2208) && !(defined(Y_HARDWARE_SERIAL) || (PIN_EXISTS(Y_SERIAL_RX) && PIN_EXISTS(Y_SERIAL_TX))) #error "TMC2208 on X2 requires X2_HARDWARE_SERIAL or X2_SERIAL_(RX|TX)_PIN."
#error "TMC2208 on Y requires Y_HARDWARE_SERIAL or both Y_SERIAL_RX_PIN and Y_SERIAL_TX_PIN." #elif INVALID_TMC2208(Y)
#elif AXIS_DRIVER_TYPE(Y2, TMC2208) && !(defined(Y2_HARDWARE_SERIAL) || (PIN_EXISTS(Y2_SERIAL_RX) && PIN_EXISTS(Y2_SERIAL_TX))) #error "TMC2208 on Y requires Y_HARDWARE_SERIAL or Y_SERIAL_(RX|TX)_PIN."
#error "TMC2208 on Y2 requires Y2_HARDWARE_SERIAL or both Y2_SERIAL_RX_PIN and Y2_SERIAL_TX_PIN." #elif INVALID_TMC2208(Y2)
#elif AXIS_DRIVER_TYPE(Z, TMC2208) && !(defined(Z_HARDWARE_SERIAL) || (PIN_EXISTS(Z_SERIAL_RX) && PIN_EXISTS(Z_SERIAL_TX))) #error "TMC2208 on Y2 requires Y2_HARDWARE_SERIAL or Y2_SERIAL_(RX|TX)_PIN."
#error "TMC2208 on Z requires Z_HARDWARE_SERIAL or both Z_SERIAL_RX_PIN and Z_SERIAL_TX_PIN." #elif INVALID_TMC2208(Z)
#elif AXIS_DRIVER_TYPE(Z2, TMC2208) && !(defined(Z2_HARDWARE_SERIAL) || (PIN_EXISTS(Z2_SERIAL_RX) && PIN_EXISTS(Z2_SERIAL_TX))) #error "TMC2208 on Z requires Z_HARDWARE_SERIAL or Z_SERIAL_(RX|TX)_PIN."
#error "TMC2208 on Z2 requires Z2_HARDWARE_SERIAL or both Z2_SERIAL_RX_PIN and Z2_SERIAL_TX_PIN." #elif INVALID_TMC2208(Z2)
#elif AXIS_DRIVER_TYPE(Z3, TMC2208) && !(defined(Z3_HARDWARE_SERIAL) || (PIN_EXISTS(Z3_SERIAL_RX) && PIN_EXISTS(Z3_SERIAL_TX))) #error "TMC2208 on Z2 requires Z2_HARDWARE_SERIAL or Z2_SERIAL_(RX|TX)_PIN."
#error "TMC2208 on Z3 requires Z3_HARDWARE_SERIAL or both Z3_SERIAL_RX_PIN and Z3_SERIAL_TX_PIN." #elif INVALID_TMC2208(Z3)
#elif AXIS_DRIVER_TYPE(E0, TMC2208) && !(defined(E0_HARDWARE_SERIAL) || (PIN_EXISTS(E0_SERIAL_RX) && PIN_EXISTS(E0_SERIAL_TX))) #error "TMC2208 on Z3 requires Z3_HARDWARE_SERIAL or Z3_SERIAL_(RX|TX)_PIN."
#error "TMC2208 on E0 requires E0_HARDWARE_SERIAL or both E0_SERIAL_RX_PIN and E0_SERIAL_TX_PIN." #elif INVALID_TMC2208(E0)
#elif AXIS_DRIVER_TYPE(E1, TMC2208) && !(defined(E1_HARDWARE_SERIAL) || (PIN_EXISTS(E1_SERIAL_RX) && PIN_EXISTS(E1_SERIAL_TX))) #error "TMC2208 on E0 requires E0_HARDWARE_SERIAL or E0_SERIAL_(RX|TX)_PIN."
#error "TMC2208 on E1 requires E1_HARDWARE_SERIAL or both E1_SERIAL_RX_PIN and E1_SERIAL_TX_PIN." #elif INVALID_TMC2208(E1)
#elif AXIS_DRIVER_TYPE(E2, TMC2208) && !(defined(E2_HARDWARE_SERIAL) || (PIN_EXISTS(E2_SERIAL_RX) && PIN_EXISTS(E2_SERIAL_TX))) #error "TMC2208 on E1 requires E1_HARDWARE_SERIAL or E1_SERIAL_(RX|TX)_PIN."
#error "TMC2208 on E2 requires E2_HARDWARE_SERIAL or both E2_SERIAL_RX_PIN and E2_SERIAL_TX_PIN." #elif INVALID_TMC2208(E2)
#elif AXIS_DRIVER_TYPE(E3, TMC2208) && !(defined(E3_HARDWARE_SERIAL) || (PIN_EXISTS(E3_SERIAL_RX) && PIN_EXISTS(E3_SERIAL_TX))) #error "TMC2208 on E2 requires E2_HARDWARE_SERIAL or E2_SERIAL_(RX|TX)_PIN."
#error "TMC2208 on E3 requires E3_HARDWARE_SERIAL or both E3_SERIAL_RX_PIN and E3_SERIAL_TX_PIN." #elif INVALID_TMC2208(E3)
#elif AXIS_DRIVER_TYPE(E4, TMC2208) && !(defined(E4_HARDWARE_SERIAL) || (PIN_EXISTS(E4_SERIAL_RX) && PIN_EXISTS(E4_SERIAL_TX))) #error "TMC2208 on E3 requires E3_HARDWARE_SERIAL or E3_SERIAL_(RX|TX)_PIN."
#error "TMC2208 on E4 requires E4_HARDWARE_SERIAL or both E4_SERIAL_RX_PIN and E4_SERIAL_TX_PIN." #elif INVALID_TMC2208(E4)
#elif AXIS_DRIVER_TYPE(E5, TMC2208) && !(defined(E5_HARDWARE_SERIAL) || (PIN_EXISTS(E5_SERIAL_RX) && PIN_EXISTS(E5_SERIAL_TX))) #error "TMC2208 on E4 requires E4_HARDWARE_SERIAL or E4_SERIAL_(RX|TX)_PIN."
#error "TMC2208 on E5 requires E5_HARDWARE_SERIAL or both E5_SERIAL_RX_PIN and E5_SERIAL_TX_PIN." #elif INVALID_TMC2208(E5)
#error "TMC2208 on E5 requires E5_HARDWARE_SERIAL or E5_SERIAL_(RX|TX)_PIN."
#endif #endif
#undef INVALID_TMC2208
/** /**
* TMC2208 software UART and ENDSTOP_INTERRUPTS both use pin change interrupts (PCI) * TMC2208 software UART and ENDSTOP_INTERRUPTS both use pin change interrupts (PCI)