Преглед изворни кода

Reorder setup, with serial early

Scott Lahteine пре 5 година
родитељ
комит
5a5be7e287
2 измењених фајлова са 44 додато и 53 уклоњено
  1. 10
    10
      Marlin/src/HAL/STM32/HAL.cpp
  2. 34
    43
      Marlin/src/MarlinCore.cpp

+ 10
- 10
Marlin/src/HAL/STM32/HAL.cpp Прегледај датотеку

@@ -76,16 +76,16 @@ void HAL_init() {
76 76
   #endif
77 77
 
78 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 90
   #if HAS_TMC_SW_SERIAL
91 91
     SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0);

+ 34
- 43
Marlin/src/MarlinCore.cpp Прегледај датотеку

@@ -889,68 +889,59 @@ void setup() {
889 889
   #endif
890 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 893
     // Disable any hardware debug to free up pins for IO
904
-    #ifdef JTAGSWD_DISABLE
894
+    #if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE)
905 895
       JTAGSWD_DISABLE();
906 896
     #elif defined(JTAG_DISABLE)
907 897
       JTAG_DISABLE();
908 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 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 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 923
   #endif
919 924
 
920 925
   #if HAS_FILAMENT_SENSOR
921
-    runout.setup();
926
+    SETUP_RUN(runout.setup());
922 927
   #endif
923 928
 
924 929
   #if ENABLED(POWER_LOSS_RECOVERY)
925
-    recovery.setup();
930
+    SETUP_RUN(recovery.setup());
926 931
   #endif
927 932
 
928
-  setup_killpin();
933
+  SETUP_RUN(setup_killpin());
929 934
 
930 935
   #if HAS_TMC220x
931
-    tmc_serial_begin();
936
+    SETUP_RUN(tmc_serial_begin());
932 937
   #endif
933 938
 
934
-  setup_powerhold();
939
+  SETUP_RUN(setup_powerhold());
935 940
 
936 941
   #if HAS_STEPPER_RESET
937
-    disableStepperDrivers();
942
+    SETUP_RUN(disableStepperDrivers());
938 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 945
   #if HAS_TMC_SPI
955 946
     #if DISABLED(TMC_USE_SW_SPI)
956 947
       SETUP_RUN(SPI.begin());
@@ -966,7 +957,7 @@ void setup() {
966 957
   SETUP_RUN(esp_wifi_init());
967 958
 
968 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 961
   if (mcu &  1) SERIAL_ECHOLNPGM(STR_POWERUP);
971 962
   if (mcu &  2) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET);
972 963
   if (mcu &  4) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET);
@@ -991,9 +982,6 @@ void setup() {
991 982
   SERIAL_ECHO_START();
992 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 985
   // Set up LEDs early
998 986
   #if HAS_COLOR_LEDS
999 987
     SETUP_RUN(leds.setup());
@@ -1003,6 +991,9 @@ void setup() {
1003 991
     SETUP_RUN(controllerFan.setup());
1004 992
   #endif
1005 993
 
994
+  // UI must be initialized before EEPROM
995
+  // (because EEPROM code calls the UI).
996
+
1006 997
   SETUP_RUN(ui.init());
1007 998
   SETUP_RUN(ui.reset_status());       // Load welcome message early. (Retained if no errors exist.)
1008 999
 

Loading…
Откажи
Сачувај