1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-26 17:46:14 +01:00

Restict where what SerialX is used

This commit is contained in:
Harald Barth 2023-05-21 20:20:32 +02:00
parent b80d7bd517
commit 16f94ecbdc
2 changed files with 12 additions and 13 deletions

View File

@ -1 +1 @@
#define GITHUB_SHA "devel-202305210948Z" #define GITHUB_SHA "devel-202305211819Z"

View File

@ -58,20 +58,14 @@ Stream * WifiInterface::wifiStream;
#define NUM_SERIAL 1 #define NUM_SERIAL 1
#endif #endif
// To be able to define these in platform specific // For STM32 we need to define Serial3 in the platform specific
// DCCTimer<PLATFORM>.cpp files, we here make the // DCCTimerSTM32.cpp file, we here make the assumption that it
// assumption that these exist to link against. // exists to link against.
// if enough serial interfaces exist. #ifdef ARDUINO_ARCH_STM32
#if NUM_SERIAL > 0
extern HardwareSerial Serial1;
#endif
#if NUM_SERIAL > 1
extern HardwareSerial Serial2;
#endif
#if NUM_SERIAL > 2 #if NUM_SERIAL > 2
extern HardwareSerial Serial3; extern HardwareSerial Serial3;
#endif #endif
#endif
bool WifiInterface::setup(long serial_link_speed, bool WifiInterface::setup(long serial_link_speed,
const FSH *wifiESSID, const FSH *wifiESSID,
const FSH *wifiPassword, const FSH *wifiPassword,
@ -97,6 +91,8 @@ bool WifiInterface::setup(long serial_link_speed,
#endif #endif
// Other serials are tried, depending on hardware. // Other serials are tried, depending on hardware.
// Currently only the Arduino Mega 2560 has usable Serial2
#if defined(ARDUINO_AVR_MEGA2560)
#if NUM_SERIAL > 1 && !defined(SERIAL2_COMMANDS) #if NUM_SERIAL > 1 && !defined(SERIAL2_COMMANDS)
if (wifiUp == WIFI_NOAT) if (wifiUp == WIFI_NOAT)
{ {
@ -104,7 +100,10 @@ bool WifiInterface::setup(long serial_link_speed,
wifiUp = setup(Serial2, wifiESSID, wifiPassword, hostname, port, channel); wifiUp = setup(Serial2, wifiESSID, wifiPassword, hostname, port, channel);
} }
#endif #endif
#endif
// We guess here that in all architctures that have a Serial3
// we can use it for our purpose.
#if NUM_SERIAL > 2 && !defined(SERIAL3_COMMANDS) #if NUM_SERIAL > 2 && !defined(SERIAL3_COMMANDS)
if (wifiUp == WIFI_NOAT) if (wifiUp == WIFI_NOAT)
{ {