Moved HAL entry point for realtime commands enqueueing to stream struct,

added some crossbar pin definitions and limited $TPW retract to Z home.
Moved some common driver code to the core and update of current position on steps/mm changes.
This commit is contained in:
Terje Io
2021-07-26 15:35:55 +02:00
parent 222ba55724
commit 2068165e62
17 changed files with 222 additions and 137 deletions

View File

@@ -11,7 +11,7 @@ It has been written to complement grblHAL and has features such as proper keyboa
---
Latest build date is 20210608, see the [changelog](changelog.md) for details.
Latest build date is 20210726, see the [changelog](changelog.md) for details.
---
@@ -77,4 +77,4 @@ List of Supported G-Codes:
```
---
2021-06-08
2021-07-26

View File

@@ -1,5 +1,20 @@
## grblHAL changelog
Build 20210726:
Core:
* Added encapsulation in stream handlers for realtime processing. This allows more flexible use of additional streams.
* Added optional debug stream to the HAL. Currently only used by the iMXRT1062 driver.
* Position will now be recalulated on steps/mm setting changes.
* Limited final `$TPW` retract on tool changes to Z home to avoid triggering Z-limit.
* Moved some common driver code snippets to the core to avoid duplication.
Drivers & plugins:
* Updated all for new stream encapsulation.
* Added option to use UART input for I2C keypad plugin. Added fan toggle support.
* Fixed some bugs and regressions.
* Added support for ganged/autosquared axes to RP2040 driver.
Build 20210707:
Core:
@@ -23,7 +38,7 @@ A-axis, B-axis and ganged X-axis: A-axis -> motor 4 and, B-axis -> motor 5 and s
Auto-squared X and Y-axis: second X-axis -> motor 4 and second Y-axis -> motor 5. Motor 6 pins may then be assigned to auxillary I/O.
etc...
__IMPORTANT:__ For those who have used auto-squared/ganged axes with previous builds be sure to check that the motors allocated matches the current wiring.
Tip: use the `$pins` system command to list the pin allocations when checking. Rewire as neccesary.
Tip: use the `$pins` system command to list the pin allocations when checking. Rewire as neccesary.
* Added ganged axis/auto-squaring support to some board maps for the [LPC176x](https://github.com/grblHAL/LPC176x) driver.
* Expanded on HAL entry points for stream communication and added [initial documentation](http://svn.io-engineering.com/grblHAL/html/hal_8h.html) for the HAL and parts of the core.
* Encapsulated UART/USB CDC code for many drivers, for most only the init function is now available for direct acccess from the outside. Simplified main driver code and plugins using streams.
@@ -37,7 +52,7 @@ Build 20210608:
Build 20210604:
* Added some HAL entry points and properties, shared file for mapped step and dir output.
* Added `$pins` system command, for listing current pin assignments. Work in progress, only supported by a couple of drivers.
* Added `$pins` system command, for listing current pin assignments. Work in progress, only supported by a couple of drivers. For now only plain GPIO pins are listed.
* Some minor bugs fixed.
Build 20210515:

View File

@@ -70,16 +70,22 @@ typedef enum {
Input_MotorFault,
Outputs,
Output_StepX = Outputs,
Output_StepX_2,
Output_StepY,
Output_StepY_2,
Output_StepZ,
Output_StepZ_2,
Output_StepA,
Output_StepB,
Output_StepC,
Output_StepU,
Output_StepV,
Output_DirX,
Output_DirX_2,
Output_DirY,
Output_DirY_2,
Output_DirZ,
Output_DirZ_2,
Output_DirA,
Output_DirB,
Output_DirC,
@@ -174,14 +180,20 @@ PROGMEM static const pin_name_t pin_names[] = {
{ .function = Input_Aux6, .name = "Aux input 6" },
{ .function = Input_Aux7, .name = "Aux input 7" },
{ .function = Output_StepX, .name = "X step" },
{ .function = Output_StepX_2, .name = "X2 step" },
{ .function = Output_StepY, .name = "Y step" },
{ .function = Output_StepY_2, .name = "Y2 step" },
{ .function = Output_StepZ, .name = "Z step" },
{ .function = Output_StepZ_2, .name = "Z2 step" },
{ .function = Output_StepA, .name = "A step" },
{ .function = Output_StepB, .name = "B step" },
{ .function = Output_StepC, .name = "C step" },
{ .function = Output_DirX, .name = "X dir" },
{ .function = Output_DirX_2, .name = "X2 dir" },
{ .function = Output_DirY, .name = "Y dir" },
{ .function = Output_DirY_2, .name = "Y2 dir" },
{ .function = Output_DirZ, .name = "Z dir" },
{ .function = Output_DirZ_2, .name = "Z2 dir" },
{ .function = Output_DirA, .name = "A dir" },
{ .function = Output_DirB, .name = "B dir" },
{ .function = Output_DirC, .name = "C dir" },

2
grbl.h
View File

@@ -34,7 +34,7 @@
#else
#define GRBL_VERSION "1.1f"
#endif
#define GRBL_VERSION_BUILD "20210629"
#define GRBL_VERSION_BUILD "20210715"
// The following symbols are set here if not already set by the compiler or in config.h
// Do NOT change here!

View File

@@ -122,7 +122,6 @@ int grbl_enter (void)
hal.irq_enable = dummy_handler;
hal.irq_disable = dummy_handler;
hal.nvs.size = GRBL_NVS_SIZE;
hal.stream.enqueue_realtime_command = protocol_enqueue_realtime_command;
hal.limits.interrupt_callback = limit_interrupt_handler;
hal.control.interrupt_callback = control_interrupt_handler;
hal.stepper.interrupt_callback = stepper_driver_interrupt_handler;
@@ -264,7 +263,7 @@ int grbl_enter (void)
state_set(STATE_ALARM);
if(hal.driver_cap.mpg_mode)
hal.stream.enqueue_realtime_command(sys.mpg_mode ? CMD_STATUS_REPORT_ALL : CMD_STATUS_REPORT);
protocol_enqueue_realtime_command(sys.mpg_mode ? CMD_STATUS_REPORT_ALL : CMD_STATUS_REPORT);
// Start Grbl main loop. Processes program inputs and executes them.
if(!(looping = protocol_main_loop()))

1
hal.h
View File

@@ -665,6 +665,7 @@ typedef struct {
#ifdef DEBUGOUT
void (*debug_out)(bool on);
io_stream_t debug; //!< Handlers for debug stream I/O.
#endif
/*! \brief Check for a soft reset or abort in blocking calls.

73
messages.h Normal file
View File

@@ -0,0 +1,73 @@
/*
messages.h - system messages
Part of grblHAL
Copyright (c) 2017-2021 Terje Io
Copyright (c) 2014-2016 Sungeun K. Jeon for Gnea Research LLC
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/>.
*/
#ifndef _MESSAGES_H_
#define _MESSAGES_H_
// Define feedback message codes. Valid values (0-255).
typedef enum {
Message_None = 0, //!< 0 - reserved, do not change value.
Message_CriticalEvent = 1, //!< 1
Message_AlarmLock = 2, //!< 2
Message_AlarmUnlock = 3, //!< 3
Message_Enabled = 4, //!< 4
Message_Disabled = 5, //!< 5
Message_SafetyDoorAjar = 6, //!< 6
Message_CheckLimits = 7, //!< 7
Message_ProgramEnd = 8, //!< 8
Message_RestoreDefaults = 9, //!< 9
Message_SpindleRestore = 10, //!< 10
Message_SleepMode = 11, //!< 11
Message_EStop = 12, //!< 12
Message_HomingCycleRequired = 13, //!< 13
Message_CycleStartToRerun = 14, //!< 14
Message_ReferenceTLOEstablished = 15, //!< 15
Message_MotorFault = 16, //!< 16
Message_NextMessage //!< 17 - next unassigned message number.
} message_code_t;
typedef struct {
message_code_t id;
const char *msg;
} message_t;
PROGMEM static const message_t messages[] = {
{ .id = Message_None, .msg = "" },
{ .id = Message_CriticalEvent, .msg = "Reset to continue" },
{ .id = Message_AlarmLock, .msg = "'$H'|'$X' to unlock" },
{ .id = Message_AlarmUnlock, .msg = "Caution: Unlocked" },
{ .id = Message_Enabled, .msg = "Enabled" },
{ .id = Message_Disabled, .msg = "Disabled" },
{ .id = Message_SafetyDoorAjar, .msg = "Check Door" },
{ .id = Message_CheckLimits, .msg = "Check Limits" },
{ .id = Message_ProgramEnd, .msg = "Pgm End" },
{ .id = Message_RestoreDefaults, .msg = "Restoring defaults" },
{ .id = Message_SpindleRestore, .msg = "Restoring spindle" },
{ .id = Message_SleepMode, .msg = "Sleeping" },
{ .id = Message_EStop, .msg = "Emergency stop" },
{ .id = Message_HomingCycleRequired, .msg = "Homing cycle required" },
{ .id = Message_CycleStartToRerun, .msg = "Press cycle start to rerun job" },
{ .id = Message_ReferenceTLOEstablished, .msg = "Reference tool length offset established" },
{ .id = Message_MotorFault, .msg = "Motor fault" }
};
#endif

View File

@@ -779,7 +779,7 @@ status_code_t mc_homing_cycle (axes_signals_t cycle)
state_set(STATE_HOMING); // Set homing system state.
#if COMPATIBILITY_LEVEL == 0
hal.stream.enqueue_realtime_command(CMD_STATUS_REPORT); // Force a status report and
protocol_enqueue_realtime_command(CMD_STATUS_REPORT); // Force a status report and
delay_sec(0.1f, DelayMode_Dwell); // delay a bit to get it sent (or perhaps wait a bit for a request?)
#endif
hal.limits.enable(false, true); // Disable hard limits pin change register for cycle duration

View File

@@ -27,6 +27,8 @@
#if defined(STM32_PLATFORM) || defined(__LPC17XX__) || defined(__IMXRT1062__)
#define UINT32FMT "%lu"
#define UINT32SFMT "lu"
#else
#define UINT32FMT "%u"
#define UINT32SFMT "u"
#endif

View File

@@ -29,7 +29,7 @@
#endif
#if TRINAMIC_ENABLE
extern void trinamic_init (void);
extern bool trinamic_init (void);
trinamic_init();
#endif

View File

@@ -317,88 +317,22 @@ void report_message (const char *msg, message_type_t type)
// messages such as setup warnings, switch toggling, and how to exit alarms.
// NOTE: For interfaces, messages are always placed within brackets. And if silent mode
// is installed, the message number codes are less than zero.
message_code_t report_feedback_message (message_code_t message_code)
message_code_t report_feedback_message (message_code_t id)
{
const char *msg = NULL;
uint_fast16_t idx = 0;
hal.stream.write_all("[MSG:");
switch(message_code) {
case Message_None:
break;
case Message_CriticalEvent:
hal.stream.write_all("Reset to continue");
break;
case Message_AlarmLock:
hal.stream.write_all("'$H'|'$X' to unlock");
break;
case Message_AlarmUnlock:
hal.stream.write_all("Caution: Unlocked");
break;
case Message_Enabled:
hal.stream.write_all("Enabled");
break;
case Message_Disabled:
hal.stream.write_all("Disabled");
break;
case Message_SafetyDoorAjar:
hal.stream.write_all("Check Door");
break;
case Message_CheckLimits:
hal.stream.write_all("Check Limits");
break;
case Message_ProgramEnd:
hal.stream.write_all("Pgm End");
break;
case Message_RestoreDefaults:
hal.stream.write_all("Restoring defaults");
break;
case Message_SpindleRestore:
hal.stream.write_all("Restoring spindle");
break;
case Message_SleepMode:
hal.stream.write_all("Sleeping");
break;
case Message_EStop:
hal.stream.write_all("Emergency stop");
break;
case Message_HomingCycleRequired:
hal.stream.write_all("Homing cycle required");
break;
case Message_CycleStartToRerun:
hal.stream.write_all("Press cycle start to rerun job");
break;
case Message_ReferenceTLOEstablished:
hal.stream.write_all("Reference tool length offset established");
break;
case Message_MotorFault:
hal.stream.write_all("Motor fault");
break;
default:
if(grbl.on_unknown_feedback_message)
grbl.on_unknown_feedback_message(hal.stream.write_all);
break;
}
do {
if(messages[idx].id == id)
msg = messages[idx].msg;
} while(msg == NULL && ++idx < Message_NextMessage);
hal.stream.write_all(msg ? msg : "");
hal.stream.write_all("]" ASCII_EOL);
return message_code;
return id;
}

View File

@@ -865,8 +865,16 @@ static status_code_t set_axis_setting (setting_id_t setting, float value)
case Setting_AxisStepsPerMM:
if (hal.max_step_rate && value * settings.axis[idx].max_rate > (float)hal.max_step_rate * 60.0f)
status = Status_MaxStepRateExceeded;
else
else {
if(settings.axis[idx].steps_per_mm > 0.0f && settings.axis[idx].steps_per_mm != value) {
float comp = value / settings.axis[idx].steps_per_mm;
sys.position[idx] *= comp;
sys.probe_position[idx] *= comp;
sys.tlo_reference[idx] *= comp;
sync_position();
}
settings.axis[idx].steps_per_mm = value;
}
break;
case Setting_AxisMaxRate:

View File

@@ -1,5 +1,5 @@
/*
stream.h - shared stream rx buffer copy for tool change protocol
stream.h - stream RX handling for tool change protocol
Part of grblHAL
@@ -22,31 +22,63 @@
#include <string.h>
#include "hal.h"
#include "protocol.h"
#include "state_machine.h"
static stream_rx_buffer_t rxbackup;
typedef struct {
enqueue_realtime_command_ptr enqueue_realtime_command;
stream_read_ptr read;
stream_rx_buffer_t *rxbuffer;
} stream_state_t;
static stream_state_t stream = {0};
// "dummy" version of serialGetC
int16_t stream_get_null (void)
{
return SERIAL_NO_DATA;
}
static bool await_toolchange_ack (char c)
{
if(c == CMD_TOOL_ACK && !stream.rxbuffer->backup) {
memcpy(&rxbackup, stream.rxbuffer, sizeof(stream_rx_buffer_t));
stream.rxbuffer->backup = true;
stream.rxbuffer->tail = stream.rxbuffer->head;
hal.stream.read = stream.read; // restore normal input
hal.stream.set_enqueue_rt_handler(stream.enqueue_realtime_command);
stream.enqueue_realtime_command = NULL;
} else
return stream.enqueue_realtime_command(c);
return true;
}
bool stream_rx_suspend (stream_rx_buffer_t *rxbuffer, bool suspend)
{
if(suspend)
if(suspend) {
stream.rxbuffer = rxbuffer;
stream.read = hal.stream.read;
stream.enqueue_realtime_command = hal.stream.set_enqueue_rt_handler(await_toolchange_ack);
hal.stream.read = stream_get_null;
else if(rxbuffer->backup)
memcpy(rxbuffer, &rxbackup, sizeof(stream_rx_buffer_t));
} else {
if(rxbuffer->backup)
memcpy(rxbuffer, &rxbackup, sizeof(stream_rx_buffer_t));
if(stream.enqueue_realtime_command) {
hal.stream.read = stream.read; // restore normal input
hal.stream.set_enqueue_rt_handler(stream.enqueue_realtime_command);
stream.enqueue_realtime_command = NULL;
}
}
return rxbuffer->tail != rxbuffer->head;
}
ISR_CODE void stream_rx_backup (stream_rx_buffer_t *rxbuffer)
ISR_CODE bool stream_buffer_all (char c)
{
memcpy(&rxbackup, rxbuffer, sizeof(stream_rx_buffer_t));
rxbuffer->backup = true;
rxbuffer->tail = rxbuffer->head;
return false;
}
ISR_CODE bool stream_enable_mpg (const io_stream_t *mpg_stream, bool mpg_mode)
@@ -59,16 +91,17 @@ ISR_CODE bool stream_enable_mpg (const io_stream_t *mpg_stream, bool mpg_mode)
// Deny entering MPG mode if busy
if(mpg_mode == sys.mpg_mode || (mpg_mode && (gc_state.file_run || !(state == STATE_IDLE || (state & (STATE_ALARM|STATE_ESTOP)))))) {
hal.stream.enqueue_realtime_command(CMD_STATUS_REPORT_ALL);
protocol_enqueue_realtime_command(CMD_STATUS_REPORT_ALL);
return false;
}
if(mpg_mode) {
if(org_stream.type == StreamType_Redirected) {
memcpy(&org_stream, &hal.stream, offsetof(io_stream_t, enqueue_realtime_command));
memcpy(&org_stream, &hal.stream, sizeof(io_stream_t));
if(hal.stream.disable)
hal.stream.disable(true);
mpg_stream->disable(false);
mpg_stream->set_enqueue_rt_handler(org_stream.set_enqueue_rt_handler(NULL));
hal.stream.read = mpg_stream->read;
hal.stream.get_rx_buffer_free = mpg_stream->get_rx_buffer_free;
hal.stream.cancel_read_buffer = mpg_stream->cancel_read_buffer;
@@ -76,7 +109,7 @@ ISR_CODE bool stream_enable_mpg (const io_stream_t *mpg_stream, bool mpg_mode)
}
} else if(org_stream.type != StreamType_Redirected) {
mpg_stream->disable(true);
memcpy(&hal.stream, &org_stream, offsetof(io_stream_t, enqueue_realtime_command));
memcpy(&hal.stream, &org_stream, sizeof(io_stream_t));
org_stream.type = StreamType_Redirected;
if(hal.stream.disable)
hal.stream.disable(false);
@@ -88,7 +121,28 @@ ISR_CODE bool stream_enable_mpg (const io_stream_t *mpg_stream, bool mpg_mode)
sys.report.mpg_mode = On;
// Force a realtime status report, all reports when MPG mode active
hal.stream.enqueue_realtime_command(mpg_mode ? CMD_STATUS_REPORT_ALL : CMD_STATUS_REPORT);
protocol_enqueue_realtime_command(mpg_mode ? CMD_STATUS_REPORT_ALL : CMD_STATUS_REPORT);
return true;
}
#ifdef DEBUGOUT
static stream_write_ptr dbg_write;
static void debug_write (const char *s)
{
dbg_write(s);
while(hal.debug.get_tx_buffer_count()); // Wait until message is delivered
}
void debug_stream_init (io_stream_t *stream)
{
memcpy(&hal.debug, stream, sizeof(io_stream_t));
dbg_write = hal.debug.write;
hal.debug.write = debug_write;
hal.debug.write(ASCII_EOL "UART debug active:" ASCII_EOL);
}
#endif

View File

@@ -69,6 +69,7 @@ Helper functions for saving away and restoring a stream input buffer. _Not refer
#define SERIAL_NO_DATA -1
#endif
#define BUFNEXT(ptr, buffer) ((ptr + 1) & (sizeof(buffer.data) - 1))
#define BUFCOUNT(head, tail, size) ((head >= tail) ? (head - tail) : (size - tail + head))
#include <stddef.h>
@@ -120,10 +121,18 @@ typedef bool (*stream_write_char_ptr)(const char c);
This should be called by driver code prior to inserting a character into the input buffer.
\param c character to check.
\returns true if extracted, driver code should not insert the character into the input buffer if so.
__NOTE:__ This is set up by the core at startup and may be changed at runtime by the core and/or plugin code.
*/
typedef bool (*enqueue_realtime_command_ptr)(char data);
typedef bool (*enqueue_realtime_command_ptr)(char c);
/*! \brief Pointer to function for setting the enqueue realtime commands handler.
\param enqueue_realtime_command_ptr pointer to the new handler function.
\returns \a enqueue_realtime_command_ptr pointer to the replaced function.
__NOTE:__ Stream implementation should hold a pointer to the handler in a local variable and typically
set it to protocol_enqueue_realtime_command() on initialization.
*/
typedef enqueue_realtime_command_ptr (*set_enqueue_rt_handler_ptr)(enqueue_realtime_command_ptr);
/*! \brief Pointer to function for setting the stream baud rate.
\param baud_rate
@@ -184,6 +193,7 @@ typedef struct {
stream_read_ptr read; //!< Handler for reading a single character from the input stream.
flush_stream_buffer_ptr reset_read_buffer; //!< Handler for flushing the input buffer.
cancel_read_buffer_ptr cancel_read_buffer; //!< Handler for flushing the input buffer and inserting an #ASCII_CAN character.
set_enqueue_rt_handler_ptr set_enqueue_rt_handler; //!< Handler for setting the enqueue realtime commands handler.
suspend_read_ptr suspend_read; //!< Optional handler for saving away and restoring the current input buffer.
stream_write_n_ptr write_n; //!< Optional handler for writing n characters to current output stream only. Required for Modbus support.
disable_stream_ptr disable; //!< Optional handler for disabling/enabling a stream. Recommended?
@@ -191,10 +201,6 @@ typedef struct {
get_stream_buffer_count_ptr get_tx_buffer_count; //!< Optional handler for getting number of characters in the output buffer(s). Count shall include any unsent characters in any transmit FIFO and/or transmit register. Required for Modbus support.
flush_stream_buffer_ptr reset_write_buffer; //!< Optional handler for flushing the output buffer. Any transmit FIFO shall be flushed as well. Required for Modbus support.
set_baud_rate_ptr set_baud_rate; //!< Optional handler for setting the stream baud rate. Required for Modbus support, recommended for Bluetooth support.
//@}
//! @name The following variable is not changed on a soft reset, do NOT move.
//@{
enqueue_realtime_command_ptr enqueue_realtime_command; //!< Handler for extracting real-time commands from the input stream. _Set by the core at startup._
} io_stream_t;
@@ -240,11 +246,6 @@ int16_t stream_get_null (void);
*/
bool stream_rx_suspend (stream_rx_buffer_t *rxbuffer, bool suspend);
/*! \brief Function for saving away an input buffer.
\param rxbuffer pointer to a stream_rx_buffer_t.
*/
void stream_rx_backup (stream_rx_buffer_t *rxbuffer);
/*! \brief Function for enabling/disabling input from a secondary input stream.
\param mpg_stream pointer to a io_stream_t.
\param mpg_mode \a true if switching input to mpg stream, \a false when restoring original input.
@@ -252,6 +253,12 @@ void stream_rx_backup (stream_rx_buffer_t *rxbuffer);
*/
bool stream_enable_mpg (const io_stream_t *mpg_stream, bool mpg_mode);
bool stream_buffer_all (char c);
#ifdef DEBUGOUT
void debug_stream_init (io_stream_t *stream);
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -167,7 +167,7 @@ status_code_t read_int (char *s, int32_t *value)
return Status_OK;
}
const sys_command_t sys_commands[] = {
PROGMEM static const sys_command_t sys_commands[] = {
{"G", true, output_parser_state},
{"J", false, jog},
{"#", true, output_ngc_parameters},

View File

@@ -26,6 +26,7 @@
#include "gcode.h"
#include "probe.h"
#include "alarms.h"
#include "messages.h"
/*! @name System executor bit map.
\anchor rt_exec
@@ -79,28 +80,6 @@ __NOTE:__ flags are mutually exclusive, bit map allows testing for multiple stat
#define STATE_TOOL_CHANGE bit(9) //!< Manual tool change, similar to #STATE_HOLD - but stops spindle and allows jogging.
///@}
// Define feedback message codes. Valid values (0-255).
typedef enum {
Message_None = 0, //!< 0 - reserved, do not change value.
Message_CriticalEvent = 1, //!< 1
Message_AlarmLock = 2, //!< 2
Message_AlarmUnlock = 3, //!< 3
Message_Enabled = 4, //!< 4
Message_Disabled = 5, //!< 5
Message_SafetyDoorAjar = 6, //!< 6
Message_CheckLimits = 7, //!< 7
Message_ProgramEnd = 8, //!< 8
Message_RestoreDefaults = 9, //!< 9
Message_SpindleRestore = 10, //!< 10
Message_SleepMode = 11, //!< 11
Message_EStop = 12, //!< 12
Message_HomingCycleRequired = 13, //!< 13
Message_CycleStartToRerun = 14, //!< 14
Message_ReferenceTLOEstablished = 15, //!< 15
Message_MotorFault = 16, //!< 16
Message_NextMessage //!< 17 - next unassigned message number.
} message_code_t;
typedef enum {
Parking_DoorClosed = 0, //!< 0
Parking_DoorAjar, //!< 1

View File

@@ -65,7 +65,7 @@ static void change_completed (void)
if(enqueue_realtime_command) {
while(spin_lock);
hal.irq_disable();
hal.stream.enqueue_realtime_command = enqueue_realtime_command;
hal.stream.set_enqueue_rt_handler(enqueue_realtime_command);
enqueue_realtime_command = NULL;
hal.irq_enable();
}
@@ -312,8 +312,7 @@ static status_code_t tool_change (parser_state_t *parser_state)
// Trap cycle start command and control signal.
block_cycle_start = settings.tool_change.mode != ToolChange_SemiAutomatic;
enqueue_realtime_command = hal.stream.enqueue_realtime_command;
hal.stream.enqueue_realtime_command = trap_stream_cycle_start;
enqueue_realtime_command = hal.stream.set_enqueue_rt_handler(trap_stream_cycle_start);
control_interrupt_callback = hal.control.interrupt_callback;
hal.control.interrupt_callback = trap_control_cycle_start;
@@ -339,7 +338,7 @@ static status_code_t tool_change (parser_state_t *parser_state)
// tool_change_position = ?
//else
tool_change_position = sys.home_position[plane.axis_linear] - settings.homing.flags.force_set_origin ? LINEAR_AXIS_HOME_OFFSET : 0.0f;
tool_change_position = sys.home_position[plane.axis_linear]; // - settings.homing.flags.force_set_origin ? LINEAR_AXIS_HOME_OFFSET : 0.0f;
// Rapid to home position of linear axis.
memcpy(&target, &previous, sizeof(coord_data_t));
@@ -459,6 +458,8 @@ status_code_t tc_probe_workpiece (void)
system_convert_array_steps_to_mpos(target.values, sys.probe_position);
plan_data.feed_rate = settings.tool_change.seek_rate;
target.values[plane.axis_linear] += TOOL_CHANGE_PROBE_RETRACT_DISTANCE * 2.0f;
if(target.values[plane.axis_linear] > tool_change_position)
target.values[plane.axis_linear] = tool_change_position;
ok = mc_line(target.values, &plan_data);
}
}