mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_hal_firewall.c@189:f392fc9709a3, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 22:31:08 2019 +0000
- Revision:
- 189:f392fc9709a3
- Parent:
- 186:707f6e361f3e
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 144:ef7eb2e8f9f7 | 1 | /** |
<> | 144:ef7eb2e8f9f7 | 2 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 3 | * @file stm32l0xx_hal_firewall.c |
<> | 144:ef7eb2e8f9f7 | 4 | * @author MCD Application Team |
<> | 144:ef7eb2e8f9f7 | 5 | * @brief FIREWALL HAL module driver. |
<> | 144:ef7eb2e8f9f7 | 6 | * This file provides firmware functions to manage the Firewall |
<> | 144:ef7eb2e8f9f7 | 7 | * Peripheral initialization and enabling. |
<> | 144:ef7eb2e8f9f7 | 8 | * |
<> | 144:ef7eb2e8f9f7 | 9 | * |
<> | 144:ef7eb2e8f9f7 | 10 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 11 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 12 | ##### How to use this driver ##### |
<> | 144:ef7eb2e8f9f7 | 13 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 14 | [..] |
<> | 144:ef7eb2e8f9f7 | 15 | The FIREWALL HAL driver can be used as follows: |
<> | 144:ef7eb2e8f9f7 | 16 | |
<> | 144:ef7eb2e8f9f7 | 17 | (#) Declare a FIREWALL_InitTypeDef initialization structure. |
<> | 144:ef7eb2e8f9f7 | 18 | |
<> | 144:ef7eb2e8f9f7 | 19 | (#) Resort to HAL_FIREWALL_Config() API to initialize the Firewall |
<> | 144:ef7eb2e8f9f7 | 20 | |
<> | 144:ef7eb2e8f9f7 | 21 | (#) Enable the FIREWALL in calling HAL_FIREWALL_EnableFirewall() API |
<> | 144:ef7eb2e8f9f7 | 22 | |
<> | 144:ef7eb2e8f9f7 | 23 | (#) To ensure that any code executed outside the protected segment closes the |
<> | 144:ef7eb2e8f9f7 | 24 | FIREWALL, the user must set the flag FIREWALL_PRE_ARM_SET in calling |
<> | 144:ef7eb2e8f9f7 | 25 | __HAL_FIREWALL_PREARM_ENABLE() macro if called within a protected code segment |
<> | 144:ef7eb2e8f9f7 | 26 | or |
<> | 144:ef7eb2e8f9f7 | 27 | HAL_FIREWALL_EnablePreArmFlag() API if called outside of protected code segment |
<> | 144:ef7eb2e8f9f7 | 28 | after HAL_FIREWALL_Config() call. |
<> | 144:ef7eb2e8f9f7 | 29 | |
<> | 144:ef7eb2e8f9f7 | 30 | |
<> | 144:ef7eb2e8f9f7 | 31 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 32 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 33 | * @attention |
<> | 144:ef7eb2e8f9f7 | 34 | * |
<> | 144:ef7eb2e8f9f7 | 35 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
<> | 144:ef7eb2e8f9f7 | 36 | * |
<> | 144:ef7eb2e8f9f7 | 37 | * Redistribution and use in source and binary forms, with or without modification, |
<> | 144:ef7eb2e8f9f7 | 38 | * are permitted provided that the following conditions are met: |
<> | 144:ef7eb2e8f9f7 | 39 | * 1. Redistributions of source code must retain the above copyright notice, |
<> | 144:ef7eb2e8f9f7 | 40 | * this list of conditions and the following disclaimer. |
<> | 144:ef7eb2e8f9f7 | 41 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
<> | 144:ef7eb2e8f9f7 | 42 | * this list of conditions and the following disclaimer in the documentation |
<> | 144:ef7eb2e8f9f7 | 43 | * and/or other materials provided with the distribution. |
<> | 144:ef7eb2e8f9f7 | 44 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
<> | 144:ef7eb2e8f9f7 | 45 | * may be used to endorse or promote products derived from this software |
<> | 144:ef7eb2e8f9f7 | 46 | * without specific prior written permission. |
<> | 144:ef7eb2e8f9f7 | 47 | * |
<> | 144:ef7eb2e8f9f7 | 48 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
<> | 144:ef7eb2e8f9f7 | 49 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
<> | 144:ef7eb2e8f9f7 | 50 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
<> | 144:ef7eb2e8f9f7 | 51 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
<> | 144:ef7eb2e8f9f7 | 52 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
<> | 144:ef7eb2e8f9f7 | 53 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
<> | 144:ef7eb2e8f9f7 | 54 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
<> | 144:ef7eb2e8f9f7 | 55 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
<> | 144:ef7eb2e8f9f7 | 56 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
<> | 144:ef7eb2e8f9f7 | 57 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
<> | 144:ef7eb2e8f9f7 | 58 | * |
<> | 144:ef7eb2e8f9f7 | 59 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 60 | */ |
<> | 144:ef7eb2e8f9f7 | 61 | #if !defined (STM32L011xx) && !defined (STM32L021xx) && !defined (STM32L031xx) && !defined (STM32L041xx) |
<> | 144:ef7eb2e8f9f7 | 62 | |
<> | 144:ef7eb2e8f9f7 | 63 | /* Includes ------------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 64 | #include "stm32l0xx_hal.h" |
<> | 144:ef7eb2e8f9f7 | 65 | |
<> | 144:ef7eb2e8f9f7 | 66 | /** @addtogroup STM32L0xx_HAL_Driver |
<> | 144:ef7eb2e8f9f7 | 67 | * @{ |
<> | 144:ef7eb2e8f9f7 | 68 | */ |
<> | 144:ef7eb2e8f9f7 | 69 | |
<> | 144:ef7eb2e8f9f7 | 70 | #ifdef HAL_FIREWALL_MODULE_ENABLED |
<> | 144:ef7eb2e8f9f7 | 71 | |
<> | 144:ef7eb2e8f9f7 | 72 | /** @addtogroup FIREWALL |
<> | 144:ef7eb2e8f9f7 | 73 | * @brief HAL FIREWALL module driver |
<> | 144:ef7eb2e8f9f7 | 74 | * @{ |
<> | 144:ef7eb2e8f9f7 | 75 | */ |
<> | 144:ef7eb2e8f9f7 | 76 | |
<> | 144:ef7eb2e8f9f7 | 77 | |
<> | 144:ef7eb2e8f9f7 | 78 | |
<> | 144:ef7eb2e8f9f7 | 79 | /** @addtogroup FIREWALL_Exported_Functions |
<> | 144:ef7eb2e8f9f7 | 80 | * @{ |
<> | 144:ef7eb2e8f9f7 | 81 | */ |
<> | 144:ef7eb2e8f9f7 | 82 | |
<> | 144:ef7eb2e8f9f7 | 83 | /** @addtogroup FIREWALL_Exported_Functions_Group1 |
<> | 144:ef7eb2e8f9f7 | 84 | * @brief Initialization and Configuration Functions |
<> | 144:ef7eb2e8f9f7 | 85 | * |
<> | 144:ef7eb2e8f9f7 | 86 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 87 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 88 | ##### Initialization and Configuration functions ##### |
<> | 144:ef7eb2e8f9f7 | 89 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 90 | [..] |
<> | 144:ef7eb2e8f9f7 | 91 | This subsection provides the functions allowing to initialize the Firewall. |
<> | 144:ef7eb2e8f9f7 | 92 | Initialization is done by HAL_FIREWALL_Config(): |
<> | 144:ef7eb2e8f9f7 | 93 | |
<> | 144:ef7eb2e8f9f7 | 94 | (+) Enable the Firewall clock thru __HAL_RCC_FIREWALL_CLK_ENABLE() macro. |
<> | 144:ef7eb2e8f9f7 | 95 | |
<> | 144:ef7eb2e8f9f7 | 96 | (+) Set the protected code segment address start and length. |
<> | 144:ef7eb2e8f9f7 | 97 | |
<> | 144:ef7eb2e8f9f7 | 98 | (+) Set the protected non-volatile and/or volatile data segments |
<> | 144:ef7eb2e8f9f7 | 99 | address starts and lengths if applicable. |
<> | 144:ef7eb2e8f9f7 | 100 | |
<> | 144:ef7eb2e8f9f7 | 101 | (+) Set the volatile data segment execution and sharing status. |
<> | 144:ef7eb2e8f9f7 | 102 | |
<> | 144:ef7eb2e8f9f7 | 103 | (+) Length must be set to 0 for an unprotected segment. |
<> | 144:ef7eb2e8f9f7 | 104 | |
<> | 144:ef7eb2e8f9f7 | 105 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 106 | * @{ |
<> | 144:ef7eb2e8f9f7 | 107 | */ |
<> | 144:ef7eb2e8f9f7 | 108 | |
<> | 144:ef7eb2e8f9f7 | 109 | /** |
<> | 144:ef7eb2e8f9f7 | 110 | * @brief Initialize the Firewall according to the FIREWALL_InitTypeDef structure parameters. |
<> | 144:ef7eb2e8f9f7 | 111 | * @param fw_init: Firewall initialization structure |
<> | 144:ef7eb2e8f9f7 | 112 | * @note The API returns HAL_ERROR if the Firewall is already enabled. |
<> | 144:ef7eb2e8f9f7 | 113 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 114 | */ |
<> | 144:ef7eb2e8f9f7 | 115 | HAL_StatusTypeDef HAL_FIREWALL_Config(FIREWALL_InitTypeDef * fw_init) |
<> | 144:ef7eb2e8f9f7 | 116 | { |
<> | 144:ef7eb2e8f9f7 | 117 | /* Check the Firewall initialization structure allocation */ |
<> | 144:ef7eb2e8f9f7 | 118 | if(fw_init == NULL) |
<> | 144:ef7eb2e8f9f7 | 119 | { |
<> | 144:ef7eb2e8f9f7 | 120 | return HAL_ERROR; |
<> | 144:ef7eb2e8f9f7 | 121 | } |
<> | 144:ef7eb2e8f9f7 | 122 | |
<> | 144:ef7eb2e8f9f7 | 123 | /* Enable Firewall clock */ |
<> | 144:ef7eb2e8f9f7 | 124 | __HAL_RCC_FIREWALL_CLK_ENABLE(); |
<> | 144:ef7eb2e8f9f7 | 125 | |
<> | 144:ef7eb2e8f9f7 | 126 | /* Make sure that Firewall is not enabled already */ |
<> | 144:ef7eb2e8f9f7 | 127 | if (__HAL_FIREWALL_IS_ENABLED() != RESET) |
<> | 144:ef7eb2e8f9f7 | 128 | { |
<> | 144:ef7eb2e8f9f7 | 129 | return HAL_ERROR; |
<> | 144:ef7eb2e8f9f7 | 130 | } |
<> | 144:ef7eb2e8f9f7 | 131 | |
<> | 144:ef7eb2e8f9f7 | 132 | /* Check Firewall configuration addresses and lengths when segment is protected */ |
<> | 144:ef7eb2e8f9f7 | 133 | /* Code segment */ |
<> | 151:5eaa88a5bcc7 | 134 | if (fw_init->CodeSegmentLength != 0U) |
<> | 144:ef7eb2e8f9f7 | 135 | { |
<> | 144:ef7eb2e8f9f7 | 136 | assert_param(IS_FIREWALL_CODE_SEGMENT_ADDRESS(fw_init->CodeSegmentStartAddress)); |
<> | 144:ef7eb2e8f9f7 | 137 | assert_param(IS_FIREWALL_CODE_SEGMENT_LENGTH(fw_init->CodeSegmentStartAddress, fw_init->CodeSegmentLength)); |
<> | 144:ef7eb2e8f9f7 | 138 | } |
<> | 144:ef7eb2e8f9f7 | 139 | /* Non volatile data segment */ |
<> | 151:5eaa88a5bcc7 | 140 | if (fw_init->NonVDataSegmentLength != 0U) |
<> | 144:ef7eb2e8f9f7 | 141 | { |
<> | 144:ef7eb2e8f9f7 | 142 | assert_param(IS_FIREWALL_NONVOLATILEDATA_SEGMENT_ADDRESS(fw_init->NonVDataSegmentStartAddress)); |
<> | 144:ef7eb2e8f9f7 | 143 | assert_param(IS_FIREWALL_NONVOLATILEDATA_SEGMENT_LENGTH(fw_init->NonVDataSegmentStartAddress, fw_init->NonVDataSegmentLength)); |
<> | 144:ef7eb2e8f9f7 | 144 | } |
<> | 144:ef7eb2e8f9f7 | 145 | /* Volatile data segment */ |
<> | 151:5eaa88a5bcc7 | 146 | if (fw_init->VDataSegmentLength != 0U) |
<> | 144:ef7eb2e8f9f7 | 147 | { |
<> | 144:ef7eb2e8f9f7 | 148 | assert_param(IS_FIREWALL_VOLATILEDATA_SEGMENT_ADDRESS(fw_init->VDataSegmentStartAddress)); |
<> | 144:ef7eb2e8f9f7 | 149 | assert_param(IS_FIREWALL_VOLATILEDATA_SEGMENT_LENGTH(fw_init->VDataSegmentStartAddress, fw_init->VDataSegmentLength)); |
<> | 144:ef7eb2e8f9f7 | 150 | } |
<> | 144:ef7eb2e8f9f7 | 151 | |
<> | 144:ef7eb2e8f9f7 | 152 | /* Check Firewall Configuration Register parameters */ |
<> | 144:ef7eb2e8f9f7 | 153 | assert_param(IS_FIREWALL_VOLATILEDATA_EXECUTE(fw_init->VolatileDataExecution)); |
<> | 144:ef7eb2e8f9f7 | 154 | assert_param(IS_FIREWALL_VOLATILEDATA_SHARE(fw_init->VolatileDataShared)); |
<> | 144:ef7eb2e8f9f7 | 155 | |
<> | 144:ef7eb2e8f9f7 | 156 | |
<> | 144:ef7eb2e8f9f7 | 157 | /* Configuration */ |
<> | 144:ef7eb2e8f9f7 | 158 | |
<> | 144:ef7eb2e8f9f7 | 159 | /* Protected code segment start address configuration */ |
<> | 144:ef7eb2e8f9f7 | 160 | WRITE_REG(FIREWALL->CSSA, (FW_CSSA_ADD & fw_init->CodeSegmentStartAddress)); |
<> | 144:ef7eb2e8f9f7 | 161 | /* Protected code segment length configuration */ |
<> | 144:ef7eb2e8f9f7 | 162 | WRITE_REG(FIREWALL->CSL, (FW_CSL_LENG & fw_init->CodeSegmentLength)); |
<> | 144:ef7eb2e8f9f7 | 163 | |
<> | 144:ef7eb2e8f9f7 | 164 | /* Protected non volatile data segment start address configuration */ |
<> | 144:ef7eb2e8f9f7 | 165 | WRITE_REG(FIREWALL->NVDSSA, (FW_NVDSSA_ADD & fw_init->NonVDataSegmentStartAddress)); |
<> | 144:ef7eb2e8f9f7 | 166 | /* Protected non volatile data segment length configuration */ |
<> | 144:ef7eb2e8f9f7 | 167 | WRITE_REG(FIREWALL->NVDSL, (FW_NVDSL_LENG & fw_init->NonVDataSegmentLength)); |
<> | 144:ef7eb2e8f9f7 | 168 | |
<> | 144:ef7eb2e8f9f7 | 169 | /* Protected volatile data segment start address configuration */ |
<> | 144:ef7eb2e8f9f7 | 170 | WRITE_REG(FIREWALL->VDSSA, (FW_VDSSA_ADD & fw_init->VDataSegmentStartAddress)); |
<> | 144:ef7eb2e8f9f7 | 171 | /* Protected volatile data segment length configuration */ |
<> | 144:ef7eb2e8f9f7 | 172 | WRITE_REG(FIREWALL->VDSL, (FW_VDSL_LENG & fw_init->VDataSegmentLength)); |
<> | 144:ef7eb2e8f9f7 | 173 | |
<> | 144:ef7eb2e8f9f7 | 174 | /* Set Firewall Configuration Register VDE and VDS bits |
<> | 144:ef7eb2e8f9f7 | 175 | (volatile data execution and shared configuration) */ |
<> | 144:ef7eb2e8f9f7 | 176 | MODIFY_REG(FIREWALL->CR, FW_CR_VDS|FW_CR_VDE, fw_init->VolatileDataExecution|fw_init->VolatileDataShared); |
<> | 144:ef7eb2e8f9f7 | 177 | |
<> | 144:ef7eb2e8f9f7 | 178 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 179 | } |
<> | 144:ef7eb2e8f9f7 | 180 | |
<> | 144:ef7eb2e8f9f7 | 181 | /** |
<> | 144:ef7eb2e8f9f7 | 182 | * @brief Retrieve the Firewall configuration. |
<> | 144:ef7eb2e8f9f7 | 183 | * @param fw_config: Firewall configuration, type is same as initialization structure |
<> | 144:ef7eb2e8f9f7 | 184 | * @note This API can't be executed inside a code area protected by the Firewall |
<> | 144:ef7eb2e8f9f7 | 185 | * when the Firewall is enabled |
<> | 144:ef7eb2e8f9f7 | 186 | * @note If NVDSL register is different from 0, that is, if the non volatile data segment |
<> | 144:ef7eb2e8f9f7 | 187 | * is defined, this API can't be executed when the Firewall is enabled. |
<> | 144:ef7eb2e8f9f7 | 188 | * @note User should resort to __HAL_FIREWALL_GET_PREARM() macro to retrieve FPA bit status |
<> | 144:ef7eb2e8f9f7 | 189 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 190 | */ |
<> | 144:ef7eb2e8f9f7 | 191 | void HAL_FIREWALL_GetConfig(FIREWALL_InitTypeDef * fw_config) |
<> | 144:ef7eb2e8f9f7 | 192 | { |
<> | 144:ef7eb2e8f9f7 | 193 | |
<> | 144:ef7eb2e8f9f7 | 194 | /* Enable Firewall clock, in case no Firewall configuration has been carried |
<> | 144:ef7eb2e8f9f7 | 195 | out up to this point */ |
<> | 144:ef7eb2e8f9f7 | 196 | __HAL_RCC_FIREWALL_CLK_ENABLE(); |
<> | 144:ef7eb2e8f9f7 | 197 | |
<> | 144:ef7eb2e8f9f7 | 198 | /* Retrieve code segment protection setting */ |
<> | 144:ef7eb2e8f9f7 | 199 | fw_config->CodeSegmentStartAddress = (READ_REG(FIREWALL->CSSA) & FW_CSSA_ADD); |
<> | 144:ef7eb2e8f9f7 | 200 | fw_config->CodeSegmentLength = (READ_REG(FIREWALL->CSL) & FW_CSL_LENG); |
<> | 144:ef7eb2e8f9f7 | 201 | |
<> | 144:ef7eb2e8f9f7 | 202 | /* Retrieve non volatile data segment protection setting */ |
<> | 144:ef7eb2e8f9f7 | 203 | fw_config->NonVDataSegmentStartAddress = (READ_REG(FIREWALL->NVDSSA) & FW_NVDSSA_ADD); |
<> | 144:ef7eb2e8f9f7 | 204 | fw_config->NonVDataSegmentLength = (READ_REG(FIREWALL->NVDSL) & FW_NVDSL_LENG); |
<> | 144:ef7eb2e8f9f7 | 205 | |
<> | 144:ef7eb2e8f9f7 | 206 | /* Retrieve volatile data segment protection setting */ |
<> | 144:ef7eb2e8f9f7 | 207 | fw_config->VDataSegmentStartAddress = (READ_REG(FIREWALL->VDSSA) & FW_VDSSA_ADD); |
<> | 144:ef7eb2e8f9f7 | 208 | fw_config->VDataSegmentLength = (READ_REG(FIREWALL->VDSL) & FW_VDSL_LENG); |
<> | 144:ef7eb2e8f9f7 | 209 | |
<> | 144:ef7eb2e8f9f7 | 210 | /* Retrieve volatile data execution setting */ |
<> | 144:ef7eb2e8f9f7 | 211 | fw_config->VolatileDataExecution = (READ_REG(FIREWALL->CR) & FW_CR_VDE); |
<> | 144:ef7eb2e8f9f7 | 212 | |
<> | 144:ef7eb2e8f9f7 | 213 | /* Retrieve volatile data shared setting */ |
<> | 144:ef7eb2e8f9f7 | 214 | fw_config->VolatileDataShared = (READ_REG(FIREWALL->CR) & FW_CR_VDS); |
<> | 144:ef7eb2e8f9f7 | 215 | |
<> | 144:ef7eb2e8f9f7 | 216 | return; |
<> | 144:ef7eb2e8f9f7 | 217 | } |
<> | 144:ef7eb2e8f9f7 | 218 | |
<> | 144:ef7eb2e8f9f7 | 219 | |
<> | 144:ef7eb2e8f9f7 | 220 | |
<> | 144:ef7eb2e8f9f7 | 221 | /** |
<> | 144:ef7eb2e8f9f7 | 222 | * @brief Enable FIREWALL. |
<> | 144:ef7eb2e8f9f7 | 223 | * @note Firewall is enabled in clearing FWDIS bit of SYSCFG CFGR1 register. |
<> | 144:ef7eb2e8f9f7 | 224 | * Once enabled, the Firewall cannot be disabled by software. Only a |
<> | 144:ef7eb2e8f9f7 | 225 | * system reset can set again FWDIS bit. |
<> | 144:ef7eb2e8f9f7 | 226 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 227 | */ |
<> | 144:ef7eb2e8f9f7 | 228 | void HAL_FIREWALL_EnableFirewall(void) |
<> | 144:ef7eb2e8f9f7 | 229 | { |
<> | 144:ef7eb2e8f9f7 | 230 | /* Clears FWDIS bit of SYSCFG CFGR1 register */ |
<> | 144:ef7eb2e8f9f7 | 231 | CLEAR_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_FWDISEN); |
<> | 144:ef7eb2e8f9f7 | 232 | |
<> | 144:ef7eb2e8f9f7 | 233 | } |
<> | 144:ef7eb2e8f9f7 | 234 | |
<> | 144:ef7eb2e8f9f7 | 235 | /** |
<> | 144:ef7eb2e8f9f7 | 236 | * @brief Enable FIREWALL pre arm. |
<> | 144:ef7eb2e8f9f7 | 237 | * @note When FPA bit is set, any code executed outside the protected segment |
<> | 144:ef7eb2e8f9f7 | 238 | * will close the Firewall. |
<> | 144:ef7eb2e8f9f7 | 239 | * @note This API provides the same service as __HAL_FIREWALL_PREARM_ENABLE() macro |
<> | 144:ef7eb2e8f9f7 | 240 | * but can't be executed inside a code area protected by the Firewall. |
<> | 144:ef7eb2e8f9f7 | 241 | * @note When the Firewall is disabled, user can resort to HAL_FIREWALL_EnablePreArmFlag() API any time. |
<> | 144:ef7eb2e8f9f7 | 242 | * @note When the Firewall is enabled and NVDSL register is equal to 0 (that is, |
<> | 144:ef7eb2e8f9f7 | 243 | * when the non volatile data segment is not defined), |
<> | 144:ef7eb2e8f9f7 | 244 | * ** this API can be executed when the Firewall is closed |
<> | 144:ef7eb2e8f9f7 | 245 | * ** when the Firewall is opened, user should resort to |
<> | 144:ef7eb2e8f9f7 | 246 | * __HAL_FIREWALL_PREARM_ENABLE() macro instead |
<> | 144:ef7eb2e8f9f7 | 247 | * @note When the Firewall is enabled and NVDSL register is different from 0 |
<> | 144:ef7eb2e8f9f7 | 248 | * (that is, when the non volatile data segment is defined) |
<> | 144:ef7eb2e8f9f7 | 249 | * ** FW_CR register can be accessed only when the Firewall is opened: |
<> | 144:ef7eb2e8f9f7 | 250 | * user should resort to __HAL_FIREWALL_PREARM_ENABLE() macro instead. |
<> | 144:ef7eb2e8f9f7 | 251 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 252 | */ |
<> | 144:ef7eb2e8f9f7 | 253 | void HAL_FIREWALL_EnablePreArmFlag(void) |
<> | 144:ef7eb2e8f9f7 | 254 | { |
<> | 144:ef7eb2e8f9f7 | 255 | /* Set FPA bit */ |
<> | 144:ef7eb2e8f9f7 | 256 | SET_BIT(FIREWALL->CR, FW_CR_FPA); |
<> | 144:ef7eb2e8f9f7 | 257 | } |
<> | 144:ef7eb2e8f9f7 | 258 | |
<> | 144:ef7eb2e8f9f7 | 259 | |
<> | 144:ef7eb2e8f9f7 | 260 | /** |
<> | 144:ef7eb2e8f9f7 | 261 | * @brief Disable FIREWALL pre arm. |
<> | 144:ef7eb2e8f9f7 | 262 | * @note When FPA bit is reset, any code executed outside the protected segment |
<> | 144:ef7eb2e8f9f7 | 263 | * when the Firewall is opened will generate a system reset. |
<> | 144:ef7eb2e8f9f7 | 264 | * @note This API provides the same service as __HAL_FIREWALL_PREARM_DISABLE() macro |
<> | 144:ef7eb2e8f9f7 | 265 | * but can't be executed inside a code area protected by the Firewall. |
<> | 144:ef7eb2e8f9f7 | 266 | * @note When the Firewall is disabled, user can resort to HAL_FIREWALL_EnablePreArmFlag() API any time. |
<> | 144:ef7eb2e8f9f7 | 267 | * @note When the Firewall is enabled and NVDSL register is equal to 0 (that is, |
<> | 144:ef7eb2e8f9f7 | 268 | * when the non volatile data segment is not defined), |
<> | 144:ef7eb2e8f9f7 | 269 | * ** this API can be executed when the Firewall is closed |
<> | 144:ef7eb2e8f9f7 | 270 | * ** when the Firewall is opened, user should resort to |
<> | 144:ef7eb2e8f9f7 | 271 | * __HAL_FIREWALL_PREARM_DISABLE() macro instead |
<> | 144:ef7eb2e8f9f7 | 272 | * @note When the Firewall is enabled and NVDSL register is different from 0 |
<> | 144:ef7eb2e8f9f7 | 273 | * (that is, when the non volatile data segment is defined) |
<> | 144:ef7eb2e8f9f7 | 274 | * ** FW_CR register can be accessed only when the Firewall is opened: |
<> | 144:ef7eb2e8f9f7 | 275 | * user should resort to __HAL_FIREWALL_PREARM_DISABLE() macro instead. |
<> | 144:ef7eb2e8f9f7 | 276 | |
<> | 144:ef7eb2e8f9f7 | 277 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 278 | */ |
<> | 144:ef7eb2e8f9f7 | 279 | void HAL_FIREWALL_DisablePreArmFlag(void) |
<> | 144:ef7eb2e8f9f7 | 280 | { |
<> | 144:ef7eb2e8f9f7 | 281 | /* Clear FPA bit */ |
<> | 144:ef7eb2e8f9f7 | 282 | CLEAR_BIT(FIREWALL->CR, FW_CR_FPA); |
<> | 144:ef7eb2e8f9f7 | 283 | } |
<> | 144:ef7eb2e8f9f7 | 284 | |
<> | 144:ef7eb2e8f9f7 | 285 | /** |
<> | 144:ef7eb2e8f9f7 | 286 | * @} |
<> | 144:ef7eb2e8f9f7 | 287 | */ |
<> | 144:ef7eb2e8f9f7 | 288 | |
<> | 144:ef7eb2e8f9f7 | 289 | /** |
<> | 144:ef7eb2e8f9f7 | 290 | * @} |
<> | 144:ef7eb2e8f9f7 | 291 | */ |
<> | 144:ef7eb2e8f9f7 | 292 | |
<> | 144:ef7eb2e8f9f7 | 293 | /** |
<> | 144:ef7eb2e8f9f7 | 294 | * @} |
<> | 144:ef7eb2e8f9f7 | 295 | */ |
<> | 144:ef7eb2e8f9f7 | 296 | |
<> | 144:ef7eb2e8f9f7 | 297 | #endif /* HAL_FIREWALL_MODULE_ENABLED */ |
<> | 144:ef7eb2e8f9f7 | 298 | |
<> | 144:ef7eb2e8f9f7 | 299 | /** |
<> | 144:ef7eb2e8f9f7 | 300 | * @} |
<> | 144:ef7eb2e8f9f7 | 301 | */ |
<> | 144:ef7eb2e8f9f7 | 302 | |
<> | 144:ef7eb2e8f9f7 | 303 | #endif /* #if !defined (STM32L011xx) && !defined (STM32L021xx) && !defined (STM32L031xx) && !defined (STM32L041xx) */ |
<> | 144:ef7eb2e8f9f7 | 304 | |
<> | 144:ef7eb2e8f9f7 | 305 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |