![]() |
ParaLib 2.0.15-master SHA: 2e03d68caa
|
Flash parameter storage for STMicroelectronics SMT32H7 Series. More...
#include <stdbool.h>#include <stdint.h>#include "project_config.h"#include <string.h>#include "Error/Error_ID_System.h"#include "Error/Error.h"#include "Para/SYS_Type.h"#include "Math/MATH_Crc.h"#include "Para/PARA_Lib.h"#include "Para/PARA_ID_System.h"#include "Error/LogMessage.h"#include "basicModules/Para/PARA_Backup.h"#include "basicModules/Network/ptp_timestamp.h"#include "PARA_Flash_STM32H7.h"#include "stm32h7xx_hal.h"#include "stm32h7xx_hal_conf.h"#include "MemoryOrganization.h"#include "FreeRTOS.h"#include "task.h"#include "gitRevision.h"#include "PARA_Identifikation.h"Data Structures | |
| struct | tFlashInformation |
| Information stored in flash about the contents of the flash page. More... | |
| struct | t_ParaFlashDataset |
| Datastructure of one flash block. More... | |
Macros | |
| #define | MEMBER_SIZEOF(t, f) (sizeof(((t*)0)->f)) |
| #define | PARA_FLASH_SIZE_DATA 24 |
| Size of data stored in one flash block. In the block some meta-information is stored besides the data. More... | |
| #define | PARA_FLASH_SIZE_BLOCK FLASH_NB_32BITWORD_IN_FLASHWORD*4 |
| Total size of one flash block. More... | |
| #define | MAXIMUM_PARAMETER_DATAPOINTER ((PARAMETER_FLASH_MAX_SIZE - PARA_FLASH_SIZE_BLOCK) /PARA_FLASH_SIZE_BLOCK) |
| Maximum address of valid flash blocks. More... | |
| #define | PARAMETER_FLASH_VERSION 1 |
| Version of the flash library. More... | |
| #define | BSY_FLAG FLASH_FLAG_QW_BANK1 |
Functions | |
| static bool | FlashErrorReset (void) |
| Error-reset definition which is called after error-reset in if a flash error is present. More... | |
| DefineOnErrorResetReaction (FlashErrorReset, "Flash Error Reset", "DOC_D Parameter überprüfen und im Flash speichern zum zurückzusetzen.\DOC_E Review Parameters and save to Flash to reset.") | |
| Function which is called after error-reset in if a flash error is present. More... | |
| void | PARA_FlashInit (void) |
| Initialization of parameter flash interface needs to be called before: More... | |
| void | PARA_FlashReadFromBackup (uint16_t location, ParameterAccessSource Access, uint8_t AccessLevel) |
| Reads backup-values from flash and stores them into parameter values. More... | |
| static void | WriteToBackupThread (const void *argument) |
| Writes backup-values into flash. More... | |
| bool | PARA_FlashWriteToBackup (uint16_t location) |
| Writes backup-values into flash All parameters with storage-location selected in parameter location are processed, all others are ignored. More... | |
| static bool | VerifyBackupArea (tFlashInformation *FlashDataLocation) |
| The Backup-Area in flash is verified. More... | |
| static HAL_StatusTypeDef | FlashEraseParaSector (uint32_t sector) |
| Erase one complete sector in flash. More... | |
| int32_t | ReadFunction_FlashInfo_U16 (Parameter *ptThis, uint16_t ui16SubId, void *pData, int32_t ui32MaxCount, uint32_t ui32Offset, ParameterAccessSource tAccessSource, uint8_t ui8AccessLevel) |
| Read-function for accessing the flash-information. More... | |
| int32_t | ReadFunction_FlashInfo_U32 (Parameter *ptThis, uint16_t ui16SubId, void *pData, int32_t ui32MaxCount, uint32_t ui32Offset, ParameterAccessSource tAccessSource, uint8_t ui8AccessLevel) |
| Read-function for accessing the flash-information. More... | |
| int32_t | ReadFunction_FlashInfo_STR (Parameter *ptThis, uint16_t ui16SubId, void *pData, int32_t ui32MaxCount, uint32_t ui32Offset, ParameterAccessSource tAccessSource, uint8_t ui8AccessLevel) |
| Read-function for accessing the flash-information. More... | |
| ParameterU16 FlashData1 ParameterU32 FlashData1 | ParameterSTR ((char *)&FlashData1.SoftwareVersion, PARA_ID_FlashSoftwareVersion, GROUP_ID_System, "Parameter Flash Softwareversion", "", "Software Version which saved the Parameters", "", "", "", 1, 30, "unknown", ReadFunction_FlashInfo_STR, WriteFunction_STD_Const, SetToDefaultFunction_STD_Const, VIEWER_READ|USER_READ|PROFESSIONAL_READ|DEVELOPER_READ, NOT_STORED, FLAG_NONE) ParameterU32(&FlashData1.WriteTimestamp |
Flash parameter storage for STMicroelectronics SMT32H7 Series.
© Copyright 2017-2022 Copyright: Retostronik GmbH Stütingstraße 30 58285 Gevelsberg
| #define BSY_FLAG FLASH_FLAG_QW_BANK1 |
| #define MAXIMUM_PARAMETER_DATAPOINTER ((PARAMETER_FLASH_MAX_SIZE - PARA_FLASH_SIZE_BLOCK) /PARA_FLASH_SIZE_BLOCK) |
Maximum address of valid flash blocks.
| #define MEMBER_SIZEOF | ( | t, | |
| f | |||
| ) | (sizeof(((t*)0)->f)) |
| #define PARA_FLASH_SIZE_BLOCK FLASH_NB_32BITWORD_IN_FLASHWORD*4 |
Total size of one flash block.
| #define PARA_FLASH_SIZE_DATA 24 |
Size of data stored in one flash block. In the block some meta-information is stored besides the data.
| #define PARAMETER_FLASH_VERSION 1 |
Version of the flash library.
| DefineOnErrorResetReaction | ( | FlashErrorReset | , |
| "Flash Error Reset" | , | ||
| "DOC_D Parameter überprüfen und im Flash speichern zum zurückzusetzen.\DOC_E Review Parameters and save to Flash to reset." | |||
| ) |
Function which is called after error-reset in if a flash error is present.
| true | if ErrorReset was successful |
| false | if ErrorReset was not successful |
|
static |
Erase one complete sector in flash.
| sector | Number of the sector to be erased. |
|
static |
Error-reset definition which is called after error-reset in if a flash error is present.
| void PARA_FlashInit | ( | void | ) |
Initialization of parameter flash interface needs to be called before:
| void PARA_FlashReadFromBackup | ( | uint16_t | location, |
| ParameterAccessSource | Access, | ||
| uint8_t | AccessLevel | ||
| ) |
Reads backup-values from flash and stores them into parameter values.
All parameters with storage-location selected in parameter location are processed, all others are ignored. The parameter values are written with the OnWrite-function defined in the parameter itself. In case of an error, the default value is set.
| location | selects the storage location |
| Access | Source of access (see Access restrictions). |
| AccessLevel | Actual AccessLevel (see Access restrictions). |
| bool PARA_FlashWriteToBackup | ( | uint16_t | location | ) |
Writes backup-values into flash All parameters with storage-location selected in parameter location are processed, all others are ignored.
| location | selects the storage location |
| True | if successfull. |
| ParameterU16 FlashData1 ParameterU32 FlashData1 ParameterSTR | ( | (char *)&FlashData1. | SoftwareVersion, |
| PARA_ID_FlashSoftwareVersion | , | ||
| GROUP_ID_System | , | ||
| "Parameter Flash Softwareversion" | , | ||
| "" | , | ||
| "Software Version which saved the Parameters" | , | ||
| "" | , | ||
| "" | , | ||
| "" | , | ||
| 1 | , | ||
| 30 | , | ||
| "unknown" | , | ||
| ReadFunction_FlashInfo_STR | , | ||
| WriteFunction_STD_Const | , | ||
| SetToDefaultFunction_STD_Const | , | ||
| VIEWER_READ|USER_READ|PROFESSIONAL_READ| | DEVELOPER_READ, | ||
| NOT_STORED | , | ||
| FLAG_NONE | |||
| ) | & |
| int32_t ReadFunction_FlashInfo_STR | ( | Parameter * | ptThis, |
| uint16_t | ui16SubId, | ||
| void * | pData, | ||
| int32_t | ui32MaxCount, | ||
| uint32_t | ui32Offset, | ||
| ParameterAccessSource | tAccessSource, | ||
| uint8_t | ui8AccessLevel | ||
| ) |
Read-function for accessing the flash-information.
This function is neccessary, because during erase operation, every access of the flash bank stalls the processor. During erase the access is trapped to prevent a processor stall.
| ptThis | Pointer to the Parameter. | |
| ui16SubId | SubID to read. | |
| [out] | pData | Outputbuffer to store the parametervalue. |
| ui32MaxCount | Buffer size. If smaller than data size, return 0 | |
| ui32Offset | Start-offset to read from. If bigger than data-size return 0 | |
| tAccessSource | Source of access (see Access restrictions). | |
| ui8AccessLevel | Actual AccessLevel (see Access restrictions). |
| int32_t ReadFunction_FlashInfo_U16 | ( | Parameter * | ptThis, |
| uint16_t | ui16SubId, | ||
| void * | pData, | ||
| int32_t | ui32MaxCount, | ||
| uint32_t | ui32Offset, | ||
| ParameterAccessSource | tAccessSource, | ||
| uint8_t | ui8AccessLevel | ||
| ) |
Read-function for accessing the flash-information.
This function is neccessary, because during erase operation, every access of the flash bank stalls the processor. During erase the access is trapped to prevent a processor stall.
| ptThis | Pointer to the Parameter. | |
| ui16SubId | SubID to read. | |
| [out] | pData | Outputbuffer to store the parametervalue. |
| ui32MaxCount | Buffer size. If smaller than data size, return 0 | |
| ui32Offset | Start-offset to read from. If bigger than data-size return 0 | |
| tAccessSource | Source of access (see Access restrictions). | |
| ui8AccessLevel | Actual AccessLevel (see Access restrictions). |
| int32_t ReadFunction_FlashInfo_U32 | ( | Parameter * | ptThis, |
| uint16_t | ui16SubId, | ||
| void * | pData, | ||
| int32_t | ui32MaxCount, | ||
| uint32_t | ui32Offset, | ||
| ParameterAccessSource | tAccessSource, | ||
| uint8_t | ui8AccessLevel | ||
| ) |
Read-function for accessing the flash-information.
This function is neccessary, because during erase operation, every access of the flash bank stalls the processor. During erase the access is trapped to prevent a processor stall.
| ptThis | Pointer to the Parameter. | |
| ui16SubId | SubID to read. | |
| [out] | pData | Outputbuffer to store the parametervalue. |
| ui32MaxCount | Buffer size. If smaller than data size, return 0 | |
| ui32Offset | Start-offset to read from. If bigger than data-size return 0 | |
| tAccessSource | Source of access (see Access restrictions). | |
| ui8AccessLevel | Actual AccessLevel (see Access restrictions). |
|
static |
The Backup-Area in flash is verified.
A 32-Bit CRC is calculated and compared to the stored value in zhe stored flashInformation. If CRC is matching, true is returned.
| FlashDataLocation | Pointer to the flash-information stored in flash. |
| True | if successfull. |
|
static |
Writes backup-values into flash.
All parameters with storage-location PARA_FLASH are processed, all others are ignored. This function is realized as a task. It has to be called as following:
| argument | not used. Set NULL as argument. |
| ParameterU16 FlashData1 ParameterU32 FlashData1 GROUP_ID_System |
| ParameterU16 FlashData1 ParameterU32 FlashData1 PARA_ID_FlashTimestamp |
| ParameterU16 FlashData1 ParameterU32 FlashData1 Parameter Write Timestamp |