Skip to content

Commit

Permalink
New HardwareTimer for STM32 5.7.0 (MarlinFirmware#15655)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinoBarreca authored and philippniethammer committed Dec 21, 2019
1 parent 0493270 commit f1d1e09
Show file tree
Hide file tree
Showing 31 changed files with 1,289 additions and 519 deletions.
19 changes: 9 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,34 @@ env:
- TEST_PLATFORM="sanguino_atmega1284p"
- TEST_PLATFORM="sanguino_atmega644p"

# Broken Extended STM32 Environments
#- TEST_PLATFORM="ARMED"
#- TEST_PLATFORM="BIGTREE_BTT002"
#- TEST_PLATFORM="BIGTREE_SKR_PRO"

# Extended STM32 Environments
- TEST_PLATFORM="STM32F103RC_bigtree"
- TEST_PLATFORM="STM32F103RC_bigtree_USB"
- TEST_PLATFORM="STM32F103RC_fysetc"
- TEST_PLATFORM="jgaurora_a5s_a1"
- TEST_PLATFORM="STM32F103VE_longer"
- TEST_PLATFORM="STM32F407VE_black"
- TEST_PLATFORM="BIGTREE_SKR_PRO"
- TEST_PLATFORM="mks_robin"
- TEST_PLATFORM="ARMED"

# STM32 with non-STM framework. both broken for now. they should use HAL_STM32 which is working.
#- TEST_PLATFORM="STM32F4"
#- TEST_PLATFORM="STM32F7"

# Put lengthy tests last
- TEST_PLATFORM="LPC1768"
- TEST_PLATFORM="LPC1769"

# Non-working environment tests
#- TEST_PLATFORM="BIGTREE_BTT002" this board isn't released yet. we need pinout to be sure about what we do
#- TEST_PLATFORM="at90usb1286_cdc"
#- TEST_PLATFORM="at90usb1286_dfu"
#- TEST_PLATFORM="STM32F103CB_malyan"
#- TEST_PLATFORM="mks_robin_lite"
#- TEST_PLATFORM="mks_robin_mini"
#- TEST_PLATFORM="mks_robin_nano"
#- TEST_PLATFORM="SAMD51_grandcentral_m4"
#- TEST_PLATFORM="STM32F103RC_bigtree"
#- TEST_PLATFORM="STM32F103RC_bigtree_USB"
#- TEST_PLATFORM="STM32F103RC_fysetc"
#- TEST_PLATFORM="STM32F4"
#- TEST_PLATFORM="STM32F7"

before_install:
#
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/HAL_ESP32/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ typedef uint64_t hal_timer_t;
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs // wrong would be 0.25
#else
#define STEPPER_TIMER_PRESCALE 40
#define STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // frequency of stepper timer, 2MHz
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
#define STEPPER_TIMER_RATE ((HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE)) // frequency of stepper timer, 2MHz
#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs
#endif

#define STEP_TIMER_MIN_INTERVAL 8 // minimum time in µs between stepper interrupts
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/HAL_SAMD51/timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
SYNC(tc->COUNT32.SYNCBUSY.bit.CTRLB);

// Set compare value
tc->COUNT32.COUNT.reg = tc->COUNT32.CC[0].reg = HAL_TIMER_RATE / frequency;
tc->COUNT32.COUNT.reg = tc->COUNT32.CC[0].reg = (HAL_TIMER_RATE) / frequency;

// And start timer
tc->COUNT32.CTRLA.bit.ENABLE = true;
Expand Down
14 changes: 14 additions & 0 deletions Marlin/src/HAL/HAL_STM32/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
#include "../../inc/MarlinConfig.h"
#include "../shared/Delay.h"

#if (__cplusplus == 201703L) && defined(__has_include)
#define HAS_SWSERIAL __has_include(<SoftwareSerial.h>)
#else
#define HAS_SWSERIAL HAS_TMC220x
#endif

#if HAS_SWSERIAL
#include "SoftwareSerial.h"
#endif

#if ENABLED(SRAM_EEPROM_EMULATION)
#if STM32F7xx
#include "stm32f7xx_ll_pwr.h"
Expand Down Expand Up @@ -82,6 +92,10 @@ void HAL_init() {
// Wait until backup regulator is initialized
while (!LL_PWR_IsActiveFlag_BRR());
#endif // EEPROM_EMULATED_SRAM

#if HAS_SWSERIAL
SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0);
#endif
}

void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); }
Expand Down
Loading

0 comments on commit f1d1e09

Please sign in to comment.