-
Notifications
You must be signed in to change notification settings - Fork 0
/
stepper.h
75 lines (59 loc) · 2.53 KB
/
stepper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
stepper.h - stepper motor driver: executes motion plans of planner.c using the stepper motors
Part of Grbl v0.9
Copyright (c) 2012-2014 Sungeun K. Jeon
Grbl 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.
Grbl 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 Grbl. If not, see <http://www.gnu.org/licenses/>.
*/
/*
This file is based on work from Grbl v0.8, distributed under the
terms of the MIT-license. See COPYING for more details.
Copyright (c) 2009-2011 Simen Svale Skogsrud
Copyright (c) 2011 Sungeun K. Jeon
*/
#ifndef stepper_h
#define stepper_h
//#ifndef SEGMENT_BUFFER_SIZE
#define SEGMENT_BUFFER_SIZE 50
//#endif
// Initialize and setup the stepper motor subsystem
void stepper_init();
// Enable steppers, but cycle does not start unless called by motion control or runtime command.
void st_wake_up(uint8_t setup_and_enable_motors);
// Immediately disables steppers
void st_go_idle(uint8_t delay_and_disable_steppers);
#define STEPPERMODE_MANUAL 0
#define STEPPERMODE_AUTO 1
void stepper_setmode(uint8_t mode);
void stepper_manualstep(uint8_t idxMotor, uint8_t motorDirection);
// Reset the stepper subsystem variables
void st_reset();
typedef struct {
uint8_t direction_bits;
uint32_t steps[N_AXIS];
uint32_t step_event_count;
} st_block_t;
typedef struct {
uint16_t n_step; // Number of step events to be executed for this segment
uint8_t st_block_index; // Stepper block data index. Uses this information to execute this segment.
uint16_t cycles_per_tick; // Step distance traveled per ISR tick, aka step rate.
//#ifdef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING
uint8_t amass_level; // Indicates AMASS level for the ISR to execute this segment
//#else
uint8_t prescaler; // Without AMASS, a prescaler is required to adjust for slow timing.
//#endif
} segment_t;
void stepper_set_settings(uint8_t step_invert_mask, uint8_t dir_invert_mask);
void stepper_store_planner_block(uint8_t blockIndex, st_block_t* block);
void stepper_store_segment_block(segment_t* segment);
void stepper_interrupt();
uint8_t stepper_has_more_segment_buffer();
#endif