From fa236e9718cd2feb85a1986b8f56ad97cd2f4871 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 1 Mar 2019 19:29:48 -0600 Subject: [PATCH] General cleanup ahead of L64XX --- Marlin/src/HAL/shared/HAL_spi_L6470.cpp | 16 ---------------- Marlin/src/Marlin.h | 3 --- Marlin/src/core/serial.cpp | 9 +++++++++ Marlin/src/core/serial.h | 2 ++ Marlin/src/core/utility.cpp | 7 ------- Marlin/src/core/utility.h | 2 -- Marlin/src/inc/SanityCheck.h | 2 +- Marlin/src/libs/L6470/000_l6470_read_me.md | 18 +++++++++--------- Marlin/src/libs/L6470/L6470_Marlin.h | 3 ++- Marlin/src/module/temperature.h | 2 +- Marlin/src/sd/cardreader.h | 2 +- 11 files changed, 25 insertions(+), 41 deletions(-) diff --git a/Marlin/src/HAL/shared/HAL_spi_L6470.cpp b/Marlin/src/HAL/shared/HAL_spi_L6470.cpp index f3a4544a7..f3c5a31f6 100644 --- a/Marlin/src/HAL/shared/HAL_spi_L6470.cpp +++ b/Marlin/src/HAL/shared/HAL_spi_L6470.cpp @@ -25,31 +25,15 @@ * Copyright (C) 2009 by William Greiman */ -// -------------------------------------------------------------------------- -// Includes -// -------------------------------------------------------------------------- - #include "../../inc/MarlinConfig.h" #if HAS_DRIVER(L6470) #include "Delay.h" -// -------------------------------------------------------------------------- -// Public Variables -// -------------------------------------------------------------------------- - -// -------------------------------------------------------------------------- -// Public functions -// -------------------------------------------------------------------------- - #include "../../core/serial.h" #include "../../libs/L6470/L6470_Marlin.h" -// -------------------------------------------------------------------------- -// Software L6470 SPI -// -------------------------------------------------------------------------- - // Make sure GCC optimizes this file. // Note that this line triggers a bug in GCC which is fixed by casting. // See the note below. diff --git a/Marlin/src/Marlin.h b/Marlin/src/Marlin.h index cac22c902..bea5c358c 100644 --- a/Marlin/src/Marlin.h +++ b/Marlin/src/Marlin.h @@ -142,8 +142,6 @@ void manage_inactivity(const bool ignore_stepper_queue=false); #define enable_Z() do{ Z_enable; Z2_enable; Z3_enable; }while(0) #define disable_Z() do{ Z_disable; Z2_disable; Z3_disable; CBI(axis_known_position, Z_AXIS); }while(0) -// end X, Y, Z Stepper enable / disable - // // Extruder Stepper enable / disable // @@ -220,7 +218,6 @@ void manage_inactivity(const bool ignore_stepper_queue=false); #define E5_enable NOOP #define E5_disable NOOP #endif -// end individual enables/disables #if ENABLED(MIXING_EXTRUDER) diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 2e233d973..eb39f389a 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -52,6 +52,15 @@ void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (c void serialprint_onoff(const bool onoff) { serialprintPGM(onoff ? PSTR(MSG_ON) : PSTR(MSG_OFF)); } void serialprintln_onoff(const bool onoff) { serialprint_onoff(onoff); SERIAL_EOL(); } +void print_bin(const uint16_t val) { + uint16_t mask = 0x8000; + for (uint8_t i = 16; i--;) { + if (i && !(i % 4)) SERIAL_CHAR(' '); + SERIAL_CHAR((val & mask) ? '1' : '0'); + mask >>= 1; + } +} + #if ENABLED(DEBUG_LEVELING_FEATURE) #include "enum.h" diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index a248014c6..b2d0f73b3 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -114,6 +114,8 @@ void serialprint_onoff(const bool onoff); void serialprintln_onoff(const bool onoff); void serial_spaces(uint8_t count); +void print_bin(const uint16_t val); + #if ENABLED(DEBUG_LEVELING_FEATURE) void print_xyz(PGM_P const prefix, PGM_P const suffix, const float x, const float y, const float z); void print_xyz(PGM_P const prefix, PGM_P const suffix, const float xyz[]); diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index b1a7e4292..e2b44141d 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -441,10 +441,3 @@ void safe_delay(millis_t ms) { } #endif // DEBUG_LEVELING_FEATURE - -void print_bin(const uint16_t val) { - for (uint8_t i = 16; i--;) { - SERIAL_ECHO(TEST(val, i)); - if (!(i & 0x3)) SERIAL_CHAR(' '); - } -} diff --git a/Marlin/src/core/utility.h b/Marlin/src/core/utility.h index 3a24608eb..46dcd5af6 100644 --- a/Marlin/src/core/utility.h +++ b/Marlin/src/core/utility.h @@ -120,8 +120,6 @@ inline void serial_delay(const millis_t ms) { void log_machine_info(); #endif -void print_bin(const uint16_t val); - template class restorer { T& ref_; diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 13d1331df..6965d8bdd 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1953,7 +1953,7 @@ constexpr float sanity_arr_1[] = DEFAULT_AXIS_STEPS_PER_UNIT, sanity_arr_2[] = DEFAULT_MAX_FEEDRATE, sanity_arr_3[] = DEFAULT_MAX_ACCELERATION; -#define _ARR_TEST(N,I) (sanity_arr_##N[MIN(I,COUNT(sanity_arr_##N)-1)] > 0) +#define _ARR_TEST(N,I) (sanity_arr_##N[MIN(I,int(COUNT(sanity_arr_##N))-1)] > 0) static_assert(COUNT(sanity_arr_1) >= XYZE, "DEFAULT_AXIS_STEPS_PER_UNIT requires X, Y, Z and E elements."); static_assert(COUNT(sanity_arr_1) <= XYZE_N, "DEFAULT_AXIS_STEPS_PER_UNIT has too many elements. (Did you forget to enable DISTINCT_E_FACTORS?)"); diff --git a/Marlin/src/libs/L6470/000_l6470_read_me.md b/Marlin/src/libs/L6470/000_l6470_read_me.md index 170ba6596..712ced551 100644 --- a/Marlin/src/libs/L6470/000_l6470_read_me.md +++ b/Marlin/src/libs/L6470/000_l6470_read_me.md @@ -6,20 +6,20 @@ These devices use voltage PWMs to drive the stepper phases. Phase current is not This software assumes that all L6470 drivers are in one SPI daisy chain. -``` {.gcode} +``` The hardware setup is: - MOSI from controller tied to SDI on the first device + MOSI from controller tied to SDI on the first device - SDO of the first device is tied to SDI of the next device + SDO of the first device is tied to SDI of the next device - SDO of the last device is tied to MISO of the controller + SDO of the last device is tied to MISO of the controller - all devices share the same SCK, SS\_PIN and RESET\_PIN + all devices share the same SCK, SS\_PIN and RESET\_PIN - Each L6470 passes the data it saw on its SDI to its neighbor on the **NEXT** SPI cycle (8 bit delay). + Each L6470 passes the data it saw on its SDI to its neighbor on the **NEXT** SPI cycle (8 bit delay). - Each L6470 acts on the **last** SPI data it saw when the SS\_PIN **goes high**. + Each L6470 acts on the **last** SPI data it saw when the SS\_PIN **goes high**. ``` The L6470 drivers operate in STEP\_CLOCK mode. In this mode the direction and enable are done via SPI commands and the phase currents are changed in response to step pulses (generated in the usual way). @@ -58,12 +58,12 @@ The steppers are **NOT** powered up during this sequence. This array is used by all routines that transmit SPI data. -``` {.gcode} +``` Location 0 - number of drivers in chain Location 1 - axis index for first device in the chain (closest to MOSI) - … + ... Location N - axis index for last device in the N device long chain (closest to MISO) ``` diff --git a/Marlin/src/libs/L6470/L6470_Marlin.h b/Marlin/src/libs/L6470/L6470_Marlin.h index b2bbcc2ee..a29e40739 100644 --- a/Marlin/src/libs/L6470/L6470_Marlin.h +++ b/Marlin/src/libs/L6470/L6470_Marlin.h @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ +#pragma once #include "../../inc/MarlinConfig.h" @@ -61,7 +62,7 @@ public: static char index_to_axis[MAX_L6470][3]; static uint8_t dir_commands[MAX_L6470]; - // flags to guarantee graceful switch if stepper interrupts L6470 SPI transfer + // Flags to guarantee graceful switch if stepper interrupts L6470 SPI transfer static volatile bool spi_abort; static bool spi_active; diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 0e1a132fb..fd0706e20 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -640,7 +640,7 @@ class Temperature { static uint8_t auto_report_temp_interval; static millis_t next_temp_report_ms; static void auto_report_temperatures(void); - FORCE_INLINE void set_auto_report_interval(uint8_t v) { + static inline void set_auto_report_interval(uint8_t v) { NOMORE(v, 60); auto_report_temp_interval = v; next_temp_report_ms = millis() + 1000UL * v; diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index a13633eaf..44a698bd5 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -128,7 +128,7 @@ public: #if ENABLED(AUTO_REPORT_SD_STATUS) static void auto_report_sd_status(void); - static inline void set_auto_report_interval(const uint8_t v) { + static inline void set_auto_report_interval(uint8_t v) { #if NUM_SERIAL > 1 auto_report_port = serial_port_index; #endif