diff --git a/GDI-4ch/firmware/main.cpp b/GDI-4ch/firmware/main.cpp index dbce2cf..b5ede5c 100644 --- a/GDI-4ch/firmware/main.cpp +++ b/GDI-4ch/firmware/main.cpp @@ -223,6 +223,8 @@ bool Pt2001::init() { Pt2001 chip; +mfs_error_t flashStartState; + /* * Application entry point. */ @@ -232,7 +234,7 @@ int main() { // Fire up all of our threads InitPins(); - bool isFlashOk = InitFlash(); + flashStartState = InitFlash(); InitCan(); InitUart(); @@ -242,10 +244,10 @@ int main() { palClearPad(LED_GREEN_PORT, LED_GREEN_PIN); bool isOverallHappyStatus = false; - if (isFlashOk) { - ReadOrDefault(); - isOverallHappyStatus = chip.init(); - } + + ReadOrDefault(); + // reminder that +12v is required for PT2001 to start + isOverallHappyStatus = chip.init(); while (true) { if (isOverallHappyStatus) { diff --git a/GDI-4ch/firmware/persistence.cpp b/GDI-4ch/firmware/persistence.cpp index 72a85f2..8c49487 100644 --- a/GDI-4ch/firmware/persistence.cpp +++ b/GDI-4ch/firmware/persistence.cpp @@ -2,7 +2,6 @@ #include "hal.h" #include "persistence.h" -#include "hal_mfs.h" #define MFS_RECORD_ID 1 @@ -19,10 +18,13 @@ const MFSConfig mfscfg1 = { static MFSDriver mfs1; uint8_t mfs_buffer[512]; -bool InitFlash() { +/** + * @return true if mfsStart is well + */ +mfs_error_t InitFlash() { mfsObjectInit(&mfs1); mfs_error_t err = mfsStart(&mfs1, &mfscfg1); - return err == MFS_NO_ERROR; + return err; } extern GDIConfiguration configuration; diff --git a/GDI-4ch/firmware/persistence.h b/GDI-4ch/firmware/persistence.h index 9cc1ea5..2b52cab 100644 --- a/GDI-4ch/firmware/persistence.h +++ b/GDI-4ch/firmware/persistence.h @@ -2,14 +2,14 @@ * @file persistence.h */ - +#include "hal_mfs.h" #pragma once /** * @return true if OK, false if broken */ -bool InitFlash(); +mfs_error_t InitFlash(); void saveConfiguration(); void ReadOrDefault();