From 631addbbb4d03151520f935a00c00a501f097e07 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 4 Mar 2020 13:15:32 -0600 Subject: [PATCH] SAMD51 SoftwareSerial (#17041) --- Marlin/src/HAL/HAL_SAMD51/fastio.h | 2 +- Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h | 12 ++++-------- Marlin/src/HAL/HAL_SAMD51/timers.cpp | 8 ++++---- Marlin/src/HAL/HAL_SAMD51/timers.h | 12 ++++++------ platformio.ini | 16 ++++++++-------- 5 files changed, 23 insertions(+), 27 deletions(-) diff --git a/Marlin/src/HAL/HAL_SAMD51/fastio.h b/Marlin/src/HAL/HAL_SAMD51/fastio.h index e00fa77a7..f6a2675de 100644 --- a/Marlin/src/HAL/HAL_SAMD51/fastio.h +++ b/Marlin/src/HAL/HAL_SAMD51/fastio.h @@ -37,7 +37,7 @@ /** * Magic I/O routines * - * Now you can simply SET_OUTPUT(STEP); WRITE(STEP, HIGH); WRITE(STEP, LOW); + * Now you can simply SET_OUTPUT(IO); WRITE(IO, HIGH); WRITE(IO, LOW); */ // Read a pin diff --git a/Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h b/Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h index ddea64f2d..04c137c34 100644 --- a/Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h +++ b/Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h @@ -23,6 +23,10 @@ * Test SAMD51 specific configuration values for errors at compile-time. */ +#if ENABLED(EEPROM_SETTINGS) && NONE(SPI_EEPROM, I2C_EEPROM) + #warning "Did you activate the SmartEEPROM? See https://github.com/GMagician/SAMD51-SmartEEprom-Manager/releases" +#endif + #if defined(ADAFRUIT_GRAND_CENTRAL_M4) && SD_CONNECTION_IS(CUSTOM_CABLE) #error "No custom SD drive cable defined for this board." #endif @@ -42,11 +46,3 @@ #if ENABLED(FAST_PWM_FAN) #error "FAST_PWM_FAN is not yet implemented for this platform." #endif - -#if ENABLED(EEPROM_SETTINGS) && NONE(SPI_EEPROM, I2C_EEPROM) - #warning "Did you activate the SmartEEPROM? See https://github.com/GMagician/SAMD51-SmartEEprom-Manager/releases" -#endif - -#if HAS_TMC_SW_SERIAL - #error "TMC220x Software Serial is not supported on this platform." -#endif diff --git a/Marlin/src/HAL/HAL_SAMD51/timers.cpp b/Marlin/src/HAL/HAL_SAMD51/timers.cpp index 99839cd48..3eb021c25 100644 --- a/Marlin/src/HAL/HAL_SAMD51/timers.cpp +++ b/Marlin/src/HAL/HAL_SAMD51/timers.cpp @@ -42,7 +42,7 @@ const tTimerConfig TimerConfig[NUM_HARDWARE_TIMERS+1] = { { {.pTc=TC1}, TC1_IRQn, TC_PRIORITY(1) }, // 1 - stepper (needed by 32 bit timers) { {.pTc=TC2}, TC2_IRQn, TC_PRIORITY(2) }, // 2 - tone (framework) { {.pTc=TC3}, TC3_IRQn, TC_PRIORITY(3) }, // 3 - servo - { {.pTc=TC4}, TC4_IRQn, TC_PRIORITY(4) }, + { {.pTc=TC4}, TC4_IRQn, TC_PRIORITY(4) }, // 4 - software serial { {.pTc=TC5}, TC5_IRQn, TC_PRIORITY(5) }, { {.pTc=TC6}, TC6_IRQn, TC_PRIORITY(6) }, { {.pTc=TC7}, TC7_IRQn, TC_PRIORITY(7) }, @@ -145,12 +145,12 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { } void HAL_timer_enable_interrupt(const uint8_t timer_num) { - IRQn_Type irq = TimerConfig[timer_num].IRQ_Id; + const IRQn_Type irq = TimerConfig[timer_num].IRQ_Id; NVIC_EnableIRQ(irq); } void HAL_timer_disable_interrupt(const uint8_t timer_num) { - IRQn_Type irq = TimerConfig[timer_num].IRQ_Id; + const IRQn_Type irq = TimerConfig[timer_num].IRQ_Id; Disable_Irq(irq); } @@ -160,7 +160,7 @@ static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) { } bool HAL_timer_interrupt_enabled(const uint8_t timer_num) { - IRQn_Type irq = TimerConfig[timer_num].IRQ_Id; + const IRQn_Type irq = TimerConfig[timer_num].IRQ_Id; return NVIC_GetEnabledIRQ(irq); } diff --git a/Marlin/src/HAL/HAL_SAMD51/timers.h b/Marlin/src/HAL/HAL_SAMD51/timers.h index 073239c43..4b21e4716 100644 --- a/Marlin/src/HAL/HAL_SAMD51/timers.h +++ b/Marlin/src/HAL/HAL_SAMD51/timers.h @@ -57,16 +57,16 @@ typedef uint32_t hal_timer_t; : (t == TEMP_TIMER_NUM) ? 6 \ : 7 -#define _TC_HANDLER(t) void TC##t##_Handler() -#define TC_HANDLER(t) _TC_HANDLER(t) -#define HAL_STEP_TIMER_ISR() TC_HANDLER(STEP_TIMER_NUM) +#define _TC_HANDLER(t) void TC##t##_Handler() +#define TC_HANDLER(t) _TC_HANDLER(t) +#define HAL_STEP_TIMER_ISR() TC_HANDLER(STEP_TIMER_NUM) #if STEP_TIMER_NUM != PULSE_TIMER_NUM - #define HAL_PULSE_TIMER_ISR() TC_HANDLER(PULSE_TIMER_NUM) + #define HAL_PULSE_TIMER_ISR() TC_HANDLER(PULSE_TIMER_NUM) #endif #if TEMP_TIMER_NUM == RTC_TIMER_NUM - #define HAL_TEMP_TIMER_ISR() void RTC_Handler() + #define HAL_TEMP_TIMER_ISR() void RTC_Handler() #else - #define HAL_TEMP_TIMER_ISR() TC_HANDLER(TEMP_TIMER_NUM) + #define HAL_TEMP_TIMER_ISR() TC_HANDLER(TEMP_TIMER_NUM) #endif // -------------------------------------------------------------------------- diff --git a/platformio.ini b/platformio.ini index 89afb9123..c57c1818b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -771,20 +771,20 @@ src_build_flags = -Wall -IMarlin/src/HAL/HAL_LINUX/include build_unflags = -Wall lib_ldf_mode = off lib_deps = -extra_scripts = src_filter = ${common.default_src_filter} + # # Adafruit Grand Central M4 (Atmel SAMD51P20A ARM Cortex-M4) # [env:SAMD51_grandcentral_m4] -platform = atmelsam -board = adafruit_grandcentral_m4 -build_flags = ${common.build_flags} -std=gnu++17 -extra_scripts = ${common.extra_scripts} -build_unflags = -std=gnu++11 -src_filter = ${common.default_src_filter} + -debug_tool = jlink +platform = atmelsam +board = adafruit_grandcentral_m4 +build_flags = ${common.build_flags} -std=gnu++17 -Wno-register +build_unflags = -std=gnu++11 +src_filter = ${common.default_src_filter} + +lib_deps = ${common.lib_deps} + SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip +debug_tool = jlink # # RUMBA32