diff --git a/.cproject b/.cproject index 107e692..b975ced 100644 --- a/.cproject +++ b/.cproject @@ -24,6 +24,7 @@ @@ -145,6 +147,7 @@ + diff --git a/.settings/com.st.stm32cube.ide.mcu.sfrview.prefs b/.settings/com.st.stm32cube.ide.mcu.sfrview.prefs new file mode 100644 index 0000000..98a69fc --- /dev/null +++ b/.settings/com.st.stm32cube.ide.mcu.sfrview.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +sfrviewstate={"fFavorites"\:{"fLists"\:{}},"fProperties"\:{"fNodeProperties"\:{}}} diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index 08968c0..605bf69 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/Core/Application/INIT_Initialization.c b/Core/Application/INIT_Initialization.c index 3446ae9..988c157 100644 --- a/Core/Application/INIT_Initialization.c +++ b/Core/Application/INIT_Initialization.c @@ -157,7 +157,7 @@ PRIVATE VOID vTask( PVOID arg ) BOOL boOK = TRUE; - //boOK &= USFL_boInitializeModule(); + boOK &= USFL_boInitializeModule(); boOK &= VARH_boInitializeModule(); boOK &= DIPO_boInitializeModule(); diff --git a/Core/Application/VARH_VariableHandler.c b/Core/Application/VARH_VariableHandler.c index cfef782..2bb3f29 100644 --- a/Core/Application/VARH_VariableHandler.c +++ b/Core/Application/VARH_VariableHandler.c @@ -374,7 +374,7 @@ BOOL VARH_vSaveVariablestoFlash( VOID ) for( U8 u8Var = 0; u8Var < VARH_eNumberOfVariables; u8Var++ ) { if( (m_astVarInfo[u8Var].u8Flags & VARH_FLAGINFO_FLASH) == VARH_FLAGINFO_FLASH ){ - boOK &= USFL_boSetVariable(u8Var, VARH_u32GetVariableData(u8Var)); + boOK &= USFL_boSetVariable(u8Var, VARH_uGetVariableData(u8Var)); } } USFL_vLock(); @@ -395,9 +395,9 @@ VOID VARH_vLoadVariablesfromFlash( VOID ) for( U8 u8Var = 0; u8Var < VARH_eNumberOfVariables; u8Var++ ) { if( (m_astVarInfo[u8Var].u8Flags & VARH_FLAGINFO_FLASH) == VARH_FLAGINFO_FLASH ){ - U32 u32Data; - boOK &= USFL_boGetVariable(u8Var, &u32Data); - if( boOK ) VARH_vSetVariableDataFromSystemU32(u8Var, u32Data); + VARH_UVariable uData; + boOK &= USFL_boGetVariable(u8Var, &uData); + if( boOK ) VARH_vSetVariableDataFromSystem(u8Var, uData); } } if( !boOK ){ diff --git a/Core/Drivers/USFL_UserFlash.c b/Core/Drivers/USFL_UserFlash.c index fb42596..cc9c94b 100644 --- a/Core/Drivers/USFL_UserFlash.c +++ b/Core/Drivers/USFL_UserFlash.c @@ -34,6 +34,7 @@ //================================================================================================= #include "USFL_UserFlash.h" +#include "UTIL_Utility.h" // include STM32 drivers #include "stm32l4xx_hal.h" @@ -116,7 +117,9 @@ BOOL USFL_boInitializeModule( VOID ) boOK &= ( ( m_pstMutexID = osMutexNew( &m_stMutexAttr )) == NULL) ? FALSE : TRUE; + boOK &= USFL_vUnlock(); boOK &= EE_Init(EE_FORCED_ERASE) == EE_OK ? TRUE : FALSE; + boOK &= USFL_vLock(); return( boOK ); } @@ -128,12 +131,12 @@ BOOL USFL_boInitializeModule( VOID ) // U32 * u32Variable -> pointer to data // Returns: Boolean TRUE if successful //------------------------------------------------------------------------------------------------- -BOOL USFL_boGetVariable ( U8 u8Variable, U32 * u32Variable ){ +BOOL USFL_boGetVariable ( U8 u8Variable, VARH_UVariable * uVariable ){ BOOL boOK = TRUE; - osMutexAcquire( m_pstMutexID, osWaitForever ); // aquire mutex - boOK &= EE_ReadVariable32bits( (U16) u8Variable, u32Variable ) == EE_OK ? TRUE : FALSE; - osMutexRelease( m_pstMutexID ); // release mutex + boOK &= EE_ReadVariable32bits( (U16) u8Variable, (PU32)uVariable ) == EE_OK ? TRUE : FALSE; + + //*u32Variable = UTIL_u32RevFLOAT( *u32Variable ); return boOK; } @@ -145,22 +148,19 @@ BOOL USFL_boGetVariable ( U8 u8Variable, U32 * u32Variable ){ // U32 u32Variable -> data to write // Returns: Boolean TRUE if successful //------------------------------------------------------------------------------------------------- -BOOL USFL_boSetVariable ( U8 u8Variable, U32 u32Variable ){ +BOOL USFL_boSetVariable ( U8 u8Variable, VARH_UVariable uVariable ){ BOOL boOK = TRUE; EE_Status ee_status = EE_OK; - osMutexAcquire( m_pstMutexID, osWaitForever ); // aquire mutex - boOK &= (ee_status = EE_WriteVariable32bits( (U16) u8Variable, u32Variable )) == EE_OK ? TRUE : FALSE; + boOK &= (ee_status = EE_WriteVariable32bits( (U16) u8Variable, uVariable.u32Val )) == EE_OK ? TRUE : FALSE; - /* Start cleanup IT mode, if cleanup is needed */ + /* Start cleanup mode, if cleanup is needed */ if ((ee_status & EE_STATUSMASK_CLEANUP) == EE_STATUSMASK_CLEANUP) { ErasingOnGoing = 1; boOK &= (ee_status |= EE_CleanUp()) == EE_OK ? TRUE : FALSE; } if ((ee_status & EE_STATUSMASK_ERROR) == EE_STATUSMASK_ERROR) {boOK &= FALSE;} - osMutexRelease( m_pstMutexID ); // release mutex - return boOK; } @@ -174,6 +174,7 @@ BOOL USFL_vLock( VOID ){ BOOL boOK = TRUE; boOK &= HAL_FLASH_Lock() == HAL_OK ? TRUE : FALSE; + osMutexRelease( m_pstMutexID ); // release mutex return boOK; } @@ -187,6 +188,7 @@ BOOL USFL_vLock( VOID ){ BOOL USFL_vUnlock( VOID ){ BOOL boOK = TRUE; + osMutexAcquire( m_pstMutexID, osWaitForever ); // aquire mutex boOK &= HAL_FLASH_Unlock() == HAL_OK ? TRUE : FALSE; return boOK; diff --git a/Core/Drivers/USFL_UserFlash.h b/Core/Drivers/USFL_UserFlash.h index 3cd78a1..a64d533 100644 --- a/Core/Drivers/USFL_UserFlash.h +++ b/Core/Drivers/USFL_UserFlash.h @@ -34,7 +34,7 @@ extern "C" { //================================================================================================= #include "../SDEF_StandardDefinitions.h" - +#include "VARH_VariableHandler.h" //================================================================================================= @@ -87,8 +87,8 @@ extern "C" { //================================================================================================= BOOL USFL_boInitializeModule( VOID ); -BOOL USFL_boGetVariable ( U8 u8Variable, U32 * u32Variable ); -BOOL USFL_boSetVariable ( U8 u8Variable, U32 u32Variable ); +BOOL USFL_boGetVariable ( U8 u8Variable, VARH_UVariable * uVariable ); +BOOL USFL_boSetVariable ( U8 u8Variable, VARH_UVariable uVariable ); BOOL USFL_vLock( VOID ); BOOL USFL_vUnlock( VOID ); diff --git a/tec Debug.launch b/tec Debug.launch new file mode 100644 index 0000000..5ad4ea8 --- /dev/null +++ b/tec Debug.launch @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +