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