General cleanup ahead of L64XX

This commit is contained in:
Scott Lahteine 2019-03-01 19:29:48 -06:00
parent 2f1e1dcb42
commit fa236e9718
11 changed files with 25 additions and 41 deletions

View file

@ -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.

View file

@ -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)

View file

@ -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"

View file

@ -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[]);

View file

@ -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(' ');
}
}

View file

@ -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<typename T>
class restorer {
T& ref_;

View file

@ -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?)");

View file

@ -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)
```

View file

@ -19,6 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#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;

View file

@ -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;

View file

@ -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