🔧 Some STM32 UART Sanity Checks (#24795)

This commit is contained in:
ellensp 2022-10-20 15:23:22 +13:00 committed by Scott Lahteine
parent 682a9b6fbe
commit 4d9bf91edc
6 changed files with 187 additions and 29 deletions

View File

@ -1152,7 +1152,7 @@
#endif
/**
* Automatic backlash, position and hotend offset calibration
* Automatic backlash, position, and hotend offset calibration
*
* Enable G425 to run automatic calibration using an electrically-
* conductive cube, bolt, or washer mounted on the bed.

View File

@ -40,15 +40,17 @@
#if SERIAL_IN_USE(0)
// D0-D1. No known conflicts.
#endif
#if SERIAL_IN_USE(1)
#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__)
#if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19))
#if CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19)
#error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board."
#endif
#else
#if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11))
#if CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11)
#error "Serial Port 1 pin D10 and/or D11 conflicts with another pin on the board."
#endif
#endif
#endif
#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."
#endif

View File

@ -50,3 +50,62 @@
#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) && NOT_TARGET(STM32H7xx, STM32F4xx, STM32F1xx)
#error "TFT_COLOR_UI, TFT_LVGL_UI and TFT_CLASSIC_UI are currently only supported on STM32H7, STM32F4 and STM32F1 hardware."
#endif
/**
* Check for common serial pin conflicts
*/
#define _CHECK_SERIAL_PIN(N) (( \
BTN_EN1 == N || DOGLCD_CS == N || HEATER_BED_PIN == N || FAN_PIN == N || \
SDIO_D2_PIN == N || SDIO_D3_PIN == N || SDIO_CK_PIN == N || SDIO_CMD_PIN == N \
))
#define CHECK_SERIAL_PIN(T,N) defined(UART##N##_##T##_PIN) && _CHECK_SERIAL_PIN(UART##N##_##T##_PIN)
#if SERIAL_IN_USE(1)
#if CHECK_SERIAL_PIN(TX,1)
#error "Serial Port 1 TX IO pins conflict with another pin on the board."
#endif
#if CHECK_SERIAL_PIN(RX,1)
#error "Serial Port 1 RX IO pins conflict with another pin on the board."
#endif
#endif
#if SERIAL_IN_USE(2)
#if CHECK_SERIAL_PIN(TX,2)
#error "Serial Port 2 TX IO pins conflict with another pin on the board."
#endif
#if CHECK_SERIAL_PIN(RX,2)
#error "Serial Port 2 RX IO pins conflict with another pin on the board."
#endif
#endif
#if SERIAL_IN_USE(3)
#if CHECK_SERIAL_PIN(TX,3)
#error "Serial Port 3 TX IO pins conflict with another pin on the board."
#endif
#if CHECK_SERIAL_PIN(RX,3)
#error "Serial Port 3 RX IO pins conflict with another pin on the board."
#endif
#endif
#if SERIAL_IN_USE(4)
#if CHECK_SERIAL_PIN(TX,4)
#error "Serial Port 4 TX IO pins conflict with another pin on the board."
#endif
#if CHECK_SERIAL_PIN(RX,4)
#error "Serial Port 4 RX IO pins conflict with another pin on the board."
#endif
#endif
#if SERIAL_IN_USE(5)
#if CHECK_SERIAL_PIN(TX,5)
#error "Serial Port 5 TX IO pins conflict with another pin on the board."
#endif
#if CHECK_SERIAL_PIN(RX,5)
#error "Serial Port 5 RX IO pins conflict with another pin on the board."
#endif
#endif
#if SERIAL_IN_USE(6)
#if CHECK_SERIAL_PIN(TX,6)
#error "Serial Port 6 TX IO pins conflict with another pin on the board."
#endif
#if CHECK_SERIAL_PIN(RX,6)
#error "Serial Port 6 RX IO pins conflict with another pin on the board."
#endif
#endif
#undef CHECK_SERIAL_PIN
#undef _CHECK_SERIAL_PIN

View File

@ -2446,11 +2446,11 @@
//
// Flag the indexed hardware serial ports in use
#define SERIAL_IN_USE(N) ( (defined(SERIAL_PORT) && SERIAL_PORT == N) \
|| (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == N) \
|| (defined(SERIAL_PORT_3) && SERIAL_PORT_3 == N) \
|| (defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == N) \
|| (defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == N) )
#define SERIAL_IN_USE(N) ( (defined(SERIAL_PORT) && N == SERIAL_PORT) \
|| (defined(SERIAL_PORT_2) && N == SERIAL_PORT_2) \
|| (defined(SERIAL_PORT_3) && N == SERIAL_PORT_3) \
|| (defined(MMU2_SERIAL_PORT) && N == MMU2_SERIAL_PORT) \
|| (defined(LCD_SERIAL_PORT) && N == LCD_SERIAL_PORT) )
// 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))

