anyThing Connected Team / mbed-dev

Dependents:   BREAK_SENSOR_LED

Fork of mbed-dev by mbed official

Committer:
Anythingconnected
Date:
Mon Dec 18 10:14:27 2017 +0000
Revision:
180:d79f997829d6
Parent:
167:e84263d55307
Getting byte by byte read to work

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 144:ef7eb2e8f9f7 1 /**
<> 144:ef7eb2e8f9f7 2 ******************************************************************************
<> 144:ef7eb2e8f9f7 3 * @file stm32l4xx_hal_firewall.h
<> 144:ef7eb2e8f9f7 4 * @author MCD Application Team
AnnaBridge 167:e84263d55307 5 * @version V1.7.1
AnnaBridge 167:e84263d55307 6 * @date 21-April-2017
<> 144:ef7eb2e8f9f7 7 * @brief Header file of FIREWALL HAL module.
<> 144:ef7eb2e8f9f7 8 ******************************************************************************
<> 144:ef7eb2e8f9f7 9 * @attention
<> 144:ef7eb2e8f9f7 10 *
AnnaBridge 167:e84263d55307 11 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
<> 144:ef7eb2e8f9f7 12 *
<> 144:ef7eb2e8f9f7 13 * Redistribution and use in source and binary forms, with or without modification,
<> 144:ef7eb2e8f9f7 14 * are permitted provided that the following conditions are met:
<> 144:ef7eb2e8f9f7 15 * 1. Redistributions of source code must retain the above copyright notice,
<> 144:ef7eb2e8f9f7 16 * this list of conditions and the following disclaimer.
<> 144:ef7eb2e8f9f7 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
<> 144:ef7eb2e8f9f7 18 * this list of conditions and the following disclaimer in the documentation
<> 144:ef7eb2e8f9f7 19 * and/or other materials provided with the distribution.
<> 144:ef7eb2e8f9f7 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
<> 144:ef7eb2e8f9f7 21 * may be used to endorse or promote products derived from this software
<> 144:ef7eb2e8f9f7 22 * without specific prior written permission.
<> 144:ef7eb2e8f9f7 23 *
<> 144:ef7eb2e8f9f7 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
<> 144:ef7eb2e8f9f7 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
<> 144:ef7eb2e8f9f7 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
<> 144:ef7eb2e8f9f7 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
<> 144:ef7eb2e8f9f7 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
<> 144:ef7eb2e8f9f7 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
<> 144:ef7eb2e8f9f7 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
<> 144:ef7eb2e8f9f7 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
<> 144:ef7eb2e8f9f7 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
<> 144:ef7eb2e8f9f7 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<> 144:ef7eb2e8f9f7 34 *
<> 144:ef7eb2e8f9f7 35 ******************************************************************************
<> 144:ef7eb2e8f9f7 36 */
<> 144:ef7eb2e8f9f7 37
<> 144:ef7eb2e8f9f7 38 /* Define to prevent recursive inclusion -------------------------------------*/
<> 144:ef7eb2e8f9f7 39 #ifndef __STM32L4xx_HAL_FIREWALL_H
<> 144:ef7eb2e8f9f7 40 #define __STM32L4xx_HAL_FIREWALL_H
<> 144:ef7eb2e8f9f7 41
<> 144:ef7eb2e8f9f7 42 #ifdef __cplusplus
<> 144:ef7eb2e8f9f7 43 extern "C" {
<> 144:ef7eb2e8f9f7 44 #endif
<> 144:ef7eb2e8f9f7 45
<> 144:ef7eb2e8f9f7 46 /* Includes ------------------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 47 #include "stm32l4xx_hal_def.h"
<> 144:ef7eb2e8f9f7 48
<> 144:ef7eb2e8f9f7 49 /** @addtogroup STM32L4xx_HAL_Driver
<> 144:ef7eb2e8f9f7 50 * @{
<> 144:ef7eb2e8f9f7 51 */
<> 144:ef7eb2e8f9f7 52
<> 144:ef7eb2e8f9f7 53 /** @addtogroup FIREWALL FIREWALL
<> 144:ef7eb2e8f9f7 54 * @{
<> 144:ef7eb2e8f9f7 55 */
<> 144:ef7eb2e8f9f7 56
<> 144:ef7eb2e8f9f7 57 /* Exported types ------------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 58 /** @defgroup FIREWALL_Exported_Types FIREWALL Exported Types
<> 144:ef7eb2e8f9f7 59 * @{
<> 144:ef7eb2e8f9f7 60 */
<> 144:ef7eb2e8f9f7 61
<> 144:ef7eb2e8f9f7 62 /**
<> 144:ef7eb2e8f9f7 63 * @brief FIREWALL Initialization Structure definition
<> 144:ef7eb2e8f9f7 64 */
<> 144:ef7eb2e8f9f7 65 typedef struct
<> 144:ef7eb2e8f9f7 66 {
<> 144:ef7eb2e8f9f7 67 uint32_t CodeSegmentStartAddress; /*!< Protected code segment start address. This value is 24-bit long, the 8 LSB bits are
<> 144:ef7eb2e8f9f7 68 reserved and forced to 0 in order to allow a 256-byte granularity. */
<> 144:ef7eb2e8f9f7 69
<> 144:ef7eb2e8f9f7 70 uint32_t CodeSegmentLength; /*!< Protected code segment length in bytes. This value is 22-bit long, the 8 LSB bits are
<> 144:ef7eb2e8f9f7 71 reserved and forced to 0 for the length to be a multiple of 256 bytes. */
<> 144:ef7eb2e8f9f7 72
<> 144:ef7eb2e8f9f7 73 uint32_t NonVDataSegmentStartAddress; /*!< Protected non-volatile data segment start address. This value is 24-bit long, the 8 LSB
<> 144:ef7eb2e8f9f7 74 bits are reserved and forced to 0 in order to allow a 256-byte granularity. */
<> 144:ef7eb2e8f9f7 75
<> 144:ef7eb2e8f9f7 76 uint32_t NonVDataSegmentLength; /*!< Protected non-volatile data segment length in bytes. This value is 22-bit long, the 8 LSB
<> 144:ef7eb2e8f9f7 77 bits are reserved and forced to 0 for the length to be a multiple of 256 bytes. */
<> 144:ef7eb2e8f9f7 78
<> 144:ef7eb2e8f9f7 79 uint32_t VDataSegmentStartAddress; /*!< Protected volatile data segment start address. This value is 17-bit long, the 6 LSB bits
<> 144:ef7eb2e8f9f7 80 are reserved and forced to 0 in order to allow a 64-byte granularity. */
<> 144:ef7eb2e8f9f7 81
<> 144:ef7eb2e8f9f7 82 uint32_t VDataSegmentLength; /*!< Protected volatile data segment length in bytes. This value is 17-bit long, the 6 LSB
<> 144:ef7eb2e8f9f7 83 bits are reserved and forced to 0 for the length to be a multiple of 64 bytes. */
<> 144:ef7eb2e8f9f7 84
<> 144:ef7eb2e8f9f7 85 uint32_t VolatileDataExecution; /*!< Set VDE bit specifying whether or not the volatile data segment can be executed.
<> 144:ef7eb2e8f9f7 86 When VDS = 1 (set by parameter VolatileDataShared), VDE bit has no meaning.
<> 144:ef7eb2e8f9f7 87 This parameter can be a value of @ref FIREWALL_VolatileData_Executable */
<> 144:ef7eb2e8f9f7 88
<> 144:ef7eb2e8f9f7 89 uint32_t VolatileDataShared; /*!< Set VDS bit in specifying whether or not the volatile data segment can be shared with a
<> 144:ef7eb2e8f9f7 90 non-protected application code.
<> 144:ef7eb2e8f9f7 91 This parameter can be a value of @ref FIREWALL_VolatileData_Shared */
<> 144:ef7eb2e8f9f7 92
<> 144:ef7eb2e8f9f7 93 }FIREWALL_InitTypeDef;
<> 144:ef7eb2e8f9f7 94
<> 144:ef7eb2e8f9f7 95
<> 144:ef7eb2e8f9f7 96 /**
<> 144:ef7eb2e8f9f7 97 * @}
<> 144:ef7eb2e8f9f7 98 */
<> 144:ef7eb2e8f9f7 99
<> 144:ef7eb2e8f9f7 100
<> 144:ef7eb2e8f9f7 101 /* Exported constants --------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 102 /** @defgroup FIREWALL_Exported_Constants FIREWALL Exported Constants
<> 144:ef7eb2e8f9f7 103 * @{
<> 144:ef7eb2e8f9f7 104 */
<> 144:ef7eb2e8f9f7 105
<> 144:ef7eb2e8f9f7 106 /** @defgroup FIREWALL_VolatileData_Executable FIREWALL volatile data segment execution status
<> 144:ef7eb2e8f9f7 107 * @{
<> 144:ef7eb2e8f9f7 108 */
<> 144:ef7eb2e8f9f7 109 #define FIREWALL_VOLATILEDATA_NOT_EXECUTABLE ((uint32_t)0x0000)
<> 144:ef7eb2e8f9f7 110 #define FIREWALL_VOLATILEDATA_EXECUTABLE ((uint32_t)FW_CR_VDE)
<> 144:ef7eb2e8f9f7 111 /**
<> 144:ef7eb2e8f9f7 112 * @}
<> 144:ef7eb2e8f9f7 113 */
<> 144:ef7eb2e8f9f7 114
<> 144:ef7eb2e8f9f7 115 /** @defgroup FIREWALL_VolatileData_Shared FIREWALL volatile data segment share status
<> 144:ef7eb2e8f9f7 116 * @{
<> 144:ef7eb2e8f9f7 117 */
<> 144:ef7eb2e8f9f7 118 #define FIREWALL_VOLATILEDATA_NOT_SHARED ((uint32_t)0x0000)
<> 144:ef7eb2e8f9f7 119 #define FIREWALL_VOLATILEDATA_SHARED ((uint32_t)FW_CR_VDS)
<> 144:ef7eb2e8f9f7 120 /**
<> 144:ef7eb2e8f9f7 121 * @}
<> 144:ef7eb2e8f9f7 122 */
<> 144:ef7eb2e8f9f7 123
<> 144:ef7eb2e8f9f7 124 /** @defgroup FIREWALL_Pre_Arm FIREWALL pre arm status
<> 144:ef7eb2e8f9f7 125 * @{
<> 144:ef7eb2e8f9f7 126 */
<> 144:ef7eb2e8f9f7 127 #define FIREWALL_PRE_ARM_RESET ((uint32_t)0x0000)
<> 144:ef7eb2e8f9f7 128 #define FIREWALL_PRE_ARM_SET ((uint32_t)FW_CR_FPA)
<> 144:ef7eb2e8f9f7 129
<> 144:ef7eb2e8f9f7 130 /**
<> 144:ef7eb2e8f9f7 131 * @}
<> 144:ef7eb2e8f9f7 132 */
<> 144:ef7eb2e8f9f7 133
<> 144:ef7eb2e8f9f7 134 /**
<> 144:ef7eb2e8f9f7 135 * @}
<> 144:ef7eb2e8f9f7 136 */
<> 144:ef7eb2e8f9f7 137
<> 144:ef7eb2e8f9f7 138 /* Private macros --------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 139 /** @defgroup FIREWALL_Private_Macros FIREWALL Private Macros
<> 144:ef7eb2e8f9f7 140 * @{
<> 144:ef7eb2e8f9f7 141 */
<> 144:ef7eb2e8f9f7 142 #define IS_FIREWALL_CODE_SEGMENT_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && ((ADDRESS) < (FLASH_BASE + FLASH_SIZE)))
<> 144:ef7eb2e8f9f7 143 #define IS_FIREWALL_CODE_SEGMENT_LENGTH(ADDRESS, LENGTH) (((ADDRESS) + (LENGTH)) <= (FLASH_BASE + FLASH_SIZE))
<> 144:ef7eb2e8f9f7 144
<> 144:ef7eb2e8f9f7 145 #define IS_FIREWALL_NONVOLATILEDATA_SEGMENT_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && ((ADDRESS) < (FLASH_BASE + FLASH_SIZE)))
<> 144:ef7eb2e8f9f7 146 #define IS_FIREWALL_NONVOLATILEDATA_SEGMENT_LENGTH(ADDRESS, LENGTH) (((ADDRESS) + (LENGTH)) <= (FLASH_BASE + FLASH_SIZE))
<> 144:ef7eb2e8f9f7 147
<> 144:ef7eb2e8f9f7 148 #define IS_FIREWALL_VOLATILEDATA_SEGMENT_ADDRESS(ADDRESS) (((ADDRESS) >= SRAM1_BASE) && ((ADDRESS) < (SRAM1_BASE + SRAM1_SIZE_MAX)))
<> 144:ef7eb2e8f9f7 149 #define IS_FIREWALL_VOLATILEDATA_SEGMENT_LENGTH(ADDRESS, LENGTH) (((ADDRESS) + (LENGTH)) <= (SRAM1_BASE + SRAM1_SIZE_MAX))
<> 144:ef7eb2e8f9f7 150
<> 144:ef7eb2e8f9f7 151
<> 144:ef7eb2e8f9f7 152 #define IS_FIREWALL_VOLATILEDATA_SHARE(SHARE) (((SHARE) == FIREWALL_VOLATILEDATA_NOT_SHARED) || \
<> 144:ef7eb2e8f9f7 153 ((SHARE) == FIREWALL_VOLATILEDATA_SHARED))
<> 144:ef7eb2e8f9f7 154
<> 144:ef7eb2e8f9f7 155 #define IS_FIREWALL_VOLATILEDATA_EXECUTE(EXECUTE) (((EXECUTE) == FIREWALL_VOLATILEDATA_NOT_EXECUTABLE) || \
<> 144:ef7eb2e8f9f7 156 ((EXECUTE) == FIREWALL_VOLATILEDATA_EXECUTABLE))
<> 144:ef7eb2e8f9f7 157 /**
<> 144:ef7eb2e8f9f7 158 * @}
<> 144:ef7eb2e8f9f7 159 */
<> 144:ef7eb2e8f9f7 160
<> 144:ef7eb2e8f9f7 161
<> 144:ef7eb2e8f9f7 162 /* Exported macros -----------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 163 /** @defgroup FIREWALL_Exported_Macros FIREWALL Exported Macros
<> 144:ef7eb2e8f9f7 164 * @{
<> 144:ef7eb2e8f9f7 165 */
<> 144:ef7eb2e8f9f7 166
<> 144:ef7eb2e8f9f7 167 /** @brief Check whether the FIREWALL is enabled or not.
<> 144:ef7eb2e8f9f7 168 * @retval FIREWALL enabling status (TRUE or FALSE).
<> 144:ef7eb2e8f9f7 169 */
<> 144:ef7eb2e8f9f7 170 #define __HAL_FIREWALL_IS_ENABLED() HAL_IS_BIT_CLR(SYSCFG->CFGR1, SYSCFG_CFGR1_FWDIS)
<> 144:ef7eb2e8f9f7 171
<> 144:ef7eb2e8f9f7 172
<> 144:ef7eb2e8f9f7 173 /** @brief Enable FIREWALL pre arm.
<> 144:ef7eb2e8f9f7 174 * @note When FPA bit is set, any code executed outside the protected segment
<> 144:ef7eb2e8f9f7 175 * closes the Firewall, otherwise it generates a system reset.
<> 144:ef7eb2e8f9f7 176 * @note This macro provides the same service as HAL_FIREWALL_EnablePreArmFlag() API
<> 144:ef7eb2e8f9f7 177 * but can be executed inside a code area protected by the Firewall.
<> 144:ef7eb2e8f9f7 178 * @note This macro can be executed whatever the Firewall state (opened or closed) when
<> 144:ef7eb2e8f9f7 179 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
<> 144:ef7eb2e8f9f7 180 * 0, that is, when the non volatile data segment is defined), the macro can be
<> 144:ef7eb2e8f9f7 181 * executed only when the Firewall is opened.
<> 144:ef7eb2e8f9f7 182 */
<> 144:ef7eb2e8f9f7 183 #define __HAL_FIREWALL_PREARM_ENABLE() \
<> 144:ef7eb2e8f9f7 184 do { \
<> 144:ef7eb2e8f9f7 185 __IO uint32_t tmpreg; \
<> 144:ef7eb2e8f9f7 186 SET_BIT(FIREWALL->CR, FW_CR_FPA) ; \
<> 144:ef7eb2e8f9f7 187 /* Read bit back to ensure it is taken into account by IP */ \
<> 144:ef7eb2e8f9f7 188 /* (introduce proper delay inside macro execution) */ \
<> 144:ef7eb2e8f9f7 189 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_FPA) ; \
<> 144:ef7eb2e8f9f7 190 UNUSED(tmpreg); \
<> 144:ef7eb2e8f9f7 191 } while(0)
<> 144:ef7eb2e8f9f7 192
<> 144:ef7eb2e8f9f7 193
<> 144:ef7eb2e8f9f7 194
<> 144:ef7eb2e8f9f7 195 /** @brief Disable FIREWALL pre arm.
<> 144:ef7eb2e8f9f7 196 * @note When FPA bit is set, any code executed outside the protected segment
<> 144:ef7eb2e8f9f7 197 * closes the Firewall, otherwise, it generates a system reset.
<> 144:ef7eb2e8f9f7 198 * @note This macro provides the same service as HAL_FIREWALL_DisablePreArmFlag() API
<> 144:ef7eb2e8f9f7 199 * but can be executed inside a code area protected by the Firewall.
<> 144:ef7eb2e8f9f7 200 * @note This macro can be executed whatever the Firewall state (opened or closed) when
<> 144:ef7eb2e8f9f7 201 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
<> 144:ef7eb2e8f9f7 202 * 0, that is, when the non volatile data segment is defined), the macro can be
<> 144:ef7eb2e8f9f7 203 * executed only when the Firewall is opened.
<> 144:ef7eb2e8f9f7 204 */
<> 144:ef7eb2e8f9f7 205 #define __HAL_FIREWALL_PREARM_DISABLE() \
<> 144:ef7eb2e8f9f7 206 do { \
<> 144:ef7eb2e8f9f7 207 __IO uint32_t tmpreg; \
<> 144:ef7eb2e8f9f7 208 CLEAR_BIT(FIREWALL->CR, FW_CR_FPA) ; \
<> 144:ef7eb2e8f9f7 209 /* Read bit back to ensure it is taken into account by IP */ \
<> 144:ef7eb2e8f9f7 210 /* (introduce proper delay inside macro execution) */ \
<> 144:ef7eb2e8f9f7 211 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_FPA) ; \
<> 144:ef7eb2e8f9f7 212 UNUSED(tmpreg); \
<> 144:ef7eb2e8f9f7 213 } while(0)
<> 144:ef7eb2e8f9f7 214
<> 144:ef7eb2e8f9f7 215 /** @brief Enable volatile data sharing in setting VDS bit.
<> 144:ef7eb2e8f9f7 216 * @note When VDS bit is set, the volatile data segment is shared with non-protected
<> 144:ef7eb2e8f9f7 217 * application code. It can be accessed whatever the Firewall state (opened or closed).
<> 144:ef7eb2e8f9f7 218 * @note This macro can be executed inside a code area protected by the Firewall.
<> 144:ef7eb2e8f9f7 219 * @note This macro can be executed whatever the Firewall state (opened or closed) when
<> 144:ef7eb2e8f9f7 220 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
<> 144:ef7eb2e8f9f7 221 * 0, that is, when the non volatile data segment is defined), the macro can be
<> 144:ef7eb2e8f9f7 222 * executed only when the Firewall is opened.
<> 144:ef7eb2e8f9f7 223 */
<> 144:ef7eb2e8f9f7 224 #define __HAL_FIREWALL_VOLATILEDATA_SHARED_ENABLE() \
<> 144:ef7eb2e8f9f7 225 do { \
<> 144:ef7eb2e8f9f7 226 __IO uint32_t tmpreg; \
<> 144:ef7eb2e8f9f7 227 SET_BIT(FIREWALL->CR, FW_CR_VDS) ; \
<> 144:ef7eb2e8f9f7 228 /* Read bit back to ensure it is taken into account by IP */ \
<> 144:ef7eb2e8f9f7 229 /* (introduce proper delay inside macro execution) */ \
<> 144:ef7eb2e8f9f7 230 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_VDS) ; \
<> 144:ef7eb2e8f9f7 231 UNUSED(tmpreg); \
<> 144:ef7eb2e8f9f7 232 } while(0)
<> 144:ef7eb2e8f9f7 233
<> 144:ef7eb2e8f9f7 234 /** @brief Disable volatile data sharing in resetting VDS bit.
<> 144:ef7eb2e8f9f7 235 * @note When VDS bit is reset, the volatile data segment is not shared and cannot be
<> 144:ef7eb2e8f9f7 236 * hit by a non protected executable code when the Firewall is closed. If it is
<> 144:ef7eb2e8f9f7 237 * accessed in such a condition, a system reset is generated by the Firewall.
<> 144:ef7eb2e8f9f7 238 * @note This macro can be executed inside a code area protected by the Firewall.
<> 144:ef7eb2e8f9f7 239 * @note This macro can be executed whatever the Firewall state (opened or closed) when
<> 144:ef7eb2e8f9f7 240 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
<> 144:ef7eb2e8f9f7 241 * 0, that is, when the non volatile data segment is defined), the macro can be
<> 144:ef7eb2e8f9f7 242 * executed only when the Firewall is opened.
<> 144:ef7eb2e8f9f7 243 */
<> 144:ef7eb2e8f9f7 244 #define __HAL_FIREWALL_VOLATILEDATA_SHARED_DISABLE() \
<> 144:ef7eb2e8f9f7 245 do { \
<> 144:ef7eb2e8f9f7 246 __IO uint32_t tmpreg; \
<> 144:ef7eb2e8f9f7 247 CLEAR_BIT(FIREWALL->CR, FW_CR_VDS) ; \
<> 144:ef7eb2e8f9f7 248 /* Read bit back to ensure it is taken into account by IP */ \
<> 144:ef7eb2e8f9f7 249 /* (introduce proper delay inside macro execution) */ \
<> 144:ef7eb2e8f9f7 250 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_VDS) ; \
<> 144:ef7eb2e8f9f7 251 UNUSED(tmpreg); \
<> 144:ef7eb2e8f9f7 252 } while(0)
<> 144:ef7eb2e8f9f7 253
<> 144:ef7eb2e8f9f7 254 /** @brief Enable volatile data execution in setting VDE bit.
<> 144:ef7eb2e8f9f7 255 * @note VDE bit is ignored when VDS is set. IF VDS = 1, the Volatile data segment can be
<> 144:ef7eb2e8f9f7 256 * executed whatever the VDE bit value.
<> 144:ef7eb2e8f9f7 257 * @note When VDE bit is set (with VDS = 0), the volatile data segment is executable. When
<> 144:ef7eb2e8f9f7 258 * the Firewall call is closed, a "call gate" entry procedure is required to open
<> 144:ef7eb2e8f9f7 259 * first the Firewall.
<> 144:ef7eb2e8f9f7 260 * @note This macro can be executed inside a code area protected by the Firewall.
<> 144:ef7eb2e8f9f7 261 * @note This macro can be executed whatever the Firewall state (opened or closed) when
<> 144:ef7eb2e8f9f7 262 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
<> 144:ef7eb2e8f9f7 263 * 0, that is, when the non volatile data segment is defined), the macro can be
<> 144:ef7eb2e8f9f7 264 * executed only when the Firewall is opened.
<> 144:ef7eb2e8f9f7 265 */
<> 144:ef7eb2e8f9f7 266 #define __HAL_FIREWALL_VOLATILEDATA_EXECUTION_ENABLE() \
<> 144:ef7eb2e8f9f7 267 do { \
<> 144:ef7eb2e8f9f7 268 __IO uint32_t tmpreg; \
<> 144:ef7eb2e8f9f7 269 SET_BIT(FIREWALL->CR, FW_CR_VDE) ; \
<> 144:ef7eb2e8f9f7 270 /* Read bit back to ensure it is taken into account by IP */ \
<> 144:ef7eb2e8f9f7 271 /* (introduce proper delay inside macro execution) */ \
<> 144:ef7eb2e8f9f7 272 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_VDE) ; \
<> 144:ef7eb2e8f9f7 273 UNUSED(tmpreg); \
<> 144:ef7eb2e8f9f7 274 } while(0)
<> 144:ef7eb2e8f9f7 275
<> 144:ef7eb2e8f9f7 276 /** @brief Disable volatile data execution in resetting VDE bit.
<> 144:ef7eb2e8f9f7 277 * @note VDE bit is ignored when VDS is set. IF VDS = 1, the Volatile data segment can be
<> 144:ef7eb2e8f9f7 278 * executed whatever the VDE bit value.
<> 144:ef7eb2e8f9f7 279 * @note When VDE bit is reset (with VDS = 0), the volatile data segment cannot be executed.
<> 144:ef7eb2e8f9f7 280 * @note This macro can be executed inside a code area protected by the Firewall.
<> 144:ef7eb2e8f9f7 281 * @note This macro can be executed whatever the Firewall state (opened or closed) when
<> 144:ef7eb2e8f9f7 282 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
<> 144:ef7eb2e8f9f7 283 * 0, that is, when the non volatile data segment is defined), the macro can be
<> 144:ef7eb2e8f9f7 284 * executed only when the Firewall is opened.
<> 144:ef7eb2e8f9f7 285 */
<> 144:ef7eb2e8f9f7 286 #define __HAL_FIREWALL_VOLATILEDATA_EXECUTION_DISABLE() \
<> 144:ef7eb2e8f9f7 287 do { \
<> 144:ef7eb2e8f9f7 288 __IO uint32_t tmpreg; \
<> 144:ef7eb2e8f9f7 289 CLEAR_BIT(FIREWALL->CR, FW_CR_VDE) ; \
<> 144:ef7eb2e8f9f7 290 /* Read bit back to ensure it is taken into account by IP */ \
<> 144:ef7eb2e8f9f7 291 /* (introduce proper delay inside macro execution) */ \
<> 144:ef7eb2e8f9f7 292 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_VDE) ; \
<> 144:ef7eb2e8f9f7 293 UNUSED(tmpreg); \
<> 144:ef7eb2e8f9f7 294 } while(0)
<> 144:ef7eb2e8f9f7 295
<> 144:ef7eb2e8f9f7 296
<> 144:ef7eb2e8f9f7 297 /** @brief Check whether or not the volatile data segment is shared.
<> 144:ef7eb2e8f9f7 298 * @note This macro can be executed inside a code area protected by the Firewall.
<> 144:ef7eb2e8f9f7 299 * @note This macro can be executed whatever the Firewall state (opened or closed) when
<> 144:ef7eb2e8f9f7 300 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
<> 144:ef7eb2e8f9f7 301 * 0, that is, when the non volatile data segment is defined), the macro can be
<> 144:ef7eb2e8f9f7 302 * executed only when the Firewall is opened.
<> 144:ef7eb2e8f9f7 303 * @retval VDS bit setting status (TRUE or FALSE).
<> 144:ef7eb2e8f9f7 304 */
<> 144:ef7eb2e8f9f7 305 #define __HAL_FIREWALL_GET_VOLATILEDATA_SHARED() ((FIREWALL->CR & FW_CR_VDS) == FW_CR_VDS)
<> 144:ef7eb2e8f9f7 306
<> 144:ef7eb2e8f9f7 307 /** @brief Check whether or not the volatile data segment is declared executable.
<> 144:ef7eb2e8f9f7 308 * @note This macro can be executed inside a code area protected by the Firewall.
<> 144:ef7eb2e8f9f7 309 * @note This macro can be executed whatever the Firewall state (opened or closed) when
<> 144:ef7eb2e8f9f7 310 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
<> 144:ef7eb2e8f9f7 311 * 0, that is, when the non volatile data segment is defined), the macro can be
<> 144:ef7eb2e8f9f7 312 * executed only when the Firewall is opened.
<> 144:ef7eb2e8f9f7 313 * @retval VDE bit setting status (TRUE or FALSE).
<> 144:ef7eb2e8f9f7 314 */
<> 144:ef7eb2e8f9f7 315 #define __HAL_FIREWALL_GET_VOLATILEDATA_EXECUTION() ((FIREWALL->CR & FW_CR_VDE) == FW_CR_VDE)
<> 144:ef7eb2e8f9f7 316
<> 144:ef7eb2e8f9f7 317 /** @brief Check whether or not the Firewall pre arm bit is set.
<> 144:ef7eb2e8f9f7 318 * @note This macro can be executed inside a code area protected by the Firewall.
<> 144:ef7eb2e8f9f7 319 * @note This macro can be executed whatever the Firewall state (opened or closed) when
<> 144:ef7eb2e8f9f7 320 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
<> 144:ef7eb2e8f9f7 321 * 0, that is, when the non volatile data segment is defined), the macro can be
<> 144:ef7eb2e8f9f7 322 * executed only when the Firewall is opened.
<> 144:ef7eb2e8f9f7 323 * @retval FPA bit setting status (TRUE or FALSE).
<> 144:ef7eb2e8f9f7 324 */
<> 144:ef7eb2e8f9f7 325 #define __HAL_FIREWALL_GET_PREARM() ((FIREWALL->CR & FW_CR_FPA) == FW_CR_FPA)
<> 144:ef7eb2e8f9f7 326
<> 144:ef7eb2e8f9f7 327
<> 144:ef7eb2e8f9f7 328 /**
<> 144:ef7eb2e8f9f7 329 * @}
<> 144:ef7eb2e8f9f7 330 */
<> 144:ef7eb2e8f9f7 331
<> 144:ef7eb2e8f9f7 332 /* Exported functions --------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 333
<> 144:ef7eb2e8f9f7 334 /** @addtogroup FIREWALL_Exported_Functions FIREWALL Exported Functions
<> 144:ef7eb2e8f9f7 335 * @{
<> 144:ef7eb2e8f9f7 336 */
<> 144:ef7eb2e8f9f7 337
<> 144:ef7eb2e8f9f7 338 /** @addtogroup FIREWALL_Exported_Functions_Group1 Initialization Functions
<> 144:ef7eb2e8f9f7 339 * @brief Initialization and Configuration Functions
<> 144:ef7eb2e8f9f7 340 * @{
<> 144:ef7eb2e8f9f7 341 */
<> 144:ef7eb2e8f9f7 342
<> 144:ef7eb2e8f9f7 343 /* Initialization functions ********************************/
<> 144:ef7eb2e8f9f7 344 HAL_StatusTypeDef HAL_FIREWALL_Config(FIREWALL_InitTypeDef * fw_init);
<> 144:ef7eb2e8f9f7 345 void HAL_FIREWALL_GetConfig(FIREWALL_InitTypeDef * fw_config);
<> 144:ef7eb2e8f9f7 346 void HAL_FIREWALL_EnableFirewall(void);
<> 144:ef7eb2e8f9f7 347 void HAL_FIREWALL_EnablePreArmFlag(void);
<> 144:ef7eb2e8f9f7 348 void HAL_FIREWALL_DisablePreArmFlag(void);
<> 144:ef7eb2e8f9f7 349
<> 144:ef7eb2e8f9f7 350 /**
<> 144:ef7eb2e8f9f7 351 * @}
<> 144:ef7eb2e8f9f7 352 */
<> 144:ef7eb2e8f9f7 353
<> 144:ef7eb2e8f9f7 354 /**
<> 144:ef7eb2e8f9f7 355 * @}
<> 144:ef7eb2e8f9f7 356 */
<> 144:ef7eb2e8f9f7 357
<> 144:ef7eb2e8f9f7 358 /**
<> 144:ef7eb2e8f9f7 359 * @}
<> 144:ef7eb2e8f9f7 360 */
<> 144:ef7eb2e8f9f7 361
<> 144:ef7eb2e8f9f7 362 /**
<> 144:ef7eb2e8f9f7 363 * @}
<> 144:ef7eb2e8f9f7 364 */
<> 144:ef7eb2e8f9f7 365
<> 144:ef7eb2e8f9f7 366 #ifdef __cplusplus
<> 144:ef7eb2e8f9f7 367 }
<> 144:ef7eb2e8f9f7 368 #endif
<> 144:ef7eb2e8f9f7 369
<> 144:ef7eb2e8f9f7 370 #endif /* __STM32L4xx_HAL_FIREWALL_H */
<> 144:ef7eb2e8f9f7 371
<> 144:ef7eb2e8f9f7 372 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/