HAL and serial cleanup
Co-Authored-By: Jason Smith <20053467+sjasonsmith@users.noreply.github.com>
This commit is contained in:
		@@ -43,82 +43,47 @@
 | 
			
		||||
// ------------------------
 | 
			
		||||
// Defines
 | 
			
		||||
// ------------------------
 | 
			
		||||
#define _MSERIAL(X) MSerial##X
 | 
			
		||||
#define MSERIAL(X) _MSERIAL(X)
 | 
			
		||||
 | 
			
		||||
#if SERIAL_PORT == 0
 | 
			
		||||
  #error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
 | 
			
		||||
#elif SERIAL_PORT == -1
 | 
			
		||||
#if SERIAL_PORT == -1
 | 
			
		||||
  #define MYSERIAL0 SerialUSB
 | 
			
		||||
#elif SERIAL_PORT == 1
 | 
			
		||||
  #define MYSERIAL0 MSerial1
 | 
			
		||||
#elif SERIAL_PORT == 2
 | 
			
		||||
  #define MYSERIAL0 MSerial2
 | 
			
		||||
#elif SERIAL_PORT == 3
 | 
			
		||||
  #define MYSERIAL0 MSerial3
 | 
			
		||||
#elif SERIAL_PORT == 4
 | 
			
		||||
  #define MYSERIAL0 MSerial4
 | 
			
		||||
#elif SERIAL_PORT == 5
 | 
			
		||||
  #define MYSERIAL0 MSerial5
 | 
			
		||||
#elif SERIAL_PORT == 6
 | 
			
		||||
  #define MYSERIAL0 MSerial6
 | 
			
		||||
#elif WITHIN(SERIAL_PORT, 1, 6)
 | 
			
		||||
  #define MYSERIAL0 MSERIAL(SERIAL_PORT)
 | 
			
		||||
#else
 | 
			
		||||
  #error "SERIAL_PORT must be from -1 to 6. Please update your configuration."
 | 
			
		||||
  #error "SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration."
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef SERIAL_PORT_2
 | 
			
		||||
  #define NUM_SERIAL 2
 | 
			
		||||
  #if SERIAL_PORT_2 == 0
 | 
			
		||||
    #error "SERIAL_PORT_2 cannot be 0. (Port 0 does not exist.) Please update your configuration."
 | 
			
		||||
  #elif SERIAL_PORT_2 == SERIAL_PORT
 | 
			
		||||
    #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
 | 
			
		||||
  #elif SERIAL_PORT_2 == -1
 | 
			
		||||
  #if SERIAL_PORT_2 == -1
 | 
			
		||||
    #define MYSERIAL1 SerialUSB
 | 
			
		||||
  #elif SERIAL_PORT_2 == 1
 | 
			
		||||
    #define MYSERIAL1 MSerial1
 | 
			
		||||
  #elif SERIAL_PORT_2 == 2
 | 
			
		||||
    #define MYSERIAL1 MSerial2
 | 
			
		||||
  #elif SERIAL_PORT_2 == 3
 | 
			
		||||
    #define MYSERIAL1 MSerial3
 | 
			
		||||
  #elif SERIAL_PORT_2 == 4
 | 
			
		||||
    #define MYSERIAL1 MSerial4
 | 
			
		||||
  #elif SERIAL_PORT_2 == 5
 | 
			
		||||
    #define MYSERIAL1 MSerial5
 | 
			
		||||
  #elif SERIAL_PORT_2 == 6
 | 
			
		||||
    #define MYSERIAL1 MSerial6
 | 
			
		||||
  #elif WITHIN(SERIAL_PORT_2, 1, 6)
 | 
			
		||||
    #define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
 | 
			
		||||
  #else
 | 
			
		||||
    #error "SERIAL_PORT_2 must be from -1 to 6. Please update your configuration."
 | 
			
		||||
    #error "SERIAL_PORT_2 must be -1 or from 1 to 6. Please update your configuration."
 | 
			
		||||
  #endif
 | 
			
		||||
#else
 | 
			
		||||
  #define NUM_SERIAL 1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if HAS_DGUS_LCD
 | 
			
		||||
  #if DGUS_SERIAL_PORT == 0
 | 
			
		||||
    #error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
 | 
			
		||||
  #elif DGUS_SERIAL_PORT == SERIAL_PORT
 | 
			
		||||
    #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
 | 
			
		||||
  #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
 | 
			
		||||
    #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
 | 
			
		||||
  #elif DGUS_SERIAL_PORT == -1
 | 
			
		||||
  #if DGUS_SERIAL_PORT == -1
 | 
			
		||||
    #define DGUS_SERIAL SerialUSB
 | 
			
		||||
  #elif DGUS_SERIAL_PORT == 1
 | 
			
		||||
    #define DGUS_SERIAL MSerial1
 | 
			
		||||
  #elif DGUS_SERIAL_PORT == 2
 | 
			
		||||
    #define DGUS_SERIAL MSerial2
 | 
			
		||||
  #elif DGUS_SERIAL_PORT == 3
 | 
			
		||||
    #define DGUS_SERIAL MSerial3
 | 
			
		||||
  #elif DGUS_SERIAL_PORT == 4
 | 
			
		||||
    #define DGUS_SERIAL MSerial4
 | 
			
		||||
  #elif DGUS_SERIAL_PORT == 5
 | 
			
		||||
    #define DGUS_SERIAL MSerial5
 | 
			
		||||
  #elif DGUS_SERIAL_PORT == 6
 | 
			
		||||
    #define DGUS_SERIAL MSerial6
 | 
			
		||||
  #elif WITHIN(DGUS_SERIAL_PORT, 1, 6)
 | 
			
		||||
    #define DGUS_SERIAL MSERIAL(DGUS_SERIAL_PORT)
 | 
			
		||||
  #else
 | 
			
		||||
    #error "DGUS_SERIAL_PORT must be from -1 to 6. Please update your configuration."
 | 
			
		||||
    #error "DGUS_SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration."
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  #define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.availableForWrite
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if ENABLED(MALYAN_LCD)
 | 
			
		||||
  #if LCD_SERIAL_PORT == -1
 | 
			
		||||
    #define LCD_SERIAL SerialUSB
 | 
			
		||||
  #elif WITHIN(LCD_SERIAL_PORT, 1, 6)
 | 
			
		||||
    #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
 | 
			
		||||
  #else
 | 
			
		||||
    #error "LCD_SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration."
 | 
			
		||||
  #endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * TODO: review this to return 1 for pins that are not analog input
 | 
			
		||||
 
 | 
			
		||||
@@ -98,7 +98,7 @@ static inline void pwm_details(const pin_t pin) {
 | 
			
		||||
    timer_dev * const tdev = PIN_MAP[pin].timer_device;
 | 
			
		||||
    const uint8_t channel = PIN_MAP[pin].timer_channel;
 | 
			
		||||
    const char num = (
 | 
			
		||||
      #if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
 | 
			
		||||
      #if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY)
 | 
			
		||||
        tdev == &timer8 ? '8' :
 | 
			
		||||
        tdev == &timer5 ? '5' :
 | 
			
		||||
      #endif
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user