From 9fd35c84ce722c71b6d42b2c618c93ca66f2537f Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Tue, 12 Nov 2019 20:16:54 -0800 Subject: [PATCH] SoftwareSerialM for SKR STM32F1 boards (#15875) --- Marlin/src/HAL/HAL_AVR/HAL.h | 2 +- Marlin/src/HAL/HAL_ESP32/WebSocketSerial.h | 2 +- Marlin/src/HAL/HAL_ESP32/i2s.cpp | 8 ++++---- Marlin/src/HAL/HAL_ESP32/ota.cpp | 2 +- Marlin/src/HAL/HAL_ESP32/timers.cpp | 8 ++++---- Marlin/src/HAL/HAL_ESP32/timers.h | 2 +- Marlin/src/HAL/HAL_LPC1768/HAL_SPI.cpp | 2 +- Marlin/src/HAL/HAL_LPC1768/persistent_store_flash.cpp | 2 +- .../HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_sw_spi.cpp | 2 +- .../HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp | 2 +- Marlin/src/HAL/HAL_LPC1768/watchdog.cpp | 2 +- Marlin/src/HAL/HAL_SAMD51/HAL.cpp | 4 ++-- Marlin/src/HAL/HAL_STM32/HAL.cpp | 6 +++--- Marlin/src/HAL/HAL_STM32/timers.cpp | 2 +- Marlin/src/HAL/HAL_STM32F1/HAL.cpp | 2 +- Marlin/src/HAL/HAL_STM32F1/SoftwareSerial.h | 4 +++- Marlin/src/HAL/HAL_STM32F1/inc/SanityCheck.h | 5 +++++ Marlin/src/HAL/HAL_STM32_F4_F7/HAL.cpp | 2 +- Marlin/src/core/drivers.h | 2 +- .../variants/BIGTREE_SKR_PRO_1v1/PeripheralPins.c | 2 +- platformio.ini | 6 ++++-- 21 files changed, 39 insertions(+), 30 deletions(-) diff --git a/Marlin/src/HAL/HAL_AVR/HAL.h b/Marlin/src/HAL/HAL_AVR/HAL.h index 0d2a1bc2c..e6d968367 100644 --- a/Marlin/src/HAL/HAL_AVR/HAL.h +++ b/Marlin/src/HAL/HAL_AVR/HAL.h @@ -25,7 +25,7 @@ #include "math.h" #ifdef USBCON - #include "HardwareSerial.h" + #include #else #define HardwareSerial_h // Hack to prevent HardwareSerial.h header inclusion #include "MarlinSerial.h" diff --git a/Marlin/src/HAL/HAL_ESP32/WebSocketSerial.h b/Marlin/src/HAL/HAL_ESP32/WebSocketSerial.h index 9590271b0..85436d151 100644 --- a/Marlin/src/HAL/HAL_ESP32/WebSocketSerial.h +++ b/Marlin/src/HAL/HAL_ESP32/WebSocketSerial.h @@ -23,7 +23,7 @@ #include "../../inc/MarlinConfig.h" -#include "Stream.h" +#include #ifndef RX_BUFFER_SIZE #define RX_BUFFER_SIZE 128 diff --git a/Marlin/src/HAL/HAL_ESP32/i2s.cpp b/Marlin/src/HAL/HAL_ESP32/i2s.cpp index 1f7c508cf..33a503455 100644 --- a/Marlin/src/HAL/HAL_ESP32/i2s.cpp +++ b/Marlin/src/HAL/HAL_ESP32/i2s.cpp @@ -26,10 +26,10 @@ #include "i2s.h" #include "../shared/Marduino.h" -#include "driver/periph_ctrl.h" -#include "rom/lldesc.h" -#include "soc/i2s_struct.h" -#include "freertos/queue.h" +#include +#include +#include +#include #include "../../module/stepper.h" #define DMA_BUF_COUNT 8 // number of DMA buffers to store data diff --git a/Marlin/src/HAL/HAL_ESP32/ota.cpp b/Marlin/src/HAL/HAL_ESP32/ota.cpp index 98ea3b5eb..377856f8d 100644 --- a/Marlin/src/HAL/HAL_ESP32/ota.cpp +++ b/Marlin/src/HAL/HAL_ESP32/ota.cpp @@ -27,7 +27,7 @@ #include #include #include -#include "driver/timer.h" +#include void OTA_init() { ArduinoOTA diff --git a/Marlin/src/HAL/HAL_ESP32/timers.cpp b/Marlin/src/HAL/HAL_ESP32/timers.cpp index 79a79e37c..543889760 100644 --- a/Marlin/src/HAL/HAL_ESP32/timers.cpp +++ b/Marlin/src/HAL/HAL_ESP32/timers.cpp @@ -23,10 +23,10 @@ #ifdef ARDUINO_ARCH_ESP32 #include -#include "esp_types.h" -#include "soc/timer_group_struct.h" -#include "driver/periph_ctrl.h" -#include "driver/timer.h" +#include +#include +#include +#include #include "HAL.h" diff --git a/Marlin/src/HAL/HAL_ESP32/timers.h b/Marlin/src/HAL/HAL_ESP32/timers.h index 98e43a4a8..e6e3495be 100644 --- a/Marlin/src/HAL/HAL_ESP32/timers.h +++ b/Marlin/src/HAL/HAL_ESP32/timers.h @@ -22,7 +22,7 @@ #pragma once #include -#include "driver/timer.h" +#include // Includes needed to get I2S_STEPPER_STREAM. Note that pins.h // is included in case this header is being included early. diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL_SPI.cpp b/Marlin/src/HAL/HAL_LPC1768/HAL_SPI.cpp index bfbf35c04..5f32c7874 100644 --- a/Marlin/src/HAL/HAL_LPC1768/HAL_SPI.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/HAL_SPI.cpp @@ -56,7 +56,7 @@ // ------------------------ #if ENABLED(LPC_SOFTWARE_SPI) - #include "SoftwareSPI.h" + #include // Software SPI diff --git a/Marlin/src/HAL/HAL_LPC1768/persistent_store_flash.cpp b/Marlin/src/HAL/HAL_LPC1768/persistent_store_flash.cpp index dac7d7a3a..3de02022e 100644 --- a/Marlin/src/HAL/HAL_LPC1768/persistent_store_flash.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/persistent_store_flash.cpp @@ -46,7 +46,7 @@ #if ENABLED(FLASH_EEPROM_EMULATION) extern "C" { - #include "lpc17xx_iap.h" + #include } #define SECTOR_START(sector) ((sector < 16) ? (sector * 0x1000) : ((sector - 14) * 0x8000)) diff --git a/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_sw_spi.cpp b/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_sw_spi.cpp index 59414e896..0a1bd8487 100644 --- a/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_sw_spi.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_sw_spi.cpp @@ -60,7 +60,7 @@ #if ENABLED(U8GLIB_ST7920) #include -#include "SoftwareSPI.h" +#include #include "../../shared/Delay.h" #undef SPI_SPEED diff --git a/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp b/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp index 479b3811d..7b6557148 100644 --- a/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp @@ -59,7 +59,7 @@ #if HAS_GRAPHICAL_LCD && DISABLED(U8GLIB_ST7920) -#include "SoftwareSPI.h" +#include #undef SPI_SPEED #define SPI_SPEED 2 // About 2 MHz diff --git a/Marlin/src/HAL/HAL_LPC1768/watchdog.cpp b/Marlin/src/HAL/HAL_LPC1768/watchdog.cpp index f122bf998..6d0200e9f 100644 --- a/Marlin/src/HAL/HAL_LPC1768/watchdog.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/watchdog.cpp @@ -26,7 +26,7 @@ #if ENABLED(USE_WATCHDOG) -#include "lpc17xx_wdt.h" +#include #include "watchdog.h" void watchdog_init() { diff --git a/Marlin/src/HAL/HAL_SAMD51/HAL.cpp b/Marlin/src/HAL/HAL_SAMD51/HAL.cpp index 35863477e..1c53042f8 100644 --- a/Marlin/src/HAL/HAL_SAMD51/HAL.cpp +++ b/Marlin/src/HAL/HAL_SAMD51/HAL.cpp @@ -22,8 +22,8 @@ #ifdef __SAMD51__ #include "../../inc/MarlinConfig.h" -#include "Adafruit_ZeroDMA.h" -#include "wiring_private.h" +#include +#include // ------------------------ // Local defines diff --git a/Marlin/src/HAL/HAL_STM32/HAL.cpp b/Marlin/src/HAL/HAL_STM32/HAL.cpp index 1d8eb4447..4fbfa7298 100644 --- a/Marlin/src/HAL/HAL_STM32/HAL.cpp +++ b/Marlin/src/HAL/HAL_STM32/HAL.cpp @@ -36,13 +36,13 @@ #if HAS_SWSERIAL #include "SoftwareSerial.h" -#endif +#endif #if ENABLED(SRAM_EEPROM_EMULATION) #if STM32F7xx - #include "stm32f7xx_ll_pwr.h" + #include #elif STM32F4xx - #include "stm32f4xx_ll_pwr.h" + #include #else #error "SRAM_EEPROM_EMULATION is currently only supported for STM32F4xx and STM32F7xx" #endif diff --git a/Marlin/src/HAL/HAL_STM32/timers.cpp b/Marlin/src/HAL/HAL_STM32/timers.cpp index 709c447b0..c2a4cbdc0 100644 --- a/Marlin/src/HAL/HAL_STM32/timers.cpp +++ b/Marlin/src/HAL/HAL_STM32/timers.cpp @@ -91,7 +91,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { // This is fixed in Arduino_Core_STM32 1.8. // These calls can be removed and replaced with // timer_instance[timer_num]->setInterruptPriority - switch (timer_num) { + switch (timer_num) { case STEP_TIMER_NUM: HAL_NVIC_SetPriority(STEP_TIMER_IRQ_NAME, STEP_TIMER_IRQ_PRIO, 0); break; diff --git a/Marlin/src/HAL/HAL_STM32F1/HAL.cpp b/Marlin/src/HAL/HAL_STM32F1/HAL.cpp index cba41dd3c..afd6eff02 100644 --- a/Marlin/src/HAL/HAL_STM32F1/HAL.cpp +++ b/Marlin/src/HAL/HAL_STM32F1/HAL.cpp @@ -272,7 +272,7 @@ extern "C" { // return free memory between end of heap (or end bss) and whatever is current /* -#include "wirish/syscalls.c" +#include //extern caddr_t _sbrk(int incr); #ifndef CONFIG_HEAP_END extern char _lm_heap_end; diff --git a/Marlin/src/HAL/HAL_STM32F1/SoftwareSerial.h b/Marlin/src/HAL/HAL_STM32F1/SoftwareSerial.h index 0692b7e9f..330d7d632 100644 --- a/Marlin/src/HAL/HAL_STM32F1/SoftwareSerial.h +++ b/Marlin/src/HAL/HAL_STM32F1/SoftwareSerial.h @@ -20,7 +20,9 @@ #include -#define SW_SERIAL_PLACEHOLDER 1 +#ifndef HAVE_SW_SERIAL + #define SW_SERIAL_PLACEHOLDER 1 +#endif class SoftwareSerial { public: diff --git a/Marlin/src/HAL/HAL_STM32F1/inc/SanityCheck.h b/Marlin/src/HAL/HAL_STM32F1/inc/SanityCheck.h index f356c0da0..69466a0a7 100644 --- a/Marlin/src/HAL/HAL_STM32F1/inc/SanityCheck.h +++ b/Marlin/src/HAL/HAL_STM32F1/inc/SanityCheck.h @@ -36,3 +36,8 @@ #if ENABLED(FAST_PWM_FAN) #error "FAST_PWM_FAN is not yet implemented for this platform." #endif + +#if !defined(HAVE_SW_SERIAL) && HAS_TMC220x + #warning "With TMC2208/9 consider using SoftwareSerialM with HAVE_SW_SERIAL and appropriate SS_TIMER." + #error "Missing SoftwareSerial implementation." +#endif diff --git a/Marlin/src/HAL/HAL_STM32_F4_F7/HAL.cpp b/Marlin/src/HAL/HAL_STM32_F4_F7/HAL.cpp index 7ed6e2c10..e24483f64 100644 --- a/Marlin/src/HAL/HAL_STM32_F4_F7/HAL.cpp +++ b/Marlin/src/HAL/HAL_STM32_F4_F7/HAL.cpp @@ -64,7 +64,7 @@ extern "C" { // return free memory between end of heap (or end bss) and whatever is current /* -#include "wirish/syscalls.c" +#include //extern caddr_t _sbrk(int incr); #ifndef CONFIG_HEAP_END extern char _lm_heap_end; diff --git a/Marlin/src/core/drivers.h b/Marlin/src/core/drivers.h index 4400e0d78..44434581a 100644 --- a/Marlin/src/core/drivers.h +++ b/Marlin/src/core/drivers.h @@ -133,7 +133,7 @@ || HAS_E_DRIVER(TMC2660_STANDALONE) \ || HAS_E_DRIVER(TMC2209_STANDALONE) \ || HAS_E_DRIVER(TMC5130_STANDALONE) \ - || HAS_E_DRIVER(TMC5160_STANDALONE) ) + || HAS_E_DRIVER(TMC5160_STANDALONE) ) // // Stretching 'drivers.h' to include LPC/SAMD51 SD options // diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/PeripheralPins.c b/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/PeripheralPins.c index 9b92ee60a..a3f800baa 100644 --- a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/PeripheralPins.c @@ -122,7 +122,7 @@ const PinMap PinMap_PWM[] = { {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 FAN1 {PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 FAN2 {PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 EXTENSION1-4 - + //probably unused on SKR-Pro. confirmation needed, please. //{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 //{PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 diff --git a/platformio.ini b/platformio.ini index 5904ee837..11db00a6b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -301,9 +301,10 @@ board = genericSTM32F103RC platform_packages = tool-stm32duino extra_scripts = buildroot/share/PlatformIO/scripts/STM32F103RC_SKR_MINI.py build_flags = !python Marlin/src/HAL/HAL_STM32F1/build_flags.py - ${common.build_flags} -DDEBUG_LEVEL=0 -std=gnu++14 + ${common.build_flags} -DDEBUG_LEVEL=0 -std=gnu++14 -DHAVE_SW_SERIAL -DSS_TIMER=4 build_unflags = -std=gnu++11 lib_deps = ${common.lib_deps} + SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip lib_ignore = Adafruit NeoPixel, SPI src_filter = ${common.default_src_filter} + monitor_speed = 115200 @@ -315,9 +316,10 @@ board = genericSTM32F103RC platform_packages = tool-stm32duino extra_scripts = buildroot/share/PlatformIO/scripts/STM32F103RC_SKR_MINI.py build_flags = !python Marlin/src/HAL/HAL_STM32F1/build_flags.py - ${common.build_flags} -DDEBUG_LEVEL=0 -std=gnu++14 -DUSE_USB_COMPOSITE + ${common.build_flags} -DDEBUG_LEVEL=0 -std=gnu++14 -DUSE_USB_COMPOSITE -DHAVE_SW_SERIAL -DSS_TIMER=4 build_unflags = -std=gnu++11 lib_deps = ${common.lib_deps} + SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip lib_ignore = Adafruit NeoPixel, SPI src_filter = ${common.default_src_filter} + monitor_speed = 115200