STM32L4xx_HAL_Driver  1.14.0
stm32l4xx_hal_firewall.h
Go to the documentation of this file.
1 
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef __STM32L4xx_HAL_FIREWALL_H
22 #define __STM32L4xx_HAL_FIREWALL_H
23 
24 #ifdef __cplusplus
25  extern "C" {
26 #endif
27 
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32l4xx_hal_def.h"
30 
39 /* Exported types ------------------------------------------------------------*/
47 typedef struct
48 {
49  uint32_t CodeSegmentStartAddress;
52  uint32_t CodeSegmentLength;
55  uint32_t NonVDataSegmentStartAddress;
58  uint32_t NonVDataSegmentLength;
61  uint32_t VDataSegmentStartAddress;
64  uint32_t VDataSegmentLength;
67  uint32_t VolatileDataExecution;
71  uint32_t VolatileDataShared;
75 }FIREWALL_InitTypeDef;
76 
77 
83 /* Exported constants --------------------------------------------------------*/
91 #define FIREWALL_VOLATILEDATA_NOT_EXECUTABLE ((uint32_t)0x0000)
92 #define FIREWALL_VOLATILEDATA_EXECUTABLE ((uint32_t)FW_CR_VDE)
93 
100 #define FIREWALL_VOLATILEDATA_NOT_SHARED ((uint32_t)0x0000)
101 #define FIREWALL_VOLATILEDATA_SHARED ((uint32_t)FW_CR_VDS)
102 
109 #define FIREWALL_PRE_ARM_RESET ((uint32_t)0x0000)
110 #define FIREWALL_PRE_ARM_SET ((uint32_t)FW_CR_FPA)
111 
120 /* Private macros --------------------------------------------------------*/
124 #define IS_FIREWALL_CODE_SEGMENT_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && ((ADDRESS) < (FLASH_BASE + FLASH_SIZE)))
125 #define IS_FIREWALL_CODE_SEGMENT_LENGTH(ADDRESS, LENGTH) (((ADDRESS) + (LENGTH)) <= (FLASH_BASE + FLASH_SIZE))
126 
127 #define IS_FIREWALL_NONVOLATILEDATA_SEGMENT_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && ((ADDRESS) < (FLASH_BASE + FLASH_SIZE)))
128 #define IS_FIREWALL_NONVOLATILEDATA_SEGMENT_LENGTH(ADDRESS, LENGTH) (((ADDRESS) + (LENGTH)) <= (FLASH_BASE + FLASH_SIZE))
129 
130 #define IS_FIREWALL_VOLATILEDATA_SEGMENT_ADDRESS(ADDRESS) (((ADDRESS) >= SRAM1_BASE) && ((ADDRESS) < (SRAM1_BASE + SRAM1_SIZE_MAX)))
131 #define IS_FIREWALL_VOLATILEDATA_SEGMENT_LENGTH(ADDRESS, LENGTH) (((ADDRESS) + (LENGTH)) <= (SRAM1_BASE + SRAM1_SIZE_MAX))
132 
133 
134 #define IS_FIREWALL_VOLATILEDATA_SHARE(SHARE) (((SHARE) == FIREWALL_VOLATILEDATA_NOT_SHARED) || \
135  ((SHARE) == FIREWALL_VOLATILEDATA_SHARED))
136 
137 #define IS_FIREWALL_VOLATILEDATA_EXECUTE(EXECUTE) (((EXECUTE) == FIREWALL_VOLATILEDATA_NOT_EXECUTABLE) || \
138  ((EXECUTE) == FIREWALL_VOLATILEDATA_EXECUTABLE))
139 
144 /* Exported macros -----------------------------------------------------------*/
152 #define __HAL_FIREWALL_IS_ENABLED() HAL_IS_BIT_CLR(SYSCFG->CFGR1, SYSCFG_CFGR1_FWDIS)
153 
154 
165 #define __HAL_FIREWALL_PREARM_ENABLE() \
166  do { \
167  __IO uint32_t tmpreg; \
168  SET_BIT(FIREWALL->CR, FW_CR_FPA) ; \
169  /* Read bit back to ensure it is taken into account by Peripheral */ \
170  /* (introduce proper delay inside macro execution) */ \
171  tmpreg = READ_BIT(FIREWALL->CR, FW_CR_FPA) ; \
172  UNUSED(tmpreg); \
173  } while(0)
174 
175 
176 
187 #define __HAL_FIREWALL_PREARM_DISABLE() \
188  do { \
189  __IO uint32_t tmpreg; \
190  CLEAR_BIT(FIREWALL->CR, FW_CR_FPA) ; \
191  /* Read bit back to ensure it is taken into account by Peripheral */ \
192  /* (introduce proper delay inside macro execution) */ \
193  tmpreg = READ_BIT(FIREWALL->CR, FW_CR_FPA) ; \
194  UNUSED(tmpreg); \
195  } while(0)
196 
206 #define __HAL_FIREWALL_VOLATILEDATA_SHARED_ENABLE() \
207  do { \
208  __IO uint32_t tmpreg; \
209  SET_BIT(FIREWALL->CR, FW_CR_VDS) ; \
210  /* Read bit back to ensure it is taken into account by Peripheral */ \
211  /* (introduce proper delay inside macro execution) */ \
212  tmpreg = READ_BIT(FIREWALL->CR, FW_CR_VDS) ; \
213  UNUSED(tmpreg); \
214  } while(0)
215 
226 #define __HAL_FIREWALL_VOLATILEDATA_SHARED_DISABLE() \
227  do { \
228  __IO uint32_t tmpreg; \
229  CLEAR_BIT(FIREWALL->CR, FW_CR_VDS) ; \
230  /* Read bit back to ensure it is taken into account by Peripheral */ \
231  /* (introduce proper delay inside macro execution) */ \
232  tmpreg = READ_BIT(FIREWALL->CR, FW_CR_VDS) ; \
233  UNUSED(tmpreg); \
234  } while(0)
235 
248 #define __HAL_FIREWALL_VOLATILEDATA_EXECUTION_ENABLE() \
249  do { \
250  __IO uint32_t tmpreg; \
251  SET_BIT(FIREWALL->CR, FW_CR_VDE) ; \
252  /* Read bit back to ensure it is taken into account by Peripheral */ \
253  /* (introduce proper delay inside macro execution) */ \
254  tmpreg = READ_BIT(FIREWALL->CR, FW_CR_VDE) ; \
255  UNUSED(tmpreg); \
256  } while(0)
257 
268 #define __HAL_FIREWALL_VOLATILEDATA_EXECUTION_DISABLE() \
269  do { \
270  __IO uint32_t tmpreg; \
271  CLEAR_BIT(FIREWALL->CR, FW_CR_VDE) ; \
272  /* Read bit back to ensure it is taken into account by Peripheral */ \
273  /* (introduce proper delay inside macro execution) */ \
274  tmpreg = READ_BIT(FIREWALL->CR, FW_CR_VDE) ; \
275  UNUSED(tmpreg); \
276  } while(0)
277 
278 
287 #define __HAL_FIREWALL_GET_VOLATILEDATA_SHARED() ((FIREWALL->CR & FW_CR_VDS) == FW_CR_VDS)
288 
297 #define __HAL_FIREWALL_GET_VOLATILEDATA_EXECUTION() ((FIREWALL->CR & FW_CR_VDE) == FW_CR_VDE)
298 
307 #define __HAL_FIREWALL_GET_PREARM() ((FIREWALL->CR & FW_CR_FPA) == FW_CR_FPA)
308 
309 
314 /* Exported functions --------------------------------------------------------*/
315 
325 /* Initialization functions ********************************/
326 HAL_StatusTypeDef HAL_FIREWALL_Config(FIREWALL_InitTypeDef * fw_init);
327 void HAL_FIREWALL_GetConfig(FIREWALL_InitTypeDef * fw_config);
328 void HAL_FIREWALL_EnableFirewall(void);
331 
348 #ifdef __cplusplus
349 }
350 #endif
351 
352 #endif /* __STM32L4xx_HAL_FIREWALL_H */
353 
354 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
void HAL_FIREWALL_GetConfig(FIREWALL_InitTypeDef *fw_config)
Retrieve the Firewall configuration.
void HAL_FIREWALL_DisablePreArmFlag(void)
Disable FIREWALL pre arm.
This file contains HAL common defines, enumeration, macros and structures definitions.
void HAL_FIREWALL_EnablePreArmFlag(void)
Enable FIREWALL pre arm.
void HAL_FIREWALL_EnableFirewall(void)
Enable FIREWALL.
HAL_StatusTypeDef HAL_FIREWALL_Config(FIREWALL_InitTypeDef *fw_init)
Initialize the Firewall according to the FIREWALL_InitTypeDef structure parameters.