Explorar el Código

Reorder setup, with serial early

Scott Lahteine hace 5 años
padre
commit
5a5be7e287
Se han modificado 2 ficheros con 44 adiciones y 53 borrados
  1. 10
    10
      Marlin/src/HAL/STM32/HAL.cpp
  2. 34
    43
      Marlin/src/MarlinCore.cpp

+ 10
- 10
Marlin/src/HAL/STM32/HAL.cpp Ver fichero

76
   #endif
76
   #endif
77
 
77
 
78
   #if ENABLED(SRAM_EEPROM_EMULATION)
78
   #if ENABLED(SRAM_EEPROM_EMULATION)
79
-  // Enable access to backup SRAM
80
-  __HAL_RCC_PWR_CLK_ENABLE();
81
-  HAL_PWR_EnableBkUpAccess();
82
-  __HAL_RCC_BKPSRAM_CLK_ENABLE();
83
-
84
-  // Enable backup regulator
85
-  LL_PWR_EnableBkUpRegulator();
86
-  // Wait until backup regulator is initialized
87
-  while (!LL_PWR_IsActiveFlag_BRR());
88
-  #endif // EEPROM_EMULATED_SRAM
79
+    // Enable access to backup SRAM
80
+    __HAL_RCC_PWR_CLK_ENABLE();
81
+    HAL_PWR_EnableBkUpAccess();
82
+    __HAL_RCC_BKPSRAM_CLK_ENABLE();
83
+
84
+    // Enable backup regulator
85
+    LL_PWR_EnableBkUpRegulator();
86
+    // Wait until backup regulator is initialized
87
+    while (!LL_PWR_IsActiveFlag_BRR());
88
+  #endif
89
 
89
 
90
   #if HAS_TMC_SW_SERIAL
90
   #if HAS_TMC_SW_SERIAL
91
     SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0);
91
     SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0);

+ 34
- 43
Marlin/src/MarlinCore.cpp Ver fichero

889
   #endif
889
   #endif
890
   #define SETUP_RUN(C) do{ SETUP_LOG(STRINGIFY(C)); C; }while(0)
890
   #define SETUP_RUN(C) do{ SETUP_LOG(STRINGIFY(C)); C; }while(0)
891
 
891
 
892
-  HAL_init();
893
-
894
-  #if HAS_L64XX
895
-    L64xxManager.init();  // Set up SPI, init drivers
896
-  #endif
897
-
898
-  #if ENABLED(SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD)
899
-    OUT_WRITE(SMART_EFFECTOR_MOD_PIN, LOW);   // Put Smart Effector into NORMAL mode
900
-  #endif
901
-
902
-  #if ENABLED(DISABLE_DEBUG)
892
+  #if EITHER(DISABLE_DEBUG, DISABLE_JTAG)
903
     // Disable any hardware debug to free up pins for IO
893
     // Disable any hardware debug to free up pins for IO
904
-    #ifdef JTAGSWD_DISABLE
894
+    #if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE)
905
       JTAGSWD_DISABLE();
895
       JTAGSWD_DISABLE();
906
     #elif defined(JTAG_DISABLE)
896
     #elif defined(JTAG_DISABLE)
907
       JTAG_DISABLE();
897
       JTAG_DISABLE();
908
     #else
898
     #else
909
-      #error "DISABLE_DEBUG is not supported for the selected MCU/Board"
899
+      #error "DISABLE_(DEBUG|JTAG) is not supported for the selected MCU/Board."
910
     #endif
900
     #endif
