Prusa MINI Firmware overview
endstops.cpp File Reference
#include "endstops.h"
#include "stepper.h"
#include "../Marlin.h"
#include "../sd/cardreader.h"
#include "temperature.h"
#include "../lcd/ultralcd.h"

Macros

#define _SET_STOP_CHAR(A, C)   ;
 
#define _ENDSTOP_HIT_ECHO(A, C)
 
#define _ENDSTOP_HIT_TEST(A, C)
 
#define ENDSTOP_HIT_TEST_X()   _ENDSTOP_HIT_TEST(X,'X')
 
#define ENDSTOP_HIT_TEST_Y()   _ENDSTOP_HIT_TEST(Y,'Y')
 
#define ENDSTOP_HIT_TEST_Z()   _ENDSTOP_HIT_TEST(Z,'Z')
 
#define ES_REPORT(S)   print_es_state(READ(S##_PIN) != S##_ENDSTOP_INVERTING, PSTR(MSG_##S))
 
#define _ENDSTOP(AXIS, MINMAX)   AXIS ##_## MINMAX
 
#define _ENDSTOP_PIN(AXIS, MINMAX)   AXIS ##_## MINMAX ##_PIN
 
#define _ENDSTOP_INVERTING(AXIS, MINMAX)   AXIS ##_## MINMAX ##_ENDSTOP_INVERTING
 
#define UPDATE_ENDSTOP_BIT(AXIS, MINMAX)   SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)))
 
#define COPY_LIVE_STATE(SRC_BIT, DST_BIT)   SET_BIT_TO(live_state, DST_BIT, TEST(live_state, SRC_BIT))
 
#define X_MIN_TEST   true
 
#define X_MAX_TEST   true
 
#define X_AXIS_HEAD   X_HEAD
 
#define Y_AXIS_HEAD   Y_HEAD
 
#define Z_AXIS_HEAD   Z_HEAD
 
#define TEST_ENDSTOP(ENDSTOP)   (TEST(state(), ENDSTOP))
 
#define _ENDSTOP_HIT(AXIS, MINMAX)   SBI(hit_state, _ENDSTOP(AXIS, MINMAX))
 
#define PROCESS_ENDSTOP(AXIS, MINMAX)
 
#define PROCESS_DUAL_ENDSTOP(AXIS1, AXIS2, MINMAX)
 
#define PROCESS_TRIPLE_ENDSTOP(AXIS1, AXIS2, AXIS3, MINMAX)
 

Functions

static void print_es_state (const bool is_hit, PGM_P const label=nullptr)
 

Variables

Endstops endstops
 

Macro Definition Documentation

◆ _SET_STOP_CHAR

#define _SET_STOP_CHAR (   A,
 
)    ;

◆ _ENDSTOP_HIT_ECHO

#define _ENDSTOP_HIT_ECHO (   A,
 
)
Value:
do{ \
SERIAL_ECHOPAIR(" " STRINGIFY(A) ":", planner.triggered_position_mm(_AXIS(A))); \
_SET_STOP_CHAR(A,C); }while(0)

◆ _ENDSTOP_HIT_TEST

#define _ENDSTOP_HIT_TEST (   A,
 
)
Value:
if (TEST(hit_state, A ##_MIN) || TEST(hit_state, A ##_MAX)) \
_ENDSTOP_HIT_ECHO(A,C)

◆ ENDSTOP_HIT_TEST_X

#define ENDSTOP_HIT_TEST_X ( )    _ENDSTOP_HIT_TEST(X,'X')

◆ ENDSTOP_HIT_TEST_Y

#define ENDSTOP_HIT_TEST_Y ( )    _ENDSTOP_HIT_TEST(Y,'Y')

◆ ENDSTOP_HIT_TEST_Z

#define ENDSTOP_HIT_TEST_Z ( )    _ENDSTOP_HIT_TEST(Z,'Z')

◆ ES_REPORT

#define ES_REPORT (   S)    print_es_state(READ(S##_PIN) != S##_ENDSTOP_INVERTING, PSTR(MSG_##S))

◆ _ENDSTOP

#define _ENDSTOP (   AXIS,
  MINMAX 
)    AXIS ##_## MINMAX

◆ _ENDSTOP_PIN

#define _ENDSTOP_PIN (   AXIS,
  MINMAX 
)    AXIS ##_## MINMAX ##_PIN

◆ _ENDSTOP_INVERTING

#define _ENDSTOP_INVERTING (   AXIS,
  MINMAX 
)    AXIS ##_## MINMAX ##_ENDSTOP_INVERTING

◆ UPDATE_ENDSTOP_BIT

#define UPDATE_ENDSTOP_BIT (   AXIS,
  MINMAX 
)    SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)))

◆ COPY_LIVE_STATE

