2 ******************************************************************************
\r
3 * @file stm32l4xx_hal_cortex.h
\r
4 * @author MCD Application Team
\r
5 * @brief Header file of CORTEX HAL module.
\r
6 ******************************************************************************
\r
9 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
\r
10 * All rights reserved.</center></h2>
\r
12 * This software component is licensed by ST under BSD 3-Clause license,
\r
13 * the "License"; You may not use this file except in compliance with the
\r
14 * License. You may obtain a copy of the License at:
\r
15 * opensource.org/licenses/BSD-3-Clause
\r
17 ******************************************************************************
\r
20 /* Define to prevent recursive inclusion -------------------------------------*/
\r
21 #ifndef __STM32L4xx_HAL_CORTEX_H
\r
22 #define __STM32L4xx_HAL_CORTEX_H
\r
28 /* Includes ------------------------------------------------------------------*/
\r
29 #include "stm32l4xx_hal_def.h"
\r
31 /** @addtogroup STM32L4xx_HAL_Driver
\r
35 /** @defgroup CORTEX CORTEX
\r
39 /* Exported types ------------------------------------------------------------*/
\r
40 /** @defgroup CORTEX_Exported_Types CORTEX Exported Types
\r
44 #if (__MPU_PRESENT == 1)
\r
45 /** @defgroup CORTEX_MPU_Region_Initialization_Structure_definition MPU Region Initialization Structure Definition
\r
50 uint8_t Enable; /*!< Specifies the status of the region.
\r
51 This parameter can be a value of @ref CORTEX_MPU_Region_Enable */
\r
52 uint8_t Number; /*!< Specifies the number of the region to protect.
\r
53 This parameter can be a value of @ref CORTEX_MPU_Region_Number */
\r
54 uint32_t BaseAddress; /*!< Specifies the base address of the region to protect. */
\r
55 uint8_t Size; /*!< Specifies the size of the region to protect.
\r
56 This parameter can be a value of @ref CORTEX_MPU_Region_Size */
\r
57 uint8_t SubRegionDisable; /*!< Specifies the number of the subregion protection to disable.
\r
58 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF */
\r
59 uint8_t TypeExtField; /*!< Specifies the TEX field level.
\r
60 This parameter can be a value of @ref CORTEX_MPU_TEX_Levels */
\r
61 uint8_t AccessPermission; /*!< Specifies the region access permission type.
\r
62 This parameter can be a value of @ref CORTEX_MPU_Region_Permission_Attributes */
\r
63 uint8_t DisableExec; /*!< Specifies the instruction access status.
\r
64 This parameter can be a value of @ref CORTEX_MPU_Instruction_Access */
\r
65 uint8_t IsShareable; /*!< Specifies the shareability status of the protected region.
\r
66 This parameter can be a value of @ref CORTEX_MPU_Access_Shareable */
\r
67 uint8_t IsCacheable; /*!< Specifies the cacheable status of the region protected.
\r
68 This parameter can be a value of @ref CORTEX_MPU_Access_Cacheable */
\r
69 uint8_t IsBufferable; /*!< Specifies the bufferable status of the protected region.
\r
70 This parameter can be a value of @ref CORTEX_MPU_Access_Bufferable */
\r
71 }MPU_Region_InitTypeDef;
\r
75 #endif /* __MPU_PRESENT */
\r
81 /* Exported constants --------------------------------------------------------*/
\r
83 /** @defgroup CORTEX_Exported_Constants CORTEX Exported Constants
\r
87 /** @defgroup CORTEX_Preemption_Priority_Group CORTEX Preemption Priority Group
\r
90 #define NVIC_PRIORITYGROUP_0 ((uint32_t)0x00000007) /*!< 0 bit for pre-emption priority,
\r
91 4 bits for subpriority */
\r
92 #define NVIC_PRIORITYGROUP_1 ((uint32_t)0x00000006) /*!< 1 bit for pre-emption priority,
\r
93 3 bits for subpriority */
\r
94 #define NVIC_PRIORITYGROUP_2 ((uint32_t)0x00000005) /*!< 2 bits for pre-emption priority,
\r
95 2 bits for subpriority */
\r
96 #define NVIC_PRIORITYGROUP_3 ((uint32_t)0x00000004) /*!< 3 bits for pre-emption priority,
\r
97 1 bit for subpriority */
\r
98 #define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003) /*!< 4 bits for pre-emption priority,
\r
99 0 bit for subpriority */
\r
104 /** @defgroup CORTEX_SysTick_clock_source CORTEX SysTick clock source
\r
107 #define SYSTICK_CLKSOURCE_HCLK_DIV8 ((uint32_t)0x00000000)
\r
108 #define SYSTICK_CLKSOURCE_HCLK ((uint32_t)0x00000004)
\r
113 #if (__MPU_PRESENT == 1)
\r
114 /** @defgroup CORTEX_MPU_HFNMI_PRIVDEF_Control CORTEX MPU HFNMI and PRIVILEGED Access control
\r
117 #define MPU_HFNMI_PRIVDEF_NONE ((uint32_t)0x00000000)
\r
118 #define MPU_HARDFAULT_NMI ((uint32_t)0x00000002)
\r
119 #define MPU_PRIVILEGED_DEFAULT ((uint32_t)0x00000004)
\r
120 #define MPU_HFNMI_PRIVDEF ((uint32_t)0x00000006)
\r
125 /** @defgroup CORTEX_MPU_Region_Enable CORTEX MPU Region Enable
\r
128 #define MPU_REGION_ENABLE ((uint8_t)0x01)
\r
129 #define MPU_REGION_DISABLE ((uint8_t)0x00)
\r
134 /** @defgroup CORTEX_MPU_Instruction_Access CORTEX MPU Instruction Access
\r
137 #define MPU_INSTRUCTION_ACCESS_ENABLE ((uint8_t)0x00)
\r
138 #define MPU_INSTRUCTION_ACCESS_DISABLE ((uint8_t)0x01)
\r
143 /** @defgroup CORTEX_MPU_Access_Shareable CORTEX MPU Instruction Access Shareable
\r
146 #define MPU_ACCESS_SHAREABLE ((uint8_t)0x01)
\r
147 #define MPU_ACCESS_NOT_SHAREABLE ((uint8_t)0x00)
\r
152 /** @defgroup CORTEX_MPU_Access_Cacheable CORTEX MPU Instruction Access Cacheable
\r
155 #define MPU_ACCESS_CACHEABLE ((uint8_t)0x01)
\r
156 #define MPU_ACCESS_NOT_CACHEABLE ((uint8_t)0x00)
\r
161 /** @defgroup CORTEX_MPU_Access_Bufferable CORTEX MPU Instruction Access Bufferable
\r
164 #define MPU_ACCESS_BUFFERABLE ((uint8_t)0x01)
\r
165 #define MPU_ACCESS_NOT_BUFFERABLE ((uint8_t)0x00)
\r
170 /** @defgroup CORTEX_MPU_TEX_Levels CORTEX MPU TEX Levels
\r
173 #define MPU_TEX_LEVEL0 ((uint8_t)0x00)
\r
174 #define MPU_TEX_LEVEL1 ((uint8_t)0x01)
\r
175 #define MPU_TEX_LEVEL2 ((uint8_t)0x02)
\r
180 /** @defgroup CORTEX_MPU_Region_Size CORTEX MPU Region Size
\r
183 #define MPU_REGION_SIZE_32B ((uint8_t)0x04)
\r
184 #define MPU_REGION_SIZE_64B ((uint8_t)0x05)
\r
185 #define MPU_REGION_SIZE_128B ((uint8_t)0x06)
\r
186 #define MPU_REGION_SIZE_256B ((uint8_t)0x07)
\r
187 #define MPU_REGION_SIZE_512B ((uint8_t)0x08)
\r
188 #define MPU_REGION_SIZE_1KB ((uint8_t)0x09)
\r
189 #define MPU_REGION_SIZE_2KB ((uint8_t)0x0A)
\r
190 #define MPU_REGION_SIZE_4KB ((uint8_t)0x0B)
\r
191 #define MPU_REGION_SIZE_8KB ((uint8_t)0x0C)
\r
192 #define MPU_REGION_SIZE_16KB ((uint8_t)0x0D)
\r
193 #define MPU_REGION_SIZE_32KB ((uint8_t)0x0E)
\r
194 #define MPU_REGION_SIZE_64KB ((uint8_t)0x0F)
\r
195 #define MPU_REGION_SIZE_128KB ((uint8_t)0x10)
\r
196 #define MPU_REGION_SIZE_256KB ((uint8_t)0x11)
\r
197 #define MPU_REGION_SIZE_512KB ((uint8_t)0x12)
\r
198 #define MPU_REGION_SIZE_1MB ((uint8_t)0x13)
\r
199 #define MPU_REGION_SIZE_2MB ((uint8_t)0x14)
\r
200 #define MPU_REGION_SIZE_4MB ((uint8_t)0x15)
\r
201 #define MPU_REGION_SIZE_8MB ((uint8_t)0x16)
\r
202 #define MPU_REGION_SIZE_16MB ((uint8_t)0x17)
\r
203 #define MPU_REGION_SIZE_32MB ((uint8_t)0x18)
\r
204 #define MPU_REGION_SIZE_64MB ((uint8_t)0x19)
\r
205 #define MPU_REGION_SIZE_128MB ((uint8_t)0x1A)
\r
206 #define MPU_REGION_SIZE_256MB ((uint8_t)0x1B)
\r
207 #define MPU_REGION_SIZE_512MB ((uint8_t)0x1C)
\r
208 #define MPU_REGION_SIZE_1GB ((uint8_t)0x1D)
\r
209 #define MPU_REGION_SIZE_2GB ((uint8_t)0x1E)
\r
210 #define MPU_REGION_SIZE_4GB ((uint8_t)0x1F)
\r
215 /** @defgroup CORTEX_MPU_Region_Permission_Attributes CORTEX MPU Region Permission Attributes
\r
218 #define MPU_REGION_NO_ACCESS ((uint8_t)0x00)
\r
219 #define MPU_REGION_PRIV_RW ((uint8_t)0x01)
\r
220 #define MPU_REGION_PRIV_RW_URO ((uint8_t)0x02)
\r
221 #define MPU_REGION_FULL_ACCESS ((uint8_t)0x03)
\r
222 #define MPU_REGION_PRIV_RO ((uint8_t)0x05)
\r
223 #define MPU_REGION_PRIV_RO_URO ((uint8_t)0x06)
\r
228 /** @defgroup CORTEX_MPU_Region_Number CORTEX MPU Region Number
\r
231 #define MPU_REGION_NUMBER0 ((uint8_t)0x00)
\r
232 #define MPU_REGION_NUMBER1 ((uint8_t)0x01)
\r
233 #define MPU_REGION_NUMBER2 ((uint8_t)0x02)
\r
234 #define MPU_REGION_NUMBER3 ((uint8_t)0x03)
\r
235 #define MPU_REGION_NUMBER4 ((uint8_t)0x04)
\r
236 #define MPU_REGION_NUMBER5 ((uint8_t)0x05)
\r
237 #define MPU_REGION_NUMBER6 ((uint8_t)0x06)
\r
238 #define MPU_REGION_NUMBER7 ((uint8_t)0x07)
\r
242 #endif /* __MPU_PRESENT */
\r
248 /* Exported macros -----------------------------------------------------------*/
\r
249 /** @defgroup CORTEX_Exported_Macros CORTEX Exported Macros
\r
257 /* Exported functions --------------------------------------------------------*/
\r
258 /** @defgroup CORTEX_Exported_Functions CORTEX Exported Functions
\r
262 /** @defgroup CORTEX_Exported_Functions_Group1 Initialization and Configuration functions
\r
263 * @brief Initialization and Configuration functions
\r
266 /* Initialization and Configuration functions *****************************/
\r
267 void HAL_NVIC_SetPriorityGrouping(uint32_t PriorityGroup);
\r
268 void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority);
\r
269 void HAL_NVIC_EnableIRQ(IRQn_Type IRQn);
\r
270 void HAL_NVIC_DisableIRQ(IRQn_Type IRQn);
\r
271 void HAL_NVIC_SystemReset(void);
\r
272 uint32_t HAL_SYSTICK_Config(uint32_t TicksNumb);
\r
278 /** @defgroup CORTEX_Exported_Functions_Group2 Peripheral Control functions
\r
279 * @brief Cortex control functions
\r
282 /* Peripheral Control functions ***********************************************/
\r
283 uint32_t HAL_NVIC_GetPriorityGrouping(void);
\r
284 void HAL_NVIC_GetPriority(IRQn_Type IRQn, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority);
\r
285 uint32_t HAL_NVIC_GetPendingIRQ(IRQn_Type IRQn);
\r
286 void HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn);
\r
287 void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn);
\r
288 uint32_t HAL_NVIC_GetActive(IRQn_Type IRQn);
\r
289 void HAL_SYSTICK_CLKSourceConfig(uint32_t CLKSource);
\r
290 void HAL_SYSTICK_IRQHandler(void);
\r
291 void HAL_SYSTICK_Callback(void);
\r
293 #if (__MPU_PRESENT == 1)
\r
294 void HAL_MPU_Enable(uint32_t MPU_Control);
\r
295 void HAL_MPU_Disable(void);
\r
296 void HAL_MPU_ConfigRegion(MPU_Region_InitTypeDef *MPU_Init);
\r
297 #endif /* __MPU_PRESENT */
\r
306 /* Private types -------------------------------------------------------------*/
\r
307 /* Private variables ---------------------------------------------------------*/
\r
308 /* Private constants ---------------------------------------------------------*/
\r
309 /* Private macros ------------------------------------------------------------*/
\r
310 /** @defgroup CORTEX_Private_Macros CORTEX Private Macros
\r
313 #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PRIORITYGROUP_0) || \
\r
314 ((GROUP) == NVIC_PRIORITYGROUP_1) || \
\r
315 ((GROUP) == NVIC_PRIORITYGROUP_2) || \
\r
316 ((GROUP) == NVIC_PRIORITYGROUP_3) || \
\r
317 ((GROUP) == NVIC_PRIORITYGROUP_4))
\r
319 #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
\r
321 #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
\r
323 #define IS_NVIC_DEVICE_IRQ(IRQ) ((IRQ) >= 0x00)
\r
325 #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SYSTICK_CLKSOURCE_HCLK) || \
\r
326 ((SOURCE) == SYSTICK_CLKSOURCE_HCLK_DIV8))
\r
328 #if (__MPU_PRESENT == 1)
\r
329 #define IS_MPU_REGION_ENABLE(STATE) (((STATE) == MPU_REGION_ENABLE) || \
\r
330 ((STATE) == MPU_REGION_DISABLE))
\r
332 #define IS_MPU_INSTRUCTION_ACCESS(STATE) (((STATE) == MPU_INSTRUCTION_ACCESS_ENABLE) || \
\r
333 ((STATE) == MPU_INSTRUCTION_ACCESS_DISABLE))
\r
335 #define IS_MPU_ACCESS_SHAREABLE(STATE) (((STATE) == MPU_ACCESS_SHAREABLE) || \
\r
336 ((STATE) == MPU_ACCESS_NOT_SHAREABLE))
\r
338 #define IS_MPU_ACCESS_CACHEABLE(STATE) (((STATE) == MPU_ACCESS_CACHEABLE) || \
\r
339 ((STATE) == MPU_ACCESS_NOT_CACHEABLE))
\r
341 #define IS_MPU_ACCESS_BUFFERABLE(STATE) (((STATE) == MPU_ACCESS_BUFFERABLE) || \
\r
342 ((STATE) == MPU_ACCESS_NOT_BUFFERABLE))
\r
344 #define IS_MPU_TEX_LEVEL(TYPE) (((TYPE) == MPU_TEX_LEVEL0) || \
\r
345 ((TYPE) == MPU_TEX_LEVEL1) || \
\r
346 ((TYPE) == MPU_TEX_LEVEL2))
\r
348 #define IS_MPU_REGION_PERMISSION_ATTRIBUTE(TYPE) (((TYPE) == MPU_REGION_NO_ACCESS) || \
\r
349 ((TYPE) == MPU_REGION_PRIV_RW) || \
\r
350 ((TYPE) == MPU_REGION_PRIV_RW_URO) || \
\r
351 ((TYPE) == MPU_REGION_FULL_ACCESS) || \
\r
352 ((TYPE) == MPU_REGION_PRIV_RO) || \
\r
353 ((TYPE) == MPU_REGION_PRIV_RO_URO))
\r
355 #define IS_MPU_REGION_NUMBER(NUMBER) (((NUMBER) == MPU_REGION_NUMBER0) || \
\r
356 ((NUMBER) == MPU_REGION_NUMBER1) || \
\r
357 ((NUMBER) == MPU_REGION_NUMBER2) || \
\r
358 ((NUMBER) == MPU_REGION_NUMBER3) || \
\r
359 ((NUMBER) == MPU_REGION_NUMBER4) || \
\r
360 ((NUMBER) == MPU_REGION_NUMBER5) || \
\r
361 ((NUMBER) == MPU_REGION_NUMBER6) || \
\r
362 ((NUMBER) == MPU_REGION_NUMBER7))
\r
364 #define IS_MPU_REGION_SIZE(SIZE) (((SIZE) == MPU_REGION_SIZE_32B) || \
\r
365 ((SIZE) == MPU_REGION_SIZE_64B) || \
\r
366 ((SIZE) == MPU_REGION_SIZE_128B) || \
\r
367 ((SIZE) == MPU_REGION_SIZE_256B) || \
\r
368 ((SIZE) == MPU_REGION_SIZE_512B) || \
\r
369 ((SIZE) == MPU_REGION_SIZE_1KB) || \
\r
370 ((SIZE) == MPU_REGION_SIZE_2KB) || \
\r
371 ((SIZE) == MPU_REGION_SIZE_4KB) || \
\r
372 ((SIZE) == MPU_REGION_SIZE_8KB) || \
\r
373 ((SIZE) == MPU_REGION_SIZE_16KB) || \
\r
374 ((SIZE) == MPU_REGION_SIZE_32KB) || \
\r
375 ((SIZE) == MPU_REGION_SIZE_64KB) || \
\r
376 ((SIZE) == MPU_REGION_SIZE_128KB) || \
\r
377 ((SIZE) == MPU_REGION_SIZE_256KB) || \
\r
378 ((SIZE) == MPU_REGION_SIZE_512KB) || \
\r
379 ((SIZE) == MPU_REGION_SIZE_1MB) || \
\r
380 ((SIZE) == MPU_REGION_SIZE_2MB) || \
\r
381 ((SIZE) == MPU_REGION_SIZE_4MB) || \
\r
382 ((SIZE) == MPU_REGION_SIZE_8MB) || \
\r
383 ((SIZE) == MPU_REGION_SIZE_16MB) || \
\r
384 ((SIZE) == MPU_REGION_SIZE_32MB) || \
\r
385 ((SIZE) == MPU_REGION_SIZE_64MB) || \
\r
386 ((SIZE) == MPU_REGION_SIZE_128MB) || \
\r
387 ((SIZE) == MPU_REGION_SIZE_256MB) || \
\r
388 ((SIZE) == MPU_REGION_SIZE_512MB) || \
\r
389 ((SIZE) == MPU_REGION_SIZE_1GB) || \
\r
390 ((SIZE) == MPU_REGION_SIZE_2GB) || \
\r
391 ((SIZE) == MPU_REGION_SIZE_4GB))
\r
393 #define IS_MPU_SUB_REGION_DISABLE(SUBREGION) ((SUBREGION) < (uint16_t)0x00FF)
\r
394 #endif /* __MPU_PRESENT */
\r
400 /* Private functions ---------------------------------------------------------*/
\r
414 #endif /* __STM32L4xx_HAL_CORTEX_H */
\r
417 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r