2 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
3 Smoothie 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.
4 Smoothie 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.
5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
18 #include "ActuatorCoordinates.h"
27 void set_frequency( float frequency
);
28 void signal_a_move_finished();
29 void set_unstep_time( float microseconds
);
30 int register_motor(StepperMotor
* motor
);
31 float get_frequency() const { return frequency
; }
34 void TIMER0_IRQHandler (void);
35 void PendSV_IRQHandler (void);
38 void copy_block(Block
*block
);
39 void set_next_block(Block
*block
) { next_block
= block
; }
40 bool is_next_block() const { return next_block
!= nullptr; }
42 // whatever setup the block should register this to know when it is done
43 std::function
<void()> finished_fnc
{nullptr};
45 static StepTicker
*getInstance() { return instance
; }
48 static StepTicker
*instance
;
52 std::array
<StepperMotor
*, k_max_actuators
> motor
;
53 std::atomic_uchar do_move_finished
;
54 std::bitset
<k_max_actuators
> unstep
;
56 // this is tick info needed for this block. applies to all motors
58 uint32_t accelerate_until
;
59 uint32_t decelerate_after
;
60 uint32_t maximum_rate
;
61 uint32_t deceleration_per_tick
;
62 uint32_t total_move_ticks
;
64 block_info_t block_info
;
65 Block
*next_block
{nullptr};
67 // this is the data needed to determine when each motor needs to be issued a step
69 float steps_per_tick
; // 2.30 fixed point
70 float counter
; // 2.30 fixed point
71 float acceleration_change
; // 1.30 fixed point signed
73 uint32_t steps_to_move
;
75 uint32_t next_accel_event
;
77 std::array
<tickinfo_t
, k_max_actuators
> tick_info
;
80 volatile bool move_issued
:1;