#define COPY_LIVE_STATE (   SRC_BIT,
  DST_BIT 
)    SET_BIT_TO(live_state, DST_BIT, TEST(live_state, SRC_BIT))

◆ X_MIN_TEST

#define X_MIN_TEST   true

◆ X_MAX_TEST

#define X_MAX_TEST   true

◆ X_AXIS_HEAD

#define X_AXIS_HEAD   X_HEAD

◆ Y_AXIS_HEAD

#define Y_AXIS_HEAD   Y_HEAD

◆ Z_AXIS_HEAD

#define Z_AXIS_HEAD   Z_HEAD

◆ TEST_ENDSTOP

#define TEST_ENDSTOP (   ENDSTOP)    (TEST(state(), ENDSTOP))

◆ _ENDSTOP_HIT

#define _ENDSTOP_HIT (   AXIS,
  MINMAX 
)    SBI(hit_state, _ENDSTOP(AXIS, MINMAX))

◆ PROCESS_ENDSTOP

#define PROCESS_ENDSTOP (   AXIS,
  MINMAX 
)
Value:
do { \
if (TEST_ENDSTOP(_ENDSTOP(AXIS, MINMAX))) { \
_ENDSTOP_HIT(AXIS, MINMAX); \
planner.endstop_triggered(_AXIS(AXIS)); \
} \
}while(0)

◆ PROCESS_DUAL_ENDSTOP

#define PROCESS_DUAL_ENDSTOP (   AXIS1,
  AXIS2,
  MINMAX 
)
Value:
do { \
const byte dual_hit = TEST_ENDSTOP(_ENDSTOP(AXIS1, MINMAX)) | (TEST_ENDSTOP(_ENDSTOP(AXIS2, MINMAX)) << 1); \
if (dual_hit) { \
_ENDSTOP_HIT(AXIS1, MINMAX); \
/* if not performing home or if both endstops were trigged during homing... */ \
if (!stepper.separate_multi_axis || dual_hit == 0b11) \
planner.endstop_triggered(_AXIS(AXIS1)); \
} \
}while(0)

◆ PROCESS_TRIPLE_ENDSTOP

#define PROCESS_TRIPLE_ENDSTOP (   AXIS1,
  AXIS2,
  AXIS3,
  MINMAX 
)
Value:
do { \
const byte triple_hit = TEST_ENDSTOP(_ENDSTOP(AXIS1, MINMAX)) | (TEST_ENDSTOP(_ENDSTOP(AXIS2, MINMAX)) << 1) | (TEST_ENDSTOP(_ENDSTOP(AXIS3, MINMAX)) << 2); \
if (triple_hit) { \
_ENDSTOP_HIT(AXIS1, MINMAX); \
/* if not performing home or if both endstops were trigged during homing... */ \
if (!stepper.separate_multi_axis || triple_hit == 0b111) \
planner.endstop_triggered(_AXIS(AXIS1)); \
} \
}while(0)

Function Documentation

◆ print_es_state()

static void print_es_state ( const bool  is_hit,
PGM_P const  label = nullptr 
)
static
391  {
392  if (label) serialprintPGM(label);
393  SERIAL_ECHOPGM(": ");
395  SERIAL_EOL();
396 }
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ endstops

Endstops endstops

Marlin 3D Printer Firmware Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]

Based on Sprinter and grbl. Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. endstops.cpp - A singleton object to manage endstops

Stepper::separate_multi_axis
static bool separate_multi_axis
Definition: stepper.h:231
_ENDSTOP
#define _ENDSTOP(AXIS, MINMAX)
Definition: endstops.cpp:491
stepper
Stepper stepper
Definition: stepper.cpp:82
_MAX
#define _MAX(V...)
Definition: macros.h:346
_AXIS
#define _AXIS(A)
Definition: macros.h:30
_MIN
#define _MIN(V...)
Definition: macros.h:333
STRINGIFY
#define STRINGIFY(M)
Definition: macros.h:73
A
#define A(CODE)
Definition: macros.h:75
MSG_ENDSTOP_HIT
#define MSG_ENDSTOP_HIT
Definition: language.h:215
PSTR
#define PSTR(str)
Definition: pgmspace.h:31
SERIAL_ECHOPGM
#define SERIAL_ECHOPGM(S)
Definition: serial.h:173
MSG_ENDSTOP_OPEN
#define MSG_ENDSTOP_OPEN
Definition: language.h:216
SERIAL_EOL
#define SERIAL_EOL()
Definition: serial.h:181
Planner::triggered_position_mm
static float triggered_position_mm(const AxisEnum axis)
Definition: planner.cpp:1513
TEST
#define TEST(n, b)
Definition: macros.h:81
serialprintPGM
void serialprintPGM(PGM_P str)
Definition: serial.cpp:35
TEST_ENDSTOP
#define TEST_ENDSTOP(ENDSTOP)
planner
Planner planner
Definition: planner.cpp:111