Skip to main content
Homepage
Explore
Search or go to…
/
Register
Sign in
Explore
Primary navigation
Project
M
marlin-anet-a8
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Collapse sidebar
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Leder
marlin-anet-a8
Commits
79a44a9d
Commit
79a44a9d
authored
Apr 24, 2015
by
Wurstnase
Browse files
Options
Downloads
Patches
Plain Diff
stepper.cpp macros rework
delete some tabs
parent
075386e7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Marlin/stepper.cpp
+71
-50
71 additions, 50 deletions
Marlin/stepper.cpp
with
71 additions
and
50 deletions
Marlin/stepper.cpp
+
71
−
50
View file @
79a44a9d
...
@@ -463,14 +463,22 @@ ISR(TIMER1_COMPA_vect) {
...
@@ -463,14 +463,22 @@ ISR(TIMER1_COMPA_vect) {
count_direction
[
Y_AXIS
]
=
1
;
count_direction
[
Y_AXIS
]
=
1
;
}
}
#define _ENDSTOP(axis, minmax) axis ##_## minmax ##_endstop
#define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN
#define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING
#define _OLD_ENDSTOP(axis, minmax) old_## axis ##_## minmax ##_endstop
#define _AXIS(AXIS) AXIS ##_AXIS
#define _ENDSTOP_HIT(axis) endstop_## axis ##_hit
#define UPDATE_ENDSTOP(axis,AXIS,minmax,MINMAX) \
#define UPDATE_ENDSTOP(axis,AXIS,minmax,MINMAX) \
bool
axis ##_## minmax ##_endstop = (READ(AXIS ##_## MINMAX ##_PIN) != AXIS ##_##
MINMAX
##
_ENDSTOP_INVERTING); \
bool
_ENDSTOP(axis, minmax) = (READ(_ENDSTOP_PIN(AXIS,
MINMAX
)) !=
_ENDSTOP_INVERTING
(AXIS, MINMAX)
); \
if (
axis ##_## minmax ##_endstop && old_## axis ##_## minmax ##_endstop
&& (current_block->steps[AXIS
##_
AXIS] > 0)) { \
if (
_ENDSTOP(axis, minmax) && _OLD_ENDSTOP(axis, minmax)
&& (current_block->steps[
_
AXIS
(
AXIS
)
] > 0)) { \
endstops_trigsteps[AXIS
##_
AXIS] = count_position[AXIS
##_
AXIS]; \
endstops_trigsteps[
_
AXIS
(
AXIS
)
] = count_position[
_
AXIS
(
AXIS
)
]; \
endstop_## axis ##_hit
= true; \
_ENDSTOP_HIT(axis)
= true; \
step_events_completed = current_block->step_event_count; \
step_events_completed = current_block->step_event_count; \
} \
} \
old_## axis ##_## minmax ##_endstop = axis ##_## minmax ##_endstop;
_OLD_ENDSTOP(axis, minmax) = _ENDSTOP(axis, minmax);
// Check X and Y endstops
// Check X and Y endstops
if
(
check_endstops
)
{
if
(
check_endstops
)
{
...
@@ -667,6 +675,11 @@ ISR(TIMER1_COMPA_vect) {
...
@@ -667,6 +675,11 @@ ISR(TIMER1_COMPA_vect) {
}
}
#endif //ADVANCE
#endif //ADVANCE
#define _COUNTER(axis) counter_## axis
#define _WRITE_STEP(AXIS, HIGHLOW) AXIS ##_STEP_WRITE(HIGHLOW)
#define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP
#define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN
#ifdef CONFIG_STEPPERS_TOSHIBA
#ifdef CONFIG_STEPPERS_TOSHIBA
/**
/**
* The Toshiba stepper controller require much longer pulses.
* The Toshiba stepper controller require much longer pulses.
...
@@ -675,8 +688,8 @@ ISR(TIMER1_COMPA_vect) {
...
@@ -675,8 +688,8 @@ ISR(TIMER1_COMPA_vect) {
* lag to allow it work with without needing NOPs
* lag to allow it work with without needing NOPs
*/
*/
#define STEP_ADD(axis, AXIS) \
#define STEP_ADD(axis, AXIS) \
counter_##
axis += current_block->steps[AXIS
##_
AXIS]; \
_COUNTER(
axis
)
+= current_block->steps[
_
AXIS
(
AXIS
)
]; \
if (
counter_##
axis > 0) {
AXIS ##_STEP_WRITE(
HIGH); }
if (
_COUNTER(
axis
)
> 0) {
_WRITE_STEP(AXIS,
HIGH); }
STEP_ADD
(
x
,
X
);
STEP_ADD
(
x
,
X
);
STEP_ADD
(
y
,
Y
);
STEP_ADD
(
y
,
Y
);
STEP_ADD
(
z
,
Z
);
STEP_ADD
(
z
,
Z
);
...
@@ -685,10 +698,10 @@ ISR(TIMER1_COMPA_vect) {
...
@@ -685,10 +698,10 @@ ISR(TIMER1_COMPA_vect) {
#endif
#endif
#define STEP_IF_COUNTER(axis, AXIS) \
#define STEP_IF_COUNTER(axis, AXIS) \
if (
counter_##
axis > 0) { \
if (
_COUNTER(
axis
)
> 0) { \
counter_##
axis -= current_block->step_event_count; \
_COUNTER(
axis
)
-= current_block->step_event_count; \
count_position[AXIS
##_
AXIS] += count_direction[AXIS
##_
AXIS]; \
count_position[
_
AXIS
(
AXIS
)
] += count_direction[
_
AXIS
(
AXIS
)
]; \
AXIS ##_STEP_WRITE(
LOW); \
_WRITE_STEP(AXIS,
LOW); \
}
}
STEP_IF_COUNTER
(
x
,
X
);
STEP_IF_COUNTER
(
x
,
X
);
...
@@ -701,12 +714,12 @@ ISR(TIMER1_COMPA_vect) {
...
@@ -701,12 +714,12 @@ ISR(TIMER1_COMPA_vect) {
#else // !CONFIG_STEPPERS_TOSHIBA
#else // !CONFIG_STEPPERS_TOSHIBA
#define APPLY_MOVEMENT(axis, AXIS) \
#define APPLY_MOVEMENT(axis, AXIS) \
counter_##
axis += current_block->steps[AXIS
##_
AXIS]; \
_COUNTER(
axis
)
+= current_block->steps[
_
AXIS
(
AXIS
)
]; \
if (
counter_##
axis > 0) { \
if (
_COUNTER(
axis
)
> 0) { \
AXIS ##
_APPLY_STEP(
!INVERT_## AXIS ##
_STEP_PIN,0); \
_APPLY_STEP(
AXIS)(!_INVERT
_STEP_PIN
(AXIS)
,0); \
counter_##
axis -= current_block->step_event_count; \
_COUNTER(
axis
)
-= current_block->step_event_count; \
count_position[AXIS
##_
AXIS] += count_direction[AXIS
##_
AXIS]; \
count_position[
_
AXIS
(
AXIS
)
] += count_direction[
_
AXIS
(
AXIS
)
]; \
AXIS ##
_APPLY_STEP(
INVERT_## AXIS ##
_STEP_PIN,0); \
_APPLY_STEP(
AXIS)(_INVERT
_STEP_PIN
(AXIS)
,0); \
}
}
APPLY_MOVEMENT
(
x
,
X
);
APPLY_MOVEMENT
(
x
,
X
);
...
@@ -1010,10 +1023,13 @@ void st_init() {
...
@@ -1010,10 +1023,13 @@ void st_init() {
#endif
#endif
#endif
#endif
#define _STEP_INIT(AXIS) AXIS ##_STEP_INIT
#define _DISABLE(axis) disable_## axis()
#define AXIS_INIT(axis, AXIS, PIN) \
#define AXIS_INIT(axis, AXIS, PIN) \
AXIS ##
_STEP_INIT; \
_STEP_INIT
(AXIS)
; \
AXIS ##_STEP_WRITE(INVERT_## PIN ##
_STEP_PIN); \
_WRITE_STEP(AXIS, _INVERT
_STEP_PIN
(PIN)
); \
disable_##
axis
(
)
_DISABLE(
axis)
#define E_AXIS_INIT(NUM) AXIS_INIT(e## NUM, E## NUM, E)
#define E_AXIS_INIT(NUM) AXIS_INIT(e## NUM, E## NUM, E)
...
@@ -1146,14 +1162,19 @@ void quickStop() {
...
@@ -1146,14 +1162,19 @@ void quickStop() {
// No other ISR should ever interrupt this!
// No other ISR should ever interrupt this!
void
babystep
(
const
uint8_t
axis
,
const
bool
direction
)
{
void
babystep
(
const
uint8_t
axis
,
const
bool
direction
)
{
#define _ENABLE(axis) enable_## axis()
#define _READ_DIR(AXIS) AXIS ##_DIR_READ
#define _INVERT_DIR(AXIS) INVERT_## AXIS ##_DIR
#define _APPLY_DIR(AXIS, INVERT) AXIS ##_APPLY_DIR(INVERT, true)
#define BABYSTEP_AXIS(axis, AXIS, INVERT) { \
#define BABYSTEP_AXIS(axis, AXIS, INVERT) { \
enable_##
axis
(
); \
_ENABLE(
axis); \
uint8_t old_pin =
AXIS ##_DIR_READ
; \
uint8_t old_pin =
_READ_DIR(AXIS)
; \
AXIS ##
_APPLY_DIR(
INVERT_## AXIS ##_DIR
^direction^INVERT
, true
); \
_APPLY_DIR(
AXIS, _INVERT_DIR(AXIS)
^direction^INVERT); \
AXIS ##
_APPLY_STEP(
!INVERT_## AXIS ##
_STEP_PIN, true); \
_APPLY_STEP(
AXIS)(!_INVERT
_STEP_PIN
(AXIS)
, true); \
delayMicroseconds(2); \
delayMicroseconds(2); \
AXIS ##
_APPLY_STEP(
INVERT_## AXIS ##
_STEP_PIN, true); \
_APPLY_STEP(
AXIS)(_INVERT
_STEP_PIN
(AXIS)
, true); \
AXIS ##
_APPLY_DIR(old_pin
, true
); \
_APPLY_DIR(
AXIS,
old_pin); \
}
}
switch
(
axis
)
{
switch
(
axis
)
{
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment