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