working on bug fix flash save

This commit is contained in:
2022-12-14 08:32:28 +01:00
parent 54fef083bf
commit 9476d996ff
8 changed files with 105 additions and 20 deletions

View File

@ -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;