From 8fa4535444be4b422af4bc36a9a035e52bba00c0 Mon Sep 17 00:00:00 2001 From: Terje Io Date: Mon, 26 Feb 2024 21:11:48 +0100 Subject: [PATCH] Fixed typo preventing lathe mode UVW builds. Added initial support for using auxillary output pin pool for spindle and coolant pins. --- changelog.md | 18 ++++++++++++ crossbar.h | 8 ++++++ gcode.c | 4 +-- grbl.h | 2 +- pin_bits_masks.h | 71 +++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 99 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 0ea35df..a956b3e 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,23 @@ ## grblHAL changelog +Build 20240226 + +Core: + +* Fixed typo preventing lathe mode UVW builds. + +* Added initial support for using auxillary output pin pool for spindle and coolant pins. + +Drivers: + +* STM32F7xx: updated to use auxillary output pin pool for spindle pins. Enhanced and simplified PWM support, added generic Uno and Protoneer v3 boards to Web Builder. + +Plugins: + +* WebUI: "hardened" code a bit more in attempt to make it usable with STM32F4xx driver which has limited RAM that blocks reporting settings data. + +--- + Build 20240222 __NOTE:__ This build has moved the probe input to the ioPorts pool of inputs and will be allocated from it when configured. diff --git a/crossbar.h b/crossbar.h index 78721b0..e7259ed 100644 --- a/crossbar.h +++ b/crossbar.h @@ -575,6 +575,14 @@ typedef struct { void *input; } aux_ctrl_t; +typedef struct { + pin_function_t function; + uint8_t aux_port; + uint8_t pin; + void *port; + void *output; +} aux_ctrl_out_t; + typedef struct xbar { uint8_t id; //!< Pin id. pin_function_t function; //!< Pin function. diff --git a/gcode.c b/gcode.c index 14ee973..8a8c651 100644 --- a/gcode.c +++ b/gcode.c @@ -1477,7 +1477,6 @@ status_code_t gc_execute_block (char *block) word_bit.parameter.z = word_bit.parameter.w = On; gc_block.values.uvw[Z_AXIS] = value; break; - #else #ifdef U_AXIS @@ -1505,7 +1504,6 @@ status_code_t gc_execute_block (char *block) gc_block.values.v = value; break; #endif -#endif // LATHE_UVW_OPTION #if !AXIS_REMAP_ABC2UVW case 'W': @@ -1513,6 +1511,8 @@ status_code_t gc_execute_block (char *block) gc_block.values.w = value; break; #endif + +#endif // !LATHE_UVW_OPTION case 'X': axis_words.x = On; word_bit.parameter.x = On; diff --git a/grbl.h b/grbl.h index 261787c..a693f98 100644 --- a/grbl.h +++ b/grbl.h @@ -42,7 +42,7 @@ #else #define GRBL_VERSION "1.1f" #endif -#define GRBL_BUILD 20240222 +#define GRBL_BUILD 20240226 #define GRBL_URL "https://github.com/grblHAL" diff --git a/pin_bits_masks.h b/pin_bits_masks.h index 12b9b82..fa0edcc 100644 --- a/pin_bits_masks.h +++ b/pin_bits_masks.h @@ -208,7 +208,7 @@ #endif static aux_ctrl_t aux_ctrl[] = { -// The following pins are bound explicitly to aux pins +// The following pins are bound explicitly to aux input pins #if PROBE_ENABLE && defined(PROBE_PIN) && defined(AUX_DEVICES) #ifdef PROBE_PORT { .function = Input_Probe, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .value = 0 }, .pin = PROBE_PIN, .port = PROBE_PORT }, @@ -392,6 +392,75 @@ static inline control_signals_t aux_ctrl_scan_status (control_signals_t signals) #define AUX_CONTROLS_SCAN 0 #endif +#ifdef AUX_CONTROLS_OUT + +// The following pins are bound explicitly to aux output pins +static aux_ctrl_out_t aux_ctrl_out[] = { +#ifdef DRIVER_SPINDLE_ENABLE + { .function = Output_SpindleOn, .aux_port = 0xFF, .pin = SPINDLE_ENABLE_PIN, .port = SPINDLE_ENABLE_PORT }, +#endif +#ifdef DRIVER_SPINDLE_PWM_ENABLE + { .function = Output_SpindlePWM, .aux_port = 0xFF, .pin = SPINDLE_PWM_PIN, .port = SPINDLE_PWM_PORT }, +#endif +#ifdef DRIVER_SPINDLE_DIR_ENABLE + { .function = Output_SpindleDir, .aux_port = 0xFF, .pin = SPINDLE_DIRECTION_PIN, .port = SPINDLE_DIRECTION_PORT }, +#endif +/* +#ifdef COOLANT_FLOOD_PIN + { .function = Output_CoolantFlood, .aux_port = 0xFF, .pin = COOLANT_FLOOD_PIN, .port = COOLANT_FLOOD_PORT }, +#endif +#ifdef COOLANT_MIST_PIN + { .function = Output_CoolantMist, .aux_port = 0xFF, .pin = COOLANT_MIST_PIN, .port = COOLANT_MIST_PORT }, +#endif +*/ +}; + +static inline aux_ctrl_out_t *aux_out_remap_explicit (void *port, uint8_t pin, uint8_t aux_port, void *output) +{ + aux_ctrl_out_t *ctrl_pin = NULL; + + uint_fast8_t idx = sizeof(aux_ctrl_out) / sizeof(aux_ctrl_out_t); + + do { + idx--; + if(aux_ctrl_out[idx].port == port && aux_ctrl_out[idx].pin == pin) { + ctrl_pin = &aux_ctrl_out[idx]; + ctrl_pin->aux_port = aux_port; + ctrl_pin->output = output; + } + } while(idx && ctrl_pin == NULL); + + return ctrl_pin; +} + +typedef bool (*aux_claim_explicit_out_ptr)(aux_ctrl_out_t *aux_ctrl); + +static bool aux_ctrl_claim_out_port (xbar_t *properties, uint8_t port, void *data) +{ + if(ioport_claim(Port_Digital, Port_Output, &properties->id, xbar_fn_to_pinname(((aux_ctrl_t *)data)->function))) + ((aux_ctrl_t *)data)->aux_port = properties->id; + + return ((aux_ctrl_t *)data)->aux_port != 0xFF; +} + +static inline void aux_ctrl_claim_out_ports (aux_claim_explicit_out_ptr aux_claim_explicit, ioports_enumerate_callback_ptr aux_claim) +{ + uint_fast8_t idx; + + if(aux_claim == NULL) + aux_claim = aux_ctrl_claim_out_port; + + for(idx = 0; idx < sizeof(aux_ctrl_out) / sizeof(aux_ctrl_out_t); idx++) { + if(aux_ctrl_out[idx].pin == 0xFF) { + if(ioports_enumerate(Port_Digital, Port_Output, (pin_cap_t){ .claimable = On }, aux_claim, (void *)&aux_ctrl_out[idx])) + hal.signals_cap.mask |= aux_ctrl[idx].cap.mask; + } else if(aux_ctrl_out[idx].aux_port != 0xFF) + aux_claim_explicit(&aux_ctrl_out[idx]); + } +} + +#endif // AUX_CONTROLS_OUT + // #ifndef CONTROL_MASK