From eef9949d55122be55712db6739fba406829b9d33 Mon Sep 17 00:00:00 2001 From: Terje Io Date: Thu, 26 Mar 2026 20:52:26 +0100 Subject: [PATCH] Improved support for using expander inputs for basic functions. "Hardened" code a bit. --- README.md | 2 +- changelog.md | 13 +++++++++++++ grbl.h | 2 +- ioports.c | 1 + machine_limits.c | 2 +- pin_bits_masks.h | 4 ++-- vfs.c | 8 ++++++-- vfs.h | 6 ++++-- 8 files changed, 29 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4764f77..41e1833 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## grblHAL ## -Latest build date is 20260320, see the [changelog](changelog.md) for details. +Latest build date is 20260326, see the [changelog](changelog.md) for details. > [!NOTE] > A settings reset will be performed on an update of builds prior to 20241208. Backup and restore of settings is recommended. diff --git a/changelog.md b/changelog.md index 54fc31c..e6d24a7 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,18 @@ ## grblHAL changelog +Build 20260326 + +Core: + +* Improved support for using expander inputs for basic functions. "Hardened" code a bit. + +Drivers: + +* STM32F4xx: added support for using expander inputs for basic functions, plus some optional pins for spindle encoder input. +Spindle encoder bug fix, ref. issue [#149](https://github.com/grblHAL/STM32F4xx/issues/149). + +--- + 20260324 Core: diff --git a/grbl.h b/grbl.h index 387592e..9dd3f5a 100644 --- a/grbl.h +++ b/grbl.h @@ -42,7 +42,7 @@ #else #define GRBL_VERSION "1.1f" #endif -#define GRBL_BUILD 20260321 +#define GRBL_BUILD 20260326 #define GRBL_URL "https://github.com/grblHAL" diff --git a/ioports.c b/ioports.c index 56e8f66..1373671 100644 --- a/ioports.c +++ b/ioports.c @@ -403,6 +403,7 @@ FLASHMEM bool ioport_set_function (xbar_t *pin, pin_function_t function, driver_ if(io_port) do { if(io_port->ports_id == pin->ports_id && (ok = pin->set_function && pin->set_function(pin, function))) { + pin->function = function; cfg->bus.mask &= ~(1 << (pin->id + io_port->ports_id->cfg[pin->mode.output].n_start)); cfg->count = cfg->free = -1; diff --git a/machine_limits.c b/machine_limits.c index cd9e6d0..bf115ba 100644 --- a/machine_limits.c +++ b/machine_limits.c @@ -395,7 +395,7 @@ FLASHMEM static bool homing_cycle (axes_signals_t cycle, axes_signals_t auto_squ if (mode != HomingMode_Pulloff) { // Check homing switches state. Lock out cycle axes when they change. - homing_state = homing_signals_select(signals_state = hal.homing.get_state(), auto_square, squaring_mode); + homing_state = homing_signals_select((signals_state = hal.homing.get_state()), auto_square, squaring_mode); // Auto squaring check if((homing_state.mask & auto_square.mask) && squaring_mode == SquaringMode_Both) { diff --git a/pin_bits_masks.h b/pin_bits_masks.h index 6032b0e..9d42a20 100644 --- a/pin_bits_masks.h +++ b/pin_bits_masks.h @@ -580,8 +580,8 @@ static inline void aux_ctrl_claim_out_ports (aux_claim_explicit_out_ptr aux_clai if(aux_ctrl_out[idx].gpio.port == (void *)EXPANDER_PORT) { if(ioports_enumerate(Port_Digital, Port_Output, (pin_cap_t){ .external = On, .claimable = On }, aux_claim, &aux_ctrl_out[idx])) { if((aux_ctrl_out[idx].output = ioport_claim(Port_Digital, Port_Output, &aux_ctrl_out[idx].port, NULL))) { - ioport_set_function((xbar_t *)aux_ctrl_out[idx].output, aux_ctrl_out[idx].function, NULL); - aux_claim_explicit(&aux_ctrl_out[idx]); + if(ioport_set_function((xbar_t *)aux_ctrl_out[idx].output, aux_ctrl_out[idx].function, NULL)) + aux_claim_explicit(&aux_ctrl_out[idx]); } } } else diff --git a/vfs.c b/vfs.c index 344fab9..259cfc2 100644 --- a/vfs.c +++ b/vfs.c @@ -663,10 +663,12 @@ bool vfs_unmount (const char *path) vfs_drive_t *vfs_get_drive (const char *path) { static vfs_drive_t drive; + static char mpath[VFS_MOUNT_PATH_LEN]; vfs_mount_t *mount = get_mount(path); + strcpy(mpath, mount->path); drive.name = mount->vfs->fs_name; - drive.path = (const char *)mount->path; + drive.path = mpath; drive.mode = mount->mode; drive.removable = mount->vfs->removable; drive.fs = mount->vfs; @@ -701,13 +703,15 @@ vfs_drives_t *vfs_drives_open (void) vfs_drive_t *vfs_drives_read (vfs_drives_t *handle, bool add_hidden) { static vfs_drive_t drive; + static char path[VFS_MOUNT_PATH_LEN]; bool ok; if((ok = handle->mount != NULL)) { + strcpy(path, handle->mount->path); drive.name = handle->mount->vfs->fs_name; - drive.path = (const char *)handle->mount->path; + drive.path = path; drive.mode = handle->mount->mode; drive.removable = handle->mount->vfs->removable; drive.fs = handle->mount->vfs; diff --git a/vfs.h b/vfs.h index ec8bb23..710b30a 100644 --- a/vfs.h +++ b/vfs.h @@ -33,6 +33,8 @@ #include #include +#define VFS_MOUNT_PATH_LEN 33 + #define vfs_load_plugin(x) #ifndef bcopy @@ -175,7 +177,7 @@ typedef struct { typedef struct vfs_mount { - char path[64]; + char path[VFS_MOUNT_PATH_LEN]; const vfs_t *vfs; vfs_st_mode_t mode; #ifdef ESP_PLATFORM // some versions of ESP-IDF/Compiler combos are fcked up @@ -198,7 +200,7 @@ typedef struct { typedef struct { const char *name; - const char *path; + char *path; bool removable; vfs_st_mode_t mode; const void *fs;