grblHAL core  20241107
stepper2.h
Go to the documentation of this file.
1 /*
2  stepper2.h - secondary stepper motor driver
3 
4  Part of grblHAL
5 
6  Copyright (c) 2023 - 2024 Terje Io
7 
8  grblHAL is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  grblHAL is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #include <stdint.h>
23 #include <stdbool.h>
24 
25 #include "task.h"
26 
27 typedef enum {
32 
33 struct st2_motor; // members defined in stepper2.c
34 typedef struct st2_motor st2_motor_t;
35 
36 st2_motor_t *st2_motor_init (uint_fast8_t axis_idx, bool is_spindle);
37 bool st2_motor_poll (st2_motor_t *motor);
38 bool st2_motor_bind_spindle (uint_fast8_t axis_idx);
39 float st2_get_speed (st2_motor_t *motor);
40 float st2_motor_set_speed (st2_motor_t *motor, float speed);
41 bool st2_motor_move (st2_motor_t *motor, const float move, const float speed, position_t type);
42 bool st2_motor_run (st2_motor_t *motor);
43 bool st2_motor_running (st2_motor_t *motor);
44 bool st2_motor_cruising (st2_motor_t *motor);
45 bool st2_motor_stop (st2_motor_t *motor);
46 int64_t st2_get_position (st2_motor_t *motor);
47 bool st2_set_position (st2_motor_t *motor, int64_t position);
int64_t st2_get_position(st2_motor_t *motor)
Get current position in steps.
Definition: stepper2.c:471
bool st2_motor_move(st2_motor_t *motor, const float move, const float speed, position_t type)
Command a motor to move.
Definition: stepper2.c:386
float st2_motor_set_speed(st2_motor_t *motor, float speed)
Set speed.
Definition: stepper2.c:316
position_t
Definition: stepper2.h:27
@ Stepper2_Steps
0
Definition: stepper2.h:28
@ Stepper2_mm
2
Definition: stepper2.h:30
@ Stepper2_InfiniteSteps
1
Definition: stepper2.h:29
st2_motor_t * st2_motor_init(uint_fast8_t axis_idx, bool is_spindle)
Bind and initialize a motor.
Definition: stepper2.c:251
bool st2_set_position(st2_motor_t *motor, int64_t position)
Set current position in steps.
Definition: stepper2.c:483
void st2_motor_register_stopped_callback(st2_motor_t *motor, foreground_task_ptr callback)
Definition: stepper2.c:208
float st2_get_speed(st2_motor_t *motor)
Get current speed (RPM).
Definition: stepper2.c:303
bool st2_motor_run(st2_motor_t *motor)
Execute a move commanded by st2_motor_move().
Definition: stepper2.c:587
bool st2_motor_bind_spindle(uint_fast8_t axis_idx)
Bind and initialize a motor.
Definition: stepper2.c:219
bool st2_motor_cruising(st2_motor_t *motor)
Check if motor is running in cruising phase.
Definition: stepper2.c:656
bool st2_motor_poll(st2_motor_t *motor)
Check if motor is run by polling.
Definition: stepper2.c:638
bool st2_motor_running(st2_motor_t *motor)
Check if motor is running.
Definition: stepper2.c:647
bool st2_motor_stop(st2_motor_t *motor)
Stop a move. This will initiate deceleration to stop the motor if it is running.
Definition: stepper2.c:609
Internal structure for holding motor configuration and keeping track of its status.
Definition: stepper2.c:45
uint32_t move
Definition: stepper2.c:55
volatile int64_t position
Definition: stepper2.c:52
bool is_spindle
Definition: stepper2.c:48
float speed
Definition: stepper2.c:65
void(* foreground_task_ptr)(void *data)
Definition: task.h:25