diff --git a/firmware/boards/f0_module/port.cpp b/firmware/boards/f0_module/port.cpp index e8f0362..4bd360a 100644 --- a/firmware/boards/f0_module/port.cpp +++ b/firmware/boards/f0_module/port.cpp @@ -95,12 +95,12 @@ int InitConfiguration() return 0; } -Configuration GetConfiguration() +static Configuration c; + +Configuration& GetConfiguration() { const auto& cfg = __configflash__start__; - Configuration c; - // If config has been written before, use the stored configuration if (cfg.IsValid()) { diff --git a/firmware/boards/f1_dual/port.cpp b/firmware/boards/f1_dual/port.cpp index 1857eaa..51262b8 100644 --- a/firmware/boards/f1_dual/port.cpp +++ b/firmware/boards/f1_dual/port.cpp @@ -117,10 +117,12 @@ static struct { uint8_t pad[128]; } config; -Configuration GetConfiguration() +static Configuration c; + +Configuration& GetConfiguration() { // TODO: implement me! - return {}; + return c; } void SetConfiguration(const Configuration& newConfig) diff --git a/firmware/boards/f1_rev2/port.cpp b/firmware/boards/f1_rev2/port.cpp index d5fd4a9..d898184 100644 --- a/firmware/boards/f1_rev2/port.cpp +++ b/firmware/boards/f1_rev2/port.cpp @@ -81,10 +81,12 @@ static struct { uint8_t pad[128]; } config; -Configuration GetConfiguration() +static Configuration c; + +Configuration& GetConfiguration() { // TODO: implement me! - return {}; + return c; } void SetConfiguration(const Configuration& newConfig) diff --git a/firmware/boards/f1_rev3/port.cpp b/firmware/boards/f1_rev3/port.cpp index a3f47e3..d9e3fdd 100644 --- a/firmware/boards/f1_rev3/port.cpp +++ b/firmware/boards/f1_rev3/port.cpp @@ -108,10 +108,12 @@ int InitConfiguration() return 0; } -Configuration GetConfiguration() +static Configuration c; + +Configuration& GetConfiguration() { // TODO: implement me! - return {}; + return c; } void SetConfiguration(const Configuration& newConfig) diff --git a/firmware/boards/port.h b/firmware/boards/port.h index 05f2069..05211cf 100644 --- a/firmware/boards/port.h +++ b/firmware/boards/port.h @@ -38,7 +38,7 @@ public: uint8_t pad[128 - 1 - 4]; }; -Configuration GetConfiguration(); +Configuration& GetConfiguration(); void SetConfiguration(const Configuration& newConfig); /* TS stuff */ diff --git a/firmware/can.cpp b/firmware/can.cpp index 8d9410d..66c92fd 100644 --- a/firmware/can.cpp +++ b/firmware/can.cpp @@ -100,7 +100,7 @@ void CanRxThread(void*) // Check if it's an "index set" message else if (frame.DLC == 1 && frame.EID == WB_MSG_SET_INDEX) { - auto newCfg = GetConfiguration(); + auto &newCfg = GetConfiguration(); newCfg.CanIndexOffset = frame.data8[0]; SetConfiguration(newCfg); configuration = GetConfiguration();