View File

@ -2231,6 +2231,80 @@
REPORT_NAME_DIGITAL(__LINE__, TFT_RESET_PIN)
#endif
//
// Hardware UART
//
#if SERIAL_IN_USE(1)
#if PIN_EXISTS(UART1_TX)
REPORT_NAME_DIGITAL(__LINE__, UART1_TX_PIN)
#endif
#if PIN_EXISTS(UART1_RX)
REPORT_NAME_DIGITAL(__LINE__, UART1_RX_PIN)
#endif
#endif
#if SERIAL_IN_USE(2)
#if PIN_EXISTS(UART2_TX)
REPORT_NAME_DIGITAL(__LINE__, UART2_TX_PIN)
#endif
#if PIN_EXISTS(UART2_RX)
REPORT_NAME_DIGITAL(__LINE__, UART2_RX_PIN)
#endif
#endif
#if SERIAL_IN_USE(3)
#if PIN_EXISTS(UART3_TX)
REPORT_NAME_DIGITAL(__LINE__, UART3_TX_PIN)
#endif
#if PIN_EXISTS(UART3_RX)
REPORT_NAME_DIGITAL(__LINE__, UART3_RX_PIN)
#endif
#endif
#if SERIAL_IN_USE(4)
#if PIN_EXISTS(UART4_TX)
REPORT_NAME_DIGITAL(__LINE__, UART4_TX_PIN)
#endif
#if PIN_EXISTS(UART4_RX)
REPORT_NAME_DIGITAL(__LINE__, UART4_RX_PIN)
#endif
#endif
#if SERIAL_IN_USE(5)
#if PIN_EXISTS(UART5_TX)
REPORT_NAME_DIGITAL(__LINE__, UART5_TX_PIN)
#endif
#if PIN_EXISTS(UART5_RX)
REPORT_NAME_DIGITAL(__LINE__, UART5_RX_PIN)
#endif
#endif
#if SERIAL_IN_USE(6)
#if PIN_EXISTS(UART6_TX)
REPORT_NAME_DIGITAL(__LINE__, UART6_TX_PIN)
#endif
#if PIN_EXISTS(UART6_RX)
REPORT_NAME_DIGITAL(__LINE__, UART6_RX_PIN)
#endif
#endif
//
// SDIO
//
#if PIN_EXISTS(SDIO_D0)
REPORT_NAME_DIGITAL(__LINE__, SDIO_D0_PIN)
#endif
#if PIN_EXISTS(SDIO_D1)
REPORT_NAME_DIGITAL(__LINE__, SDIO_D1_PIN)
#endif
#if PIN_EXISTS(SDIO_D2)
REPORT_NAME_DIGITAL(__LINE__, SDIO_D2_PIN)
#endif
#if PIN_EXISTS(SDIO_D3)
REPORT_NAME_DIGITAL(__LINE__, SDIO_D3_PIN)
#endif
#if PIN_EXISTS(SDIO_CK)
REPORT_NAME_DIGITAL(__LINE__, SDIO_CK_PIN)
#endif
#if PIN_EXISTS(SDIO_CMD)
REPORT_NAME_DIGITAL(__LINE__, SDIO_CMD_PIN)
#endif
//
// Miscellaneous
//

View File

@ -283,3 +283,26 @@
#define NEOPIXEL_PIN PA13
#endif
// Pins for documentation and sanity checks only.
// Changing these will not change the pin they are on.
// Hardware UART pins
#define UART1_TX_PIN PA9 // default uses CH340 RX
#define UART1_RX_PIN PA10 // default uses CH340 TX
#define UART2_TX_PIN PA2 // default uses HEATER_BED_PIN
#define UART2_RX_PIN PA3 // not connected
#define UART3_TX_PIN PB10 // default uses LCD connector
#define UART3_RX_PIN PB11 // default uses LCD connector
#define UART4_TX_PIN PC10 // default uses sdcard SDIO_D2
#define UART4_RX_PIN PC11 // default uses sdcard SDIO_D3
#define UART5_TX_PIN PC12 // default uses sdcard SDIO_CK
#define UART5_RX_PIN PD2 // default uses sdcard SDIO_CMD
// SDIO pins
#define SDIO_D0_PIN PC8
#define SDIO_D1_PIN PC9
#define SDIO_D2_PIN PC10
#define SDIO_D3_PIN PC11
#define SDIO_CK_PIN PC12
#define SDIO_CMD_PIN PD2