| [1] | 1 | /**
|
|---|
| 2 | ******************************************************************************
|
|---|
| 3 | * @file EEPROM_Emul/Porting/STM32G0/flash_interface.h
|
|---|
| 4 | * @author MCD Application Team
|
|---|
| 5 | * @brief This file contains all the functions prototypes for the EEPROM
|
|---|
| 6 | * emulation flash interface.
|
|---|
| 7 | ******************************************************************************
|
|---|
| 8 | * @attention
|
|---|
| 9 | *
|
|---|
| 10 | * <h2><center>© Copyright (c) 2020 STMicroelectronics International N.V.
|
|---|
| 11 | * All rights reserved.</center></h2>
|
|---|
| 12 | *
|
|---|
| 13 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 14 | * modification, are permitted, provided that the following conditions are met:
|
|---|
| 15 | *
|
|---|
| 16 | * 1. Redistribution of source code must retain the above copyright notice,
|
|---|
| 17 | * this list of conditions and the following disclaimer.
|
|---|
| 18 | * 2. Redistributions in binary form must reproduce the above copyright notice,
|
|---|
| 19 | * this list of conditions and the following disclaimer in the documentation
|
|---|
| 20 | * and/or other materials provided with the distribution.
|
|---|
| 21 | * 3. Neither the name of STMicroelectronics nor the names of other
|
|---|
| 22 | * contributors to this software may be used to endorse or promote products
|
|---|
| 23 | * derived from this software without specific written permission.
|
|---|
| 24 | * 4. This software, including modifications and/or derivative works of this
|
|---|
| 25 | * software, must execute solely and exclusively on microcontroller or
|
|---|
| 26 | * microprocessor devices manufactured by or for STMicroelectronics.
|
|---|
| 27 | * 5. Redistribution and use of this software other than as permitted under
|
|---|
| 28 | * this license is void and will automatically terminate your rights under
|
|---|
| 29 | * this license.
|
|---|
| 30 | *
|
|---|
| 31 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
|---|
| 32 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
|---|
| 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|---|
| 34 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
|
|---|
| 35 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
|---|
| 36 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 37 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|---|
| 38 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|---|
| 39 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|---|
| 40 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|---|
| 41 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|---|
| 42 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 43 | *
|
|---|
| 44 | ******************************************************************************
|
|---|
| 45 | */
|
|---|
| 46 |
|
|---|
| 47 | /* Define to prevent recursive inclusion -------------------------------------*/
|
|---|
| 48 | #ifndef __FLASH_INTERFACE_H
|
|---|
| 49 | #define __FLASH_INTERFACE_H
|
|---|
| 50 |
|
|---|
| 51 | #ifdef __cplusplus
|
|---|
| 52 | extern "C" {
|
|---|
| 53 | #endif
|
|---|
| 54 |
|
|---|
| 55 | /* Includes ------------------------------------------------------------------*/
|
|---|
| 56 | #include "stm32g0xx_hal.h"
|
|---|
| 57 | #include "stm32g0xx_ll_crc.h"
|
|---|
| 58 | #include "stm32g0xx_ll_bus.h"
|
|---|
| 59 |
|
|---|
| 60 | /** @addtogroup EEPROM_Emulation
|
|---|
| 61 | * @{
|
|---|
| 62 | */
|
|---|
| 63 |
|
|---|
| 64 | /* Exported types ------------------------------------------------------------*/
|
|---|
| 65 | /* Exported macro ------------------------------------------------------------*/
|
|---|
| 66 | /* Exported functions ------------------------------------------------------- */
|
|---|
| 67 |
|
|---|
| 68 | /* Private types -------------------------------------------------------------*/
|
|---|
| 69 | /* Private constants ---------------------------------------------------------*/
|
|---|
| 70 | /** @addtogroup EEPROM_Private_Constants
|
|---|
| 71 | * @{
|
|---|
| 72 | */
|
|---|
| 73 |
|
|---|
| 74 | /** @addtogroup Private_Other_Constants
|
|---|
| 75 | * @{
|
|---|
| 76 | */
|
|---|
| 77 |
|
|---|
| 78 | #define BANK_SIZE FLASH_BANK_SIZE /*!< Alias to FLASH_BANK_SIZE definition from HAL STM32L4 */
|
|---|
| 79 | #define EE_ACCESS_32BITS /*!< Enable EEPROM 32bits R/W functions, only valid for flash allowing 64bits access*/
|
|---|
| 80 |
|
|---|
| 81 | /* Page state header */
|
|---|
| 82 | #define EE_PAGESTAT_ERASED (uint64_t)0xFFFFFFFFFFFFFFFFU /*!< State saved in 1st,2nd,3rd,4th data type of page header */
|
|---|
| 83 | #define EE_PAGESTAT_RECEIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 1st data type of page header */
|
|---|
| 84 | #define EE_PAGESTAT_ACTIVE (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 2nd data type of page header */
|
|---|
| 85 | #define EE_PAGESTAT_VALID (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 3rd data type of page header */
|
|---|
| 86 | #define EE_PAGESTAT_ERASING (uint64_t)0xAAAAAAAAAAAAAAAAU /*!< State saved in 4th data type of page header */
|
|---|
| 87 |
|
|---|
| 88 | /* Description of the 8 Bytes (64 bits) element in flash */
|
|---|
| 89 | /* Bit: 63 32 31 16 15 0 */
|
|---|
| 90 | /* <--- Data Value -----> <-unused-> <-VirtAddr-> */
|
|---|
| 91 | #define EE_ELEMENT_SIZE 8U /*!< Size of element in Bytes */
|
|---|
| 92 | #define EE_ELEMENT_TYPE uint64_t /*!< Type of element */
|
|---|
| 93 | #define EE_VIRTUALADDRESS_TYPE uint16_t /*!< Type of Virtual Address */
|
|---|
| 94 | #define EE_VIRTUALADDRESS_SHIFT 0U /*!< Bits Shifting to get Virtual Address in element */
|
|---|
| 95 | #define EE_CRC_TYPE uint16_t /*!< Type of Crc */
|
|---|
| 96 | #define EE_CRC_SHIFT 16U /*!< Bits Shifting to get Crc in element */
|
|---|
| 97 | #define EE_DATA_TYPE uint32_t /*!< Type of Data */
|
|---|
| 98 | #define EE_DATA_SHIFT 32U /*!< Bits Shifting to get Data value in element */
|
|---|
| 99 | #define EE_MASK_VIRTUALADDRESS (uint64_t)0x000000000000FFFFU
|
|---|
| 100 | #define EE_MASK_CRC (uint64_t)0x00000000FFFF0000U
|
|---|
| 101 | #define EE_MASK_DATA (uint64_t)0xFFFFFFFF00000000U
|
|---|
| 102 | #define EE_MASK_FULL (uint64_t)0xFFFFFFFFFFFFFFFFU
|
|---|
| 103 |
|
|---|
| 104 | /**
|
|---|
| 105 | * @}
|
|---|
| 106 | */
|
|---|
| 107 |
|
|---|
| 108 | /**
|
|---|
| 109 | * @}
|
|---|
| 110 | */
|
|---|
| 111 |
|
|---|
| 112 | /* Private macro -------------------------------------------------------------*/
|
|---|
| 113 | /** @addtogroup EEPROM_Private_Macros
|
|---|
| 114 | * @{
|
|---|
| 115 | */
|
|---|
| 116 |
|
|---|
| 117 | /**
|
|---|
| 118 | * @}
|
|---|
| 119 | */
|
|---|
| 120 |
|
|---|
| 121 | /**
|
|---|
| 122 | * @}
|
|---|
| 123 | */
|
|---|
| 124 |
|
|---|
| 125 | /* Private functions ---------------------------------------------------------*/
|
|---|
| 126 | /** @addtogroup EEPROM_Private_Functions
|
|---|
| 127 | * @{
|
|---|
| 128 | */
|
|---|
| 129 | HAL_StatusTypeDef FI_WriteDoubleWord(uint32_t Address, uint64_t Data);
|
|---|
| 130 | EE_Status FI_PageErase(uint32_t Page, uint16_t NbPages);
|
|---|
| 131 | EE_Status FI_PageErase_IT(uint32_t Page, uint16_t NbPages);
|
|---|
| 132 | EE_Status FI_DeleteCorruptedFlashAddress(uint32_t Address);
|
|---|
| 133 | EE_Status FI_CheckBankConfig(void);
|
|---|
| 134 |
|
|---|
| 135 | /**
|
|---|
| 136 | * @}
|
|---|
| 137 | */
|
|---|
| 138 |
|
|---|
| 139 | #ifdef __cplusplus
|
|---|
| 140 | }
|
|---|
| 141 | #endif
|
|---|
| 142 |
|
|---|
| 143 | /**
|
|---|
| 144 | * @}
|
|---|
| 145 | */
|
|---|
| 146 |
|
|---|
| 147 | #endif /* __FLASH_INTERFACE_H */
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|---|