Fix STM32F1 Serial and ADC pins (#13331)

This commit is contained in:
Msq001 2019-03-08 16:21:32 +08:00 committed by Scott Lahteine
parent dbead66988
commit fb3302feda
2 changed files with 44 additions and 18 deletions

View file

@ -33,6 +33,7 @@
#include "HAL.h" #include "HAL.h"
#include <STM32ADC.h> #include <STM32ADC.h>
#include "../../inc/MarlinConfig.h"
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Externals // Externals
@ -91,7 +92,9 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Public Variables // Public Variables
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
USBSerial SerialUSB; #ifdef SERIAL_USB
USBSerial SerialUSB;
#endif
uint16_t HAL_adc_result; uint16_t HAL_adc_result;

View file

@ -51,46 +51,69 @@
#include "watchdog_STM32F1.h" #include "watchdog_STM32F1.h"
#include "HAL_timers_STM32F1.h" #include "HAL_timers_STM32F1.h"
#include "../../inc/MarlinConfigPre.h"
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Defines // Defines
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#if !WITHIN(SERIAL_PORT, -1, 3) #ifdef SERIAL_USB
#error "SERIAL_PORT must be from -1 to 3" #define UsbSerial Serial
#define MSerial1 Serial1
#define MSerial2 Serial2
#define MSerial3 Serial3
#define MSerial4 Serial4
#define MSerial5 Serial5
#else
extern USBSerial SerialUSB;
#define UsbSerial SerialUSB
#define MSerial1 Serial
#define MSerial2 Serial1
#define MSerial3 Serial2
#define MSerial4 Serial3
#define MSerial5 Serial4
#endif
#if !WITHIN(SERIAL_PORT, -1, 5)
#error "SERIAL_PORT must be from -1 to 5"
#endif #endif
#if SERIAL_PORT == -1 #if SERIAL_PORT == -1
extern USBSerial SerialUSB; #define MYSERIAL0 UsbSerial
#define MYSERIAL0 SerialUSB
#elif SERIAL_PORT == 0 #elif SERIAL_PORT == 0
#define MYSERIAL0 Serial #error "Serial port 0 does not exist"
#elif SERIAL_PORT == 1 #elif SERIAL_PORT == 1
#define MYSERIAL0 Serial1 #define MYSERIAL0 MSerial1
#elif SERIAL_PORT == 2 #elif SERIAL_PORT == 2
#define MYSERIAL0 Serial2 #define MYSERIAL0 MSerial2
#elif SERIAL_PORT == 3 #elif SERIAL_PORT == 3
#define MYSERIAL0 Serial3 #define MYSERIAL0 MSerial3
#elif SERIAL_PORT == 4
#define MYSERIAL0 MSerial4
#elif SERIAL_PORT == 5
#define MYSERIAL0 MSerial5
#endif #endif
#ifdef SERIAL_PORT_2 #ifdef SERIAL_PORT_2
#if !WITHIN(SERIAL_PORT_2, -1, 3) #if !WITHIN(SERIAL_PORT_2, -1, 5)
#error "SERIAL_PORT_2 must be from -1 to 3" #error "SERIAL_PORT_2 must be from -1 to 5"
#elif SERIAL_PORT_2 == SERIAL_PORT #elif SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 must be different than SERIAL_PORT" #error "SERIAL_PORT_2 must be different than SERIAL_PORT"
#endif #endif
#define NUM_SERIAL 2 #define NUM_SERIAL 2
#if SERIAL_PORT_2 == -1 #if SERIAL_PORT_2 == -1
extern USBSerial SerialUSB; #define MYSERIAL1 UsbSerial
#define MYSERIAL1 SerialUSB
#elif SERIAL_PORT_2 == 0 #elif SERIAL_PORT_2 == 0
#define MYSERIAL1 Serial #error "Serial port 0 does not exist"
#elif SERIAL_PORT_2 == 1 #elif SERIAL_PORT_2 == 1
#define MYSERIAL1 Serial1 #define MYSERIAL1 MSerial1
#elif SERIAL_PORT_2 == 2 #elif SERIAL_PORT_2 == 2
#define MYSERIAL1 Serial2 #define MYSERIAL1 MSerial2
#elif SERIAL_PORT_2 == 3 #elif SERIAL_PORT_2 == 3
#define MYSERIAL1 Serial3 #define MYSERIAL1 MSerial3
#elif SERIAL_PORT_2 == 4
#define MYSERIAL1 MSerial4
#elif SERIAL_PORT_2 == 5
#define MYSERIAL1 MSerial5
#endif #endif
#else #else
#define NUM_SERIAL 1 #define NUM_SERIAL 1