fix LPC812 PWM

Dependents:   IR_LED_Send

Fork of mbed-dev by mbed official

Committer:
nameless129
Date:
Mon May 16 16:50:30 2016 +0000
Revision:
129:2e517c56bcfb
Parent:
113:b3775bf36a83
PWM Fix:Duty 0%??H???????????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 0:9b334a45a8ff 1 /**
bogdanm 0:9b334a45a8ff 2 ******************************************************************************
bogdanm 0:9b334a45a8ff 3 * @file stm32l0xx_hal_firewall.h
bogdanm 0:9b334a45a8ff 4 * @author MCD Application Team
mbed_official 113:b3775bf36a83 5 * @version V1.5.0
mbed_official 113:b3775bf36a83 6 * @date 8-January-2016
bogdanm 0:9b334a45a8ff 7 * @brief Header file of FIREWALL HAL module.
bogdanm 0:9b334a45a8ff 8 ******************************************************************************
bogdanm 0:9b334a45a8ff 9 * @attention
bogdanm 0:9b334a45a8ff 10 *
mbed_official 113:b3775bf36a83 11 * <h2><center>&copy; COPYRIGHT(c) 2016 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 __STM32L0xx_HAL_FIREWALL_H
bogdanm 0:9b334a45a8ff 40 #define __STM32L0xx_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
mbed_official 113:b3775bf36a83 46 #if !defined (STM32L011xx) && !defined (STM32L021xx) && !defined (STM32L031xx) && !defined (STM32L041xx)
mbed_official 113:b3775bf36a83 47
bogdanm 0:9b334a45a8ff 48 /* Includes ------------------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 49 #include "stm32l0xx_hal_def.h"
bogdanm 0:9b334a45a8ff 50
bogdanm 0:9b334a45a8ff 51 /** @addtogroup STM32L0xx_HAL_Driver
bogdanm 0:9b334a45a8ff 52 * @{
bogdanm 0:9b334a45a8ff 53 */
bogdanm 0:9b334a45a8ff 54
mbed_official 113:b3775bf36a83 55 /** @defgroup FIREWALL FIREWALL
bogdanm 0:9b334a45a8ff 56 * @{
bogdanm 0:9b334a45a8ff 57 */
bogdanm 0:9b334a45a8ff 58
bogdanm 0:9b334a45a8ff 59 /* Exported types ------------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 60 /** @defgroup FIREWALL_Exported_Types FIREWALL Exported Types
bogdanm 0:9b334a45a8ff 61 * @{
bogdanm 0:9b334a45a8ff 62 */
bogdanm 0:9b334a45a8ff 63
bogdanm 0:9b334a45a8ff 64 /**
bogdanm 0:9b334a45a8ff 65 * @brief FIREWALL Initialization Structure definition
bogdanm 0:9b334a45a8ff 66 */
bogdanm 0:9b334a45a8ff 67 typedef struct
bogdanm 0:9b334a45a8ff 68 {
bogdanm 0:9b334a45a8ff 69 uint32_t CodeSegmentStartAddress; /*!< Protected code segment start address. This value is 24-bit long, the 8 LSB bits are
bogdanm 0:9b334a45a8ff 70 reserved and forced to 0 in order to allow a 256-byte granularity. */
bogdanm 0:9b334a45a8ff 71
bogdanm 0:9b334a45a8ff 72 uint32_t CodeSegmentLength; /*!< Protected code segment length in bytes. This value is 22-bit long, the 8 LSB bits are
bogdanm 0:9b334a45a8ff 73 reserved and forced to 0 for the length to be a multiple of 256 bytes. */
bogdanm 0:9b334a45a8ff 74
bogdanm 0:9b334a45a8ff 75 uint32_t NonVDataSegmentStartAddress; /*!< Protected non-volatile data segment start address. This value is 24-bit long, the 8 LSB
bogdanm 0:9b334a45a8ff 76 bits are reserved and forced to 0 in order to allow a 256-byte granularity. */
bogdanm 0:9b334a45a8ff 77
bogdanm 0:9b334a45a8ff 78 uint32_t NonVDataSegmentLength; /*!< Protected non-volatile data segment length in bytes. This value is 22-bit long, the 8 LSB
bogdanm 0:9b334a45a8ff 79 bits are reserved and forced to 0 for the length to be a multiple of 256 bytes. */
bogdanm 0:9b334a45a8ff 80
bogdanm 0:9b334a45a8ff 81 uint32_t VDataSegmentStartAddress; /*!< Protected volatile data segment start address. This value is 17-bit long, the 6 LSB bits
bogdanm 0:9b334a45a8ff 82 are reserved and forced to 0 in order to allow a 64-byte granularity. */
bogdanm 0:9b334a45a8ff 83
bogdanm 0:9b334a45a8ff 84 uint32_t VDataSegmentLength; /*!< Protected volatile data segment length in bytes. This value is 17-bit long, the 6 LSB
bogdanm 0:9b334a45a8ff 85 bits are reserved and forced to 0 for the length to be a multiple of 64 bytes. */
bogdanm 0:9b334a45a8ff 86
bogdanm 0:9b334a45a8ff 87 uint32_t VolatileDataExecution; /*!< Set VDE bit specifying whether or not the volatile data segment can be executed.
bogdanm 0:9b334a45a8ff 88 When VDS = 1 (set by parameter VolatileDataShared), VDE bit has no meaning.
bogdanm 0:9b334a45a8ff 89 This parameter can be a value of @ref FIREWALL_VolatileData_Executable */
bogdanm 0:9b334a45a8ff 90
bogdanm 0:9b334a45a8ff 91 uint32_t VolatileDataShared; /*!< Set VDS bit in specifying whether or not the volatile data segment can be shared with a
bogdanm 0:9b334a45a8ff 92 non-protected application code.
bogdanm 0:9b334a45a8ff 93 This parameter can be a value of @ref FIREWALL_VolatileData_Shared */
bogdanm 0:9b334a45a8ff 94
bogdanm 0:9b334a45a8ff 95 }FIREWALL_InitTypeDef;
bogdanm 0:9b334a45a8ff 96
bogdanm 0:9b334a45a8ff 97
bogdanm 0:9b334a45a8ff 98 /**
bogdanm 0:9b334a45a8ff 99 * @}
bogdanm 0:9b334a45a8ff 100 */
bogdanm 0:9b334a45a8ff 101
bogdanm 0:9b334a45a8ff 102
bogdanm 0:9b334a45a8ff 103 /* Exported constants --------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 104 /** @defgroup FIREWALL_Exported_Constants FIREWALL Exported Constants
bogdanm 0:9b334a45a8ff 105 * @{
bogdanm 0:9b334a45a8ff 106 */
bogdanm 0:9b334a45a8ff 107
bogdanm 0:9b334a45a8ff 108 /** @defgroup FIREWALL_VolatileData_Executable FIREWALL volatile data segment execution status
bogdanm 0:9b334a45a8ff 109 * @{
bogdanm 0:9b334a45a8ff 110 */
bogdanm 0:9b334a45a8ff 111 #define FIREWALL_VOLATILEDATA_NOT_EXECUTABLE ((uint32_t)0x0000)
bogdanm 0:9b334a45a8ff 112 #define FIREWALL_VOLATILEDATA_EXECUTABLE ((uint32_t)FW_CR_VDE)
bogdanm 0:9b334a45a8ff 113 /**
bogdanm 0:9b334a45a8ff 114 * @}
bogdanm 0:9b334a45a8ff 115 */
bogdanm 0:9b334a45a8ff 116
bogdanm 0:9b334a45a8ff 117 /** @defgroup FIREWALL_VolatileData_Shared FIREWALL volatile data segment share status
bogdanm 0:9b334a45a8ff 118 * @{
bogdanm 0:9b334a45a8ff 119 */
bogdanm 0:9b334a45a8ff 120 #define FIREWALL_VOLATILEDATA_NOT_SHARED ((uint32_t)0x0000)
bogdanm 0:9b334a45a8ff 121 #define FIREWALL_VOLATILEDATA_SHARED ((uint32_t)FW_CR_VDS)
bogdanm 0:9b334a45a8ff 122 /**
bogdanm 0:9b334a45a8ff 123 * @}
bogdanm 0:9b334a45a8ff 124 */
bogdanm 0:9b334a45a8ff 125
bogdanm 0:9b334a45a8ff 126 /** @defgroup FIREWALL_Pre_Arm FIREWALL pre arm status
bogdanm 0:9b334a45a8ff 127 * @{
bogdanm 0:9b334a45a8ff 128 */
bogdanm 0:9b334a45a8ff 129 #define FIREWALL_PRE_ARM_RESET ((uint32_t)0x0000)
bogdanm 0:9b334a45a8ff 130 #define FIREWALL_PRE_ARM_SET ((uint32_t)FW_CR_FPA)
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 */
bogdanm 0:9b334a45a8ff 139
bogdanm 0:9b334a45a8ff 140 /* Private macros --------------------------------------------------------*/
mbed_official 113:b3775bf36a83 141 /** @addtogroup FIREWALL_Private
bogdanm 0:9b334a45a8ff 142 * @{
bogdanm 0:9b334a45a8ff 143 */
mbed_official 113:b3775bf36a83 144 #define IS_FIREWALL_CODE_SEGMENT_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && ((ADDRESS) < (FLASH_BASE + FLASH_SIZE)))
mbed_official 113:b3775bf36a83 145 #define IS_FIREWALL_CODE_SEGMENT_LENGTH(ADDRESS, LENGTH) (((ADDRESS) + (LENGTH)) <= (FLASH_BASE + FLASH_SIZE))
bogdanm 0:9b334a45a8ff 146
mbed_official 113:b3775bf36a83 147 #define IS_FIREWALL_NONVOLATILEDATA_SEGMENT_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && ((ADDRESS) < (FLASH_BASE + FLASH_SIZE)))
mbed_official 113:b3775bf36a83 148 #define IS_FIREWALL_NONVOLATILEDATA_SEGMENT_LENGTH(ADDRESS, LENGTH) (((ADDRESS) + (LENGTH)) <= (FLASH_BASE + FLASH_SIZE))
bogdanm 0:9b334a45a8ff 149
mbed_official 113:b3775bf36a83 150 #define IS_FIREWALL_VOLATILEDATA_SEGMENT_ADDRESS(ADDRESS) (((ADDRESS) >= SRAM_BASE) && ((ADDRESS) < (SRAM_BASE + SRAM1_SIZE_MAX)))
mbed_official 113:b3775bf36a83 151 #define IS_FIREWALL_VOLATILEDATA_SEGMENT_LENGTH(ADDRESS, LENGTH) (((ADDRESS) + (LENGTH)) <= (SRAM_BASE + SRAM_SIZE_MAX))
bogdanm 0:9b334a45a8ff 152
bogdanm 0:9b334a45a8ff 153
bogdanm 0:9b334a45a8ff 154 #define IS_FIREWALL_VOLATILEDATA_SHARE(SHARE) (((SHARE) == FIREWALL_VOLATILEDATA_NOT_SHARED) || \
bogdanm 0:9b334a45a8ff 155 ((SHARE) == FIREWALL_VOLATILEDATA_SHARED))
bogdanm 0:9b334a45a8ff 156
bogdanm 0:9b334a45a8ff 157 #define IS_FIREWALL_VOLATILEDATA_EXECUTE(EXECUTE) (((EXECUTE) == FIREWALL_VOLATILEDATA_NOT_EXECUTABLE) || \
bogdanm 0:9b334a45a8ff 158 ((EXECUTE) == FIREWALL_VOLATILEDATA_EXECUTABLE))
bogdanm 0:9b334a45a8ff 159 /**
bogdanm 0:9b334a45a8ff 160 * @}
bogdanm 0:9b334a45a8ff 161 */
bogdanm 0:9b334a45a8ff 162
bogdanm 0:9b334a45a8ff 163
bogdanm 0:9b334a45a8ff 164 /* Exported macros -----------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 165 /** @defgroup FIREWALL_Exported_Macros FIREWALL Exported Macros
bogdanm 0:9b334a45a8ff 166 * @{
bogdanm 0:9b334a45a8ff 167 */
bogdanm 0:9b334a45a8ff 168
mbed_official 113:b3775bf36a83 169 /** @brief Check whether the FIREWALL is enabled or not.
bogdanm 0:9b334a45a8ff 170 * @retval FIREWALL enabling status (TRUE or FALSE).
bogdanm 0:9b334a45a8ff 171 */
bogdanm 0:9b334a45a8ff 172 #define __HAL_FIREWALL_IS_ENABLED() HAL_IS_BIT_CLR(SYSCFG->CFGR2, SYSCFG_CFGR2_FWDISEN)
bogdanm 0:9b334a45a8ff 173
bogdanm 0:9b334a45a8ff 174
bogdanm 0:9b334a45a8ff 175 /** @brief Enable FIREWALL pre arm.
bogdanm 0:9b334a45a8ff 176 * @note When FPA bit is set, any code executed outside the protected segment
bogdanm 0:9b334a45a8ff 177 * closes the Firewall, otherwise it generates a system reset.
bogdanm 0:9b334a45a8ff 178 * @note This macro provides the same service as HAL_FIREWALL_EnablePreArmFlag() API
bogdanm 0:9b334a45a8ff 179 * but can be executed inside a code area protected by the Firewall.
bogdanm 0:9b334a45a8ff 180 * @note This macro can be executed whatever the Firewall state (opened or closed) when
bogdanm 0:9b334a45a8ff 181 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
bogdanm 0:9b334a45a8ff 182 * 0, that is, when the non volatile data segment is defined), the macro can be
bogdanm 0:9b334a45a8ff 183 * executed only when the Firewall is opened.
bogdanm 0:9b334a45a8ff 184 */
bogdanm 0:9b334a45a8ff 185 #define __HAL_FIREWALL_PREARM_ENABLE() \
bogdanm 0:9b334a45a8ff 186 do { \
bogdanm 0:9b334a45a8ff 187 __IO uint32_t tmpreg; \
mbed_official 113:b3775bf36a83 188 SET_BIT(FIREWALL->CR, FW_CR_FPA) ; \
bogdanm 0:9b334a45a8ff 189 /* Read bit back to ensure it is taken into account by IP */ \
bogdanm 0:9b334a45a8ff 190 /* (introduce proper delay inside macro execution) */ \
mbed_official 113:b3775bf36a83 191 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_FPA) ; \
bogdanm 0:9b334a45a8ff 192 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 193 } while(0)
bogdanm 0:9b334a45a8ff 194
bogdanm 0:9b334a45a8ff 195
bogdanm 0:9b334a45a8ff 196
bogdanm 0:9b334a45a8ff 197 /** @brief Disable FIREWALL pre arm.
bogdanm 0:9b334a45a8ff 198 * @note When FPA bit is set, any code executed outside the protected segment
bogdanm 0:9b334a45a8ff 199 * closes the Firewall, otherwise, it generates a system reset.
bogdanm 0:9b334a45a8ff 200 * @note This macro provides the same service as HAL_FIREWALL_DisablePreArmFlag() API
bogdanm 0:9b334a45a8ff 201 * but can be executed inside a code area protected by the Firewall.
bogdanm 0:9b334a45a8ff 202 * @note This macro can be executed whatever the Firewall state (opened or closed) when
bogdanm 0:9b334a45a8ff 203 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
bogdanm 0:9b334a45a8ff 204 * 0, that is, when the non volatile data segment is defined), the macro can be
bogdanm 0:9b334a45a8ff 205 * executed only when the Firewall is opened.
bogdanm 0:9b334a45a8ff 206 */
bogdanm 0:9b334a45a8ff 207 #define __HAL_FIREWALL_PREARM_DISABLE() \
bogdanm 0:9b334a45a8ff 208 do { \
bogdanm 0:9b334a45a8ff 209 __IO uint32_t tmpreg; \
mbed_official 113:b3775bf36a83 210 CLEAR_BIT(FIREWALL->CR, FW_CR_FPA) ; \
bogdanm 0:9b334a45a8ff 211 /* Read bit back to ensure it is taken into account by IP */ \
bogdanm 0:9b334a45a8ff 212 /* (introduce proper delay inside macro execution) */ \
mbed_official 113:b3775bf36a83 213 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_FPA) ; \
bogdanm 0:9b334a45a8ff 214 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 215 } while(0)
bogdanm 0:9b334a45a8ff 216
bogdanm 0:9b334a45a8ff 217 /** @brief Enable volatile data sharing in setting VDS bit.
bogdanm 0:9b334a45a8ff 218 * @note When VDS bit is set, the volatile data segment is shared with non-protected
bogdanm 0:9b334a45a8ff 219 * application code. It can be accessed whatever the Firewall state (opened or closed).
bogdanm 0:9b334a45a8ff 220 * @note This macro can be executed inside a code area protected by the Firewall.
bogdanm 0:9b334a45a8ff 221 * @note This macro can be executed whatever the Firewall state (opened or closed) when
bogdanm 0:9b334a45a8ff 222 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
bogdanm 0:9b334a45a8ff 223 * 0, that is, when the non volatile data segment is defined), the macro can be
bogdanm 0:9b334a45a8ff 224 * executed only when the Firewall is opened.
bogdanm 0:9b334a45a8ff 225 */
bogdanm 0:9b334a45a8ff 226 #define __HAL_FIREWALL_VOLATILEDATA_SHARED_ENABLE() \
bogdanm 0:9b334a45a8ff 227 do { \
bogdanm 0:9b334a45a8ff 228 __IO uint32_t tmpreg; \
mbed_official 113:b3775bf36a83 229 SET_BIT(FIREWALL->CR, FW_CR_VDS) ; \
bogdanm 0:9b334a45a8ff 230 /* Read bit back to ensure it is taken into account by IP */ \
bogdanm 0:9b334a45a8ff 231 /* (introduce proper delay inside macro execution) */ \
mbed_official 113:b3775bf36a83 232 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_VDS) ; \
bogdanm 0:9b334a45a8ff 233 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 234 } while(0)
bogdanm 0:9b334a45a8ff 235
bogdanm 0:9b334a45a8ff 236 /** @brief Disable volatile data sharing in resetting VDS bit.
bogdanm 0:9b334a45a8ff 237 * @note When VDS bit is reset, the volatile data segment is not shared and cannot be
bogdanm 0:9b334a45a8ff 238 * hit by a non protected executable code when the Firewall is closed. If it is
bogdanm 0:9b334a45a8ff 239 * accessed in such a condition, a system reset is generated by the Firewall.
bogdanm 0:9b334a45a8ff 240 * @note This macro can be executed inside a code area protected by the Firewall.
bogdanm 0:9b334a45a8ff 241 * @note This macro can be executed whatever the Firewall state (opened or closed) when
bogdanm 0:9b334a45a8ff 242 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
bogdanm 0:9b334a45a8ff 243 * 0, that is, when the non volatile data segment is defined), the macro can be
bogdanm 0:9b334a45a8ff 244 * executed only when the Firewall is opened.
bogdanm 0:9b334a45a8ff 245 */
bogdanm 0:9b334a45a8ff 246 #define __HAL_FIREWALL_VOLATILEDATA_SHARED_DISABLE() \
bogdanm 0:9b334a45a8ff 247 do { \
bogdanm 0:9b334a45a8ff 248 __IO uint32_t tmpreg; \
mbed_official 113:b3775bf36a83 249 CLEAR_BIT(FIREWALL->CR, FW_CR_VDS) ; \
bogdanm 0:9b334a45a8ff 250 /* Read bit back to ensure it is taken into account by IP */ \
bogdanm 0:9b334a45a8ff 251 /* (introduce proper delay inside macro execution) */ \
mbed_official 113:b3775bf36a83 252 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_VDS) ; \
bogdanm 0:9b334a45a8ff 253 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 254 } while(0)
bogdanm 0:9b334a45a8ff 255
bogdanm 0:9b334a45a8ff 256 /** @brief Enable volatile data execution in setting VDE bit.
bogdanm 0:9b334a45a8ff 257 * @note VDE bit is ignored when VDS is set. IF VDS = 1, the Volatile data segment can be
bogdanm 0:9b334a45a8ff 258 * executed whatever the VDE bit value.
bogdanm 0:9b334a45a8ff 259 * @note When VDE bit is set (with VDS = 0), the volatile data segment is executable. When
bogdanm 0:9b334a45a8ff 260 * the Firewall call is closed, a "call gate" entry procedure is required to open
bogdanm 0:9b334a45a8ff 261 * first the Firewall.
bogdanm 0:9b334a45a8ff 262 * @note This macro can be executed inside a code area protected by the Firewall.
bogdanm 0:9b334a45a8ff 263 * @note This macro can be executed whatever the Firewall state (opened or closed) when
bogdanm 0:9b334a45a8ff 264 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
bogdanm 0:9b334a45a8ff 265 * 0, that is, when the non volatile data segment is defined), the macro can be
bogdanm 0:9b334a45a8ff 266 * executed only when the Firewall is opened.
bogdanm 0:9b334a45a8ff 267 */
bogdanm 0:9b334a45a8ff 268 #define __HAL_FIREWALL_VOLATILEDATA_EXECUTION_ENABLE() \
bogdanm 0:9b334a45a8ff 269 do { \
bogdanm 0:9b334a45a8ff 270 __IO uint32_t tmpreg; \
mbed_official 113:b3775bf36a83 271 SET_BIT(FIREWALL->CR, FW_CR_VDE) ; \
bogdanm 0:9b334a45a8ff 272 /* Read bit back to ensure it is taken into account by IP */ \
bogdanm 0:9b334a45a8ff 273 /* (introduce proper delay inside macro execution) */ \
mbed_official 113:b3775bf36a83 274 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_VDE) ; \
bogdanm 0:9b334a45a8ff 275 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 276 } while(0)
bogdanm 0:9b334a45a8ff 277
bogdanm 0:9b334a45a8ff 278 /** @brief Disable volatile data execution in resetting VDE bit.
bogdanm 0:9b334a45a8ff 279 * @note VDE bit is ignored when VDS is set. IF VDS = 1, the Volatile data segment can be
bogdanm 0:9b334a45a8ff 280 * executed whatever the VDE bit value.
bogdanm 0:9b334a45a8ff 281 * @note When VDE bit is reset (with VDS = 0), the volatile data segment cannot be executed.
bogdanm 0:9b334a45a8ff 282 * @note This macro can be executed inside a code area protected by the Firewall.
bogdanm 0:9b334a45a8ff 283 * @note This macro can be executed whatever the Firewall state (opened or closed) when
bogdanm 0:9b334a45a8ff 284 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
bogdanm 0:9b334a45a8ff 285 * 0, that is, when the non volatile data segment is defined), the macro can be
bogdanm 0:9b334a45a8ff 286 * executed only when the Firewall is opened.
bogdanm 0:9b334a45a8ff 287 */
bogdanm 0:9b334a45a8ff 288 #define __HAL_FIREWALL_VOLATILEDATA_EXECUTION_DISABLE() \
bogdanm 0:9b334a45a8ff 289 do { \
bogdanm 0:9b334a45a8ff 290 __IO uint32_t tmpreg; \
mbed_official 113:b3775bf36a83 291 CLEAR_BIT(FIREWALL->CR, FW_CR_VDE) ; \
bogdanm 0:9b334a45a8ff 292 /* Read bit back to ensure it is taken into account by IP */ \
bogdanm 0:9b334a45a8ff 293 /* (introduce proper delay inside macro execution) */ \
mbed_official 113:b3775bf36a83 294 tmpreg = READ_BIT(FIREWALL->CR, FW_CR_VDE) ; \
bogdanm 0:9b334a45a8ff 295 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 296 } while(0)
bogdanm 0:9b334a45a8ff 297
bogdanm 0:9b334a45a8ff 298
bogdanm 0:9b334a45a8ff 299 /** @brief Check whether or not the volatile data segment is shared.
bogdanm 0:9b334a45a8ff 300 * @note This macro can be executed inside a code area protected by the Firewall.
bogdanm 0:9b334a45a8ff 301 * @note This macro can be executed whatever the Firewall state (opened or closed) when
bogdanm 0:9b334a45a8ff 302 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
bogdanm 0:9b334a45a8ff 303 * 0, that is, when the non volatile data segment is defined), the macro can be
bogdanm 0:9b334a45a8ff 304 * executed only when the Firewall is opened.
bogdanm 0:9b334a45a8ff 305 * @retval VDS bit setting status (TRUE or FALSE).
bogdanm 0:9b334a45a8ff 306 */
mbed_official 113:b3775bf36a83 307 #define __HAL_FIREWALL_GET_VOLATILEDATA_SHARED() ((FIREWALL->CR & FW_CR_VDS) == FW_CR_VDS)
bogdanm 0:9b334a45a8ff 308
bogdanm 0:9b334a45a8ff 309 /** @brief Check whether or not the volatile data segment is declared executable.
bogdanm 0:9b334a45a8ff 310 * @note This macro can be executed inside a code area protected by the Firewall.
bogdanm 0:9b334a45a8ff 311 * @note This macro can be executed whatever the Firewall state (opened or closed) when
bogdanm 0:9b334a45a8ff 312 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
bogdanm 0:9b334a45a8ff 313 * 0, that is, when the non volatile data segment is defined), the macro can be
bogdanm 0:9b334a45a8ff 314 * executed only when the Firewall is opened.
bogdanm 0:9b334a45a8ff 315 * @retval VDE bit setting status (TRUE or FALSE).
bogdanm 0:9b334a45a8ff 316 */
mbed_official 113:b3775bf36a83 317 #define __HAL_FIREWALL_GET_VOLATILEDATA_EXECUTION() ((FIREWALL->CR & FW_CR_VDE) == FW_CR_VDE)
bogdanm 0:9b334a45a8ff 318
bogdanm 0:9b334a45a8ff 319 /** @brief Check whether or not the Firewall pre arm bit is set.
bogdanm 0:9b334a45a8ff 320 * @note This macro can be executed inside a code area protected by the Firewall.
bogdanm 0:9b334a45a8ff 321 * @note This macro can be executed whatever the Firewall state (opened or closed) when
bogdanm 0:9b334a45a8ff 322 * NVDSL register is equal to 0. Otherwise (when NVDSL register is different from
bogdanm 0:9b334a45a8ff 323 * 0, that is, when the non volatile data segment is defined), the macro can be
bogdanm 0:9b334a45a8ff 324 * executed only when the Firewall is opened.
bogdanm 0:9b334a45a8ff 325 * @retval FPA bit setting status (TRUE or FALSE).
bogdanm 0:9b334a45a8ff 326 */
mbed_official 113:b3775bf36a83 327 #define __HAL_FIREWALL_GET_PREARM() ((FIREWALL->CR & FW_CR_FPA) == FW_CR_FPA)
bogdanm 0:9b334a45a8ff 328
bogdanm 0:9b334a45a8ff 329
bogdanm 0:9b334a45a8ff 330 /**
bogdanm 0:9b334a45a8ff 331 * @}
bogdanm 0:9b334a45a8ff 332 */
bogdanm 0:9b334a45a8ff 333
bogdanm 0:9b334a45a8ff 334 /* Exported functions --------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 335
mbed_official 113:b3775bf36a83 336 /** @defgroup FIREWALL_Exported_Functions FIREWALL Exported Functions
bogdanm 0:9b334a45a8ff 337 * @{
bogdanm 0:9b334a45a8ff 338 */
bogdanm 0:9b334a45a8ff 339
mbed_official 113:b3775bf36a83 340 /** @defgroup FIREWALL_Exported_Functions_Group1 Initialization Functions
bogdanm 0:9b334a45a8ff 341 * @brief Initialization and Configuration Functions
bogdanm 0:9b334a45a8ff 342 * @{
bogdanm 0:9b334a45a8ff 343 */
bogdanm 0:9b334a45a8ff 344
bogdanm 0:9b334a45a8ff 345 /* Initialization functions ********************************/
bogdanm 0:9b334a45a8ff 346 HAL_StatusTypeDef HAL_FIREWALL_Config(FIREWALL_InitTypeDef * fw_init);
bogdanm 0:9b334a45a8ff 347 void HAL_FIREWALL_GetConfig(FIREWALL_InitTypeDef * fw_config);
bogdanm 0:9b334a45a8ff 348 void HAL_FIREWALL_EnableFirewall(void);
bogdanm 0:9b334a45a8ff 349 void HAL_FIREWALL_EnablePreArmFlag(void);
bogdanm 0:9b334a45a8ff 350 void HAL_FIREWALL_DisablePreArmFlag(void);
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 */
mbed_official 113:b3775bf36a83 359 /* Define the private group ***********************************/
mbed_official 113:b3775bf36a83 360 /**************************************************************/
mbed_official 113:b3775bf36a83 361 /** @defgroup FIREWALL_Private FIREWALL Private
mbed_official 113:b3775bf36a83 362 * @{
mbed_official 113:b3775bf36a83 363 */
mbed_official 113:b3775bf36a83 364 /**
mbed_official 113:b3775bf36a83 365 * @}
mbed_official 113:b3775bf36a83 366 */
mbed_official 113:b3775bf36a83 367 /**************************************************************/
bogdanm 0:9b334a45a8ff 368
bogdanm 0:9b334a45a8ff 369 /**
bogdanm 0:9b334a45a8ff 370 * @}
bogdanm 0:9b334a45a8ff 371 */
bogdanm 0:9b334a45a8ff 372
bogdanm 0:9b334a45a8ff 373 /**
bogdanm 0:9b334a45a8ff 374 * @}
bogdanm 0:9b334a45a8ff 375 */
bogdanm 0:9b334a45a8ff 376
mbed_official 113:b3775bf36a83 377
mbed_official 113:b3775bf36a83 378 #endif /* #if !defined (STM32L011xx) && !defined (STM32L021xx) && !defined (STM32L031xx) && !defined (STM32L041xx) */
mbed_official 113:b3775bf36a83 379
bogdanm 0:9b334a45a8ff 380 #ifdef __cplusplus
bogdanm 0:9b334a45a8ff 381 }
bogdanm 0:9b334a45a8ff 382 #endif
bogdanm 0:9b334a45a8ff 383
bogdanm 0:9b334a45a8ff 384 #endif /* __STM32L0xx_HAL_FIREWALL_H */
bogdanm 0:9b334a45a8ff 385
bogdanm 0:9b334a45a8ff 386 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/