Move setup logging to the top

This commit is contained in:
Scott Lahteine 2020-04-16 03:36:53 -05:00
parent 1c43870cec
commit d8b8d88276

View file

@ -875,6 +875,19 @@ void stop() {
*/
void setup() {
#if ENABLED(MARLIN_DEV_MODE)
auto log_current_ms = [&](PGM_P const msg) {
SERIAL_ECHO_START();
SERIAL_CHAR('['); SERIAL_ECHO(millis()); SERIAL_ECHO("] ");
serialprintPGM(msg);
SERIAL_EOL();
};
#define SETUP_LOG(M) log_current_ms(PSTR(M))
#else
#define SETUP_LOG(...) NOOP
#endif
#define SETUP_RUN(C) do{ SETUP_LOG(STRINGIFY(C)); C; }while(0)
HAL_init();
#if HAS_L64XX
@ -939,12 +952,13 @@ void setup() {
#if HAS_TMC_SPI
#if DISABLED(TMC_USE_SW_SPI)
SPI.begin();
SETUP_RUN(SPI.begin());
#endif
tmc_init_cs_pins();
SETUP_RUN(tmc_init_cs_pins());
#endif
#ifdef BOARD_INIT
SETUP_LOG("BOARD_INIT");
BOARD_INIT();
#endif
@ -977,19 +991,6 @@ void setup() {
// UI must be initialized before EEPROM
// (because EEPROM code calls the UI).
#if ENABLED(MARLIN_DEV_MODE)
auto log_current_ms = [&](PGM_P const msg) {
SERIAL_ECHO_START();
SERIAL_CHAR('['); SERIAL_ECHO(millis()); SERIAL_ECHO("] ");
serialprintPGM(msg);
SERIAL_EOL();
};
#define SETUP_LOG(M) log_current_ms(PSTR(M))
#else
#define SETUP_LOG(...) NOOP
#endif
#define SETUP_RUN(C) do{ SETUP_LOG(STRINGIFY(C)); C; }while(0)
// Set up LEDs early
#if HAS_COLOR_LEDS
SETUP_RUN(leds.setup());