diff --git a/framework/system_settings.c b/framework/system_settings.c index 1fc1595..9dc7771 100644 --- a/framework/system_settings.c +++ b/framework/system_settings.c @@ -5,14 +5,16 @@ #include "platform.h" #include "utils/str_utils.h" #include "system_settings.h" +#include "platform/lock_jumper.h" struct system_settings SystemSettings; void systemsettings_init(void) { SystemSettings.visible_vcom = true; - SystemSettings.editable = false; // This will be loaded in platform init based on the LOCK pin SystemSettings.modified = false; + + LockJumper_ReadHardware(); } // to binary diff --git a/gex.mk b/gex.mk index 2bf0055..7b5eab1 100644 --- a/gex.mk +++ b/gex.mk @@ -46,7 +46,7 @@ GEX_CDEFS = \ -DUSE_FULL_LL_DRIVER \ -DUSE_FULL_ASSERT=1 \ -DVERBOSE_ASSERT=1 \ --DDEBUG_VFS=0 \ +-DDEBUG_VFS=1 \ -DVERBOSE_HARDFAULT=1 \ -DUSE_STACK_MONITOR=1 \ -DUSE_DEBUG_UART=1 diff --git a/platform/lock_jumper.c b/platform/lock_jumper.c index 385d7f4..81110b5 100644 --- a/platform/lock_jumper.c +++ b/platform/lock_jumper.c @@ -75,7 +75,7 @@ void LockJumper_Check(void) // Read the pin state bool old = SystemSettings.editable; - SystemSettings.editable = (bool) LL_GPIO_IsInputPinSet(lock_periph, lock_llpin); + LockJumper_ReadHardware(); if (old != SystemSettings.editable) { // --- State changed --- @@ -84,3 +84,8 @@ void LockJumper_Check(void) jumper_changed(); } } + +void LockJumper_ReadHardware(void) +{ + SystemSettings.editable = (bool) LL_GPIO_IsInputPinSet(lock_periph, lock_llpin); +} diff --git a/platform/lock_jumper.h b/platform/lock_jumper.h index 0ec8c14..54b261c 100644 --- a/platform/lock_jumper.h +++ b/platform/lock_jumper.h @@ -17,4 +17,10 @@ void LockJumper_Init(void); */ void LockJumper_Check(void); +/** + * Check hardware jumper and load it's value into the settings struct. + * Does NOT trigger MSC changes or anything else. + */ +void LockJumper_ReadHardware(void); + #endif //GEX_LOCK_JUMPER_H diff --git a/vfs/file_stream.c b/vfs/file_stream.c index fc83f90..3105083 100644 --- a/vfs/file_stream.c +++ b/vfs/file_stream.c @@ -238,7 +238,6 @@ static error_t close_conf(void *state) ini_parse_end(); settings_read_ini_end(); - // force a full remount to have the changes be visible vfs_mngr_fs_remount(true); return E_SUCCESS; diff --git a/vfs/vfs_manager.c b/vfs/vfs_manager.c index 578a45d..65a7900 100644 --- a/vfs/vfs_manager.c +++ b/vfs/vfs_manager.c @@ -38,6 +38,8 @@ // TRANSFER_NOT_STARTED || TRASNFER_FINISHED #define DISCONNECT_DELAY_MS 500 +bool vfs_is_windows = false; + // Make sure none of the delays exceed the max time COMPILER_ASSERT(CONNECT_DELAY_MS < MAX_EVENT_TIME_MS); COMPILER_ASSERT(RECONNECT_DELAY_MS < MAX_EVENT_TIME_MS); diff --git a/vfs/vfs_manager.h b/vfs/vfs_manager.h index 1928357..b9c181e 100644 --- a/vfs/vfs_manager.h +++ b/vfs/vfs_manager.h @@ -29,6 +29,8 @@ extern "C" { #endif +extern bool vfs_is_windows; + /* Callable from anywhere */ // Enable or disable the virtual filesystem diff --git a/vfs/vfs_user.c b/vfs/vfs_user.c index 6808a6c..12e99be 100644 --- a/vfs/vfs_user.c +++ b/vfs/vfs_user.c @@ -23,6 +23,7 @@ #include "framework/settings.h" #include "platform.h" #include "vfs_manager.h" +#include "str_utils.h" const vfs_filename_t daplink_drive_name = "VIRTUALFS"; @@ -67,6 +68,13 @@ void vfs_user_file_change_handler(const vfs_filename_t filename, vfs_file_change_t change, vfs_file_t file, vfs_file_t new_file_data) { + if (strstarts(filename, "SYSTEM~1")) { + vfs_printf("ATENTION - we are dealing with windows! Careful or it will crash!"); + // TODO take precautions + vfs_is_windows = true; + return; + } + if (VFS_FILE_CHANGED == change) { // Unused vfs_printf(">>> CHANGED %s", filename);