aboutsummaryrefslogtreecommitdiffstats
path: root/src/stepper.c
Commit message (Collapse)AuthorAgeFilesLines
* stepper: Move min_next_time check to stepper_event_full()Kevin O'Connor2021-11-041-16/+14
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Add support for stepping on both edges of a step pulseKevin O'Connor2021-11-041-7/+42
| | | | | | | | | | Add an optimized step function for drivers that support stepping on both rising and falling edges of the step pin. Enable this optimization on 32bit ARM micro-controllers. Automatically detect this capability in the host code and enable on TMC drivers running in SPI/UART mode. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Make step pulse duration customizable at run-timeKevin O'Connor2021-11-041-63/+47
| | | | | | | | | | | | Remove the STEP_DELAY Kconfig option and replace it with a per-stepper step_pulse_duration printer.cfg config option. The AVR code will continue to have optimized code to step and "unstep" in the same function (which is automatically activated when the step delay is 40 ticks or less). This change removes the Kconfig option for single function step/unstep on 32bit processors. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Remove unused SF_LAST_RESET flagKevin O'Connor2021-10-271-3/+2
| | | | | | | Tracking of the last reset is no longer needed after commit 8f76e53c. Remove the code tracking that status and remove the flag definition. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* trsync: Introduce new "trigger synchronization" supportKevin O'Connor2021-06-091-8/+21
| | | | | | | Separate out the stepper stopping code from endstop.c into its own trsync.c code file. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Remove min_stop_interval from mcu codeKevin O'Connor2021-04-301-13/+3
| | | | | | | Now that the host never uses a min_stop_interval, remove it from the mcu code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Use a reusable interface to the "move queue"Kevin O'Connor2020-12-041-18/+13
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Make toggling the step gpio after timer read conditionalKevin O'Connor2020-05-311-1/+5
| | | | | | | On the Linux mcu, toggling the pin after the time is read is not valid. Make that optimization dependent on CONFIG_HAVE_STRICT_TIMING. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Add some comments on s->position trackingKevin O'Connor2020-03-041-0/+5
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Don't update SF_LAST_DIR if SF_NEED_RESETKevin O'Connor2019-07-121-1/+3
| | | | | | | | If the move is not added to the move queue, then the SF_LAST_DIR setting must not be changed. Otherwise, it could result in an incorrect direction being set on the stepper after a homing operation. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Fix reset_step_clock corruption due to bitset typoKevin O'Connor2019-03-191-1/+1
| | | | | | | Commit b9b03dd0 had a typo in the flag updating. The typo could result in corruption of the stepper state. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: Always pass a string to the DECL_CONSTANT() macroKevin O'Connor2019-03-171-1/+1
| | | | | | | | Make it clear that the name of the constant being defined is a string. When the value being defined is also a string, use a new DECL_CONSTANT_STR() macro. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Require an explicit reset_step_clock after stepper_stop()Kevin O'Connor2019-03-171-5/+9
| | | | | | | If the stepper is stopped by the endstop code, then ignore any further stepper moves until a reset_step_clock command is received. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Support an optimized step/unstep function on ARMKevin O'Connor2019-03-101-24/+49
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Wrap code to 80 columnsKevin O'Connor2019-02-271-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Fix bug when using a non-zero CONFIG_STEP_DELAY on AVRKevin O'Connor2019-01-111-1/+1
| | | | | | | | Make sure to explicitly cast to 32bit integers when doing math on 16bit integers that require the extra precision as the AVR uses a 16bit int. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Support configuring the stepper pulse length from KconfigKevin O'Connor2019-01-091-7/+8
| | | | | | | Allow the stepper pulse length to be configured at compile time from the Kconfig menu system. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Introduce and use gpio_out_toggle_noirq()Kevin O'Connor2018-05-151-5/+5
| | | | | | | | | | | | | | | The gpio_out_toggle() function in the sam3x8e and stm32f1 code was only valid if it was called with irqs disabled. Commits 018c5daa and 9c52ad43 enabled the lcd code which called gpio_out_toggle() with irqs enabled. This could cause corruption of the gpio state. Introduce a gpio_out_toggle_noirq() function that will only be invoked with irqs disabled, and fix gpio_out_toggle() on sam3x8e and stm32f1 so that it safe to call even if irqs are enabled. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Provide some further help on common MCU shutdown errorsKevin O'Connor2017-09-051-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Revert f8b0c884Kevin O'Connor2017-08-111-26/+25
| | | | | | | | Go back to scheduling the unstep time instead of busy waiting in the timer dispatch. With the unstep time increased to 2us, it no longer makes sense to spin while waiting for the unstep. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Increase the step delay time from 1us to 2usKevin O'Connor2017-06-131-1/+1
| | | | | | | Increase the step delay time so that it works with the common DRV8825 stepper drivers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Use compile_time_request system for init, tasks, and shutdownKevin O'Connor2017-05-261-1/+1
| | | | | | | | Avoid using linker magic to define the init, task, and shutdown functions. Instead, use the compile_time_request system. This simplifies the build and produces more efficient code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: It is not necessary to ensure gpio_out_write value is 0 or 1Kevin O'Connor2017-05-151-2/+2
| | | | | | | | The gpio_out_write() and gpio_out_setup() calls will check for zero and non-zero, so it is not necessary to explicitly convert to 0/1 in the stepper.c code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Improve performance of scheduled unstepsKevin O'Connor2017-03-301-25/+26
| | | | | | | | | On faster MCUs where a delay is needed between step and unstep use a "busy loop" in the scheduler instead of trying to schedule to the unstep time. This reduces the chance of jitter in the scheduler accumulating. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* timer: Allow board code to define its own timer_is_before implementationKevin O'Connor2017-03-261-5/+6
| | | | | | | | | | | | Move sched_is_before() from sched.c to timer_is_before() in the board specific timer code. This allows the board code to provide its own definition. Also, remove the sched_from_us() and sched_read_time() wrapper functions and change the callers to directly invoke timer_from_us() / timer_read_time(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Rename sched_timer() to sched_add_timer()Kevin O'Connor2017-03-111-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Introduce stepper_get_position command and remove from endstop.cKevin O'Connor2017-03-091-5/+27
| | | | | | | | Move the logic to calculate and report the stepper's current position from endstop.c to stepper.c. This localizes the stepper code into stepper.c. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* basecmd: Use oid_ prefix for the oid manipulation functionsKevin O'Connor2017-03-091-5/+5
| | | | | | | Consistently use an "oid_" prefix on the oid functions - this makes them similar to other functions with a common prefix. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* basecmd: Generalize the "move queue" runtime storageKevin O'Connor2017-03-081-5/+15
| | | | | | | | | Detect the maximum size of each "move queue" item during the configuration phase instead of using the stepper move struct. This allows the stepper code to be contained entirely in stepper.c and it allows for future run time allocations from other types of objects. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Minor change - remove unneeded header filesKevin O'Connor2017-01-141-1/+0
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Reset the next step time on a stepper stopKevin O'Connor2016-11-141-0/+1
| | | | | | | | | Automatically reset the next step time to zero on a stepper_stop() call. This makes the host code simpler as it no longer needs to schedule an explicit reset_step_clock command on the step after a homing operation. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Default to a high direction pin meaning positive directionKevin O'Connor2016-11-081-2/+2
| | | | | | | | | Invert the default meaning of the stepper direction pin. Instead of treating a low value as position motion, treat a high value as positive motion. This matches what other firmwares do, and it matches what common stepper motor drivers document. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Disable "no next step" check for some count=1 queue_step commandsKevin O'Connor2016-09-221-5/+16
| | | | | | | | | It's possible for a "count=1" stepper move immediately after a set_next_step_dir or reset_step_clock command to be valid and have an interval less than min_stop_interval. Make sure this case does not result in a shutdown. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Support rescheduling of step events on faster MCUsKevin O'Connor2016-06-141-19/+72
| | | | | | | | | | On faster MCUs the step and unstep events may be too close for the stepper motor driver. Add a CONFIG_NO_UNSTEP_DELAY build option and support the case where it is not set. This allows faster MCUs to schedule two events for each step (one for the step and one for the unstep). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Use uint_fast8_t for return type of timersKevin O'Connor2016-06-141-3/+3
| | | | | | | | Some architectures are faster passing regular integers than 8bit integers. Use uint_fast8_t so that the architecture chooses the appropriate type. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* irq: Prefer irq_disable/enable instead of irq_save/restore in cmds/tasksKevin O'Connor2016-06-131-3/+3
| | | | | | | | Task and command handlers always run with irqs enabled, so it is not necessary to save/restore the irq state when disabling irqs in these handlers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Optimize for case where add is zeroKevin O'Connor2016-06-131-11/+15
| | | | | | | At high rates, the "add" field is frequently zero. It's possible to optimize for that case. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Use stepper_stop() instead of stepper_reset() in stepper_shutdown()Kevin O'Connor2016-06-021-13/+6
| | | | | | | The stepper_stop() function is equivalent to stepper_reset() during a shutdown event. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Initial commit of source code.Kevin O'Connor2016-05-251-0/+202
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>