911
-  #elif ENABLED(DISABLE_JTAG)
912
-    // Disable JTAG to free up pins for IO
913
-    #ifdef JTAG_DISABLE
914
-      JTAG_DISABLE();
915
-    #else
916
-      #error "DISABLE_JTAG is not supported for the selected MCU/Board"
901
+  #endif
902
+
903
+  #if NUM_SERIAL > 0
904
+    MYSERIAL0.begin(BAUDRATE);
905
+    uint32_t serial_connect_timeout = millis() + 1000UL;
906
+    while (!MYSERIAL0 && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
907
+    #if NUM_SERIAL > 1
908
+      MYSERIAL1.begin(BAUDRATE);
909
+      serial_connect_timeout = millis() + 1000UL;
910
+      while (!MYSERIAL1 && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
917
     #endif
911
     #endif
912
+    SERIAL_ECHO_MSG("start");
913
+  #endif
914
+
915
+  SETUP_RUN(HAL_init());
916
+
917
+  #if HAS_L64XX
918
+    SETUP_RUN(L64xxManager.init());  // Set up SPI, init drivers
919
+  #endif
920
+
921
+  #if ENABLED(SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD)
922
+    OUT_WRITE(SMART_EFFECTOR_MOD_PIN, LOW);   // Put Smart Effector into NORMAL mode
918
   #endif
923
   #endif
919
 
924
 
920
   #if HAS_FILAMENT_SENSOR
925
   #if HAS_FILAMENT_SENSOR
921
-    runout.setup();
926
+    SETUP_RUN(runout.setup());
922
   #endif
927
   #endif
923
 
928
 
924
   #if ENABLED(POWER_LOSS_RECOVERY)
929
   #if ENABLED(POWER_LOSS_RECOVERY)
925
-    recovery.setup();
930
+    SETUP_RUN(recovery.setup());
926
   #endif
931
   #endif
927
 
932
 
928
-  setup_killpin();
933
+  SETUP_RUN(setup_killpin());
929
 
934
 
930
   #if HAS_TMC220x
935
   #if HAS_TMC220x
931
-    tmc_serial_begin();
936
+    SETUP_RUN(tmc_serial_begin());
932
   #endif
937
   #endif
933
 
938
 
934
-  setup_powerhold();
939
+  SETUP_RUN(setup_powerhold());
935
 
940
 
936
   #if HAS_STEPPER_RESET
941
   #if HAS_STEPPER_RESET
937
-    disableStepperDrivers();
942
+    SETUP_RUN(disableStepperDrivers());
938
   #endif
943
   #endif
939
 
944
 
940
-  #if NUM_SERIAL > 0
941
-    MYSERIAL0.begin(BAUDRATE);
942
-    uint32_t serial_connect_timeout = millis() + 1000UL;
943
-    while (!MYSERIAL0 && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
944
-    #if NUM_SERIAL > 1
945
-      MYSERIAL1.begin(BAUDRATE);
946
-      serial_connect_timeout = millis() + 1000UL;
947
-      while (!MYSERIAL1 && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
948
-    #endif
949
-  #endif
950
-
951
-  SERIAL_ECHOLNPGM("start");
952
-  SERIAL_ECHO_START();
953
-
954
   #if HAS_TMC_SPI
945
   #if HAS_TMC_SPI
955
     #if DISABLED(TMC_USE_SW_SPI)
946
     #if DISABLED(TMC_USE_SW_SPI)
956
       SETUP_RUN(SPI.begin());
947
       SETUP_RUN(SPI.begin());
966
   SETUP_RUN(esp_wifi_init());
957
   SETUP_RUN(esp_wifi_init());
967
 
958
 
968
   // Check startup - does nothing if bootloader sets MCUSR to 0
959
   // Check startup - does nothing if bootloader sets MCUSR to 0
969
-  byte mcu = HAL_get_reset_source();
960
+  const byte mcu = HAL_get_reset_source();
970
   if (mcu &  1) SERIAL_ECHOLNPGM(STR_POWERUP);
961
   if (mcu &  1) SERIAL_ECHOLNPGM(STR_POWERUP);
971
   if (mcu &  2) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET);
962
   if (mcu &  2) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET);
972
   if (mcu &  4) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET);
963
   if (mcu &  4) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET);
991
   SERIAL_ECHO_START();
982
   SERIAL_ECHO_START();
992
   SERIAL_ECHOLNPAIR(STR_FREE_MEMORY, freeMemory(), STR_PLANNER_BUFFER_BYTES, (int)sizeof(block_t) * (BLOCK_BUFFER_SIZE));
983
   SERIAL_ECHOLNPAIR(STR_FREE_MEMORY, freeMemory(), STR_PLANNER_BUFFER_BYTES, (int)sizeof(block_t) * (BLOCK_BUFFER_SIZE));
993
 
984
 
994
-  // UI must be initialized before EEPROM
995
-  // (because EEPROM code calls the UI).
996
-
997
   // Set up LEDs early
985
   // Set up LEDs early
998
   #if HAS_COLOR_LEDS
986
   #if HAS_COLOR_LEDS
999
     SETUP_RUN(leds.setup());
987
     SETUP_RUN(leds.setup());
1003
     SETUP_RUN(controllerFan.setup());
991
     SETUP_RUN(controllerFan.setup());
1004
   #endif
992
   #endif
1005
 
993
 
994
+  // UI must be initialized before EEPROM
995
+  // (because EEPROM code calls the UI).
996
+
1006
   SETUP_RUN(ui.init());
997
   SETUP_RUN(ui.init());
1007
   SETUP_RUN(ui.reset_status());       // Load welcome message early. (Retained if no errors exist.)
998
   SETUP_RUN(ui.reset_status());       // Load welcome message early. (Retained if no errors exist.)
1008
 
999
 

Loading…
Cancelar
Guardar