Skip to content

Commit

Permalink
🚑️ Init FastIO before anything else (#22508)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpruvot authored and thinkyhead committed Aug 9, 2021
1 parent 924e4f9 commit bc68664
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
2 changes: 0 additions & 2 deletions Marlin/src/HAL/STM32/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial());

// HAL initialization task
void HAL_init() {
FastIO_init();

// Ensure F_CPU is a constant expression.
// If the compiler breaks here, it means that delay code that should compute at compile time will not work.
// So better safe than sorry here.
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32/fastio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "../../inc/MarlinConfig.h"

GPIO_TypeDef* FastIOPortMap[LastPort + 1];
GPIO_TypeDef* FastIOPortMap[LastPort + 1] = { 0 };

void FastIO_init() {
LOOP_L_N(i, NUM_DIGITAL_PINS)
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/HAL/STM32/fastio.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ extern GPIO_TypeDef * FastIOPortMap[];
// ------------------------

void FastIO_init(); // Must be called before using fast io macros
#define FASTIO_INIT() FastIO_init()

// ------------------------
// Defines
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/HAL/STM32F1/pinsDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
#pragma once

/**
* Support routines for STM32GENERIC (Maple)
* Support routines for MAPLE_STM32F1
*/

/**
* Translation of routines & variables used by pinsDebug.h
*/

#ifndef BOARD_NR_GPIO_PINS // Only in STM32GENERIC (Maple)
#error "Expected BOARD_NR_GPIO_PINS not found"
#ifndef BOARD_NR_GPIO_PINS // Only in MAPLE_STM32F1
#error "Expected BOARD_NR_GPIO_PINS not found"
#endif

#include "fastio.h"
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,10 @@ inline void tmc_standby_setup() {
* - Set Marlin to RUNNING State
*/
void setup() {
#ifdef FASTIO_INIT
FASTIO_INIT();
#endif

#ifdef BOARD_PREINIT
BOARD_PREINIT(); // Low-level init (before serial init)
#endif
Expand Down

0 comments on commit bc68664

Please sign in to comment.