2 ******************************************************************************
\r
3 * @file stm32l1xx_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 __STM32L1xx_HAL_CORTEX_H
\r
22 #define __STM32L1xx_HAL_CORTEX_H
\r
28 /* Includes ------------------------------------------------------------------*/
\r
29 #include "stm32l1xx_hal_def.h"
\r
31 /** @addtogroup STM32L1xx_HAL_Driver
\r
35 /** @addtogroup 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
46 * @brief MPU Region initialization structure
\r
51 uint8_t Enable; /*!< Specifies the status of the region.
\r
52 This parameter can be a value of @ref CORTEX_MPU_Region_Enable */
\r
53 uint8_t Number; /*!< Specifies the number of the region to protect.
\r
54 This parameter can be a value of @ref CORTEX_MPU_Region_Number */
\r
55 uint32_t BaseAddress; /*!< Specifies the base address of the region to protect. */
\r
56 uint8_t Size; /*!< Specifies the size of the region to protect.
\r
57 This parameter can be a value of @ref CORTEX_MPU_Region_Size */
\r
58 uint8_t SubRegionDisable; /*!< Specifies the number of the subregion protection to disable.
\r
59 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF */
\r
60 uint8_t TypeExtField; /*!< Specifies the TEX field level.
\r
61 This parameter can be a value of @ref CORTEX_MPU_TEX_Levels */
\r
62 uint8_t AccessPermission; /*!< Specifies the region access permission type.
\r
63 This parameter can be a value of @ref CORTEX_MPU_Region_Permission_Attributes */
\r
64 uint8_t DisableExec; /*!< Specifies the instruction access status.
\r
65 This parameter can be a value of @ref CORTEX_MPU_Instruction_Access */
\r
66 uint8_t IsShareable; /*!< Specifies the shareability status of the protected region.
\r
67 This parameter can be a value of @ref CORTEX_MPU_Access_Shareable */
\r
68 uint8_t IsCacheable; /*!< Specifies the cacheable status of the region protected.
\r
69 This parameter can be a value of @ref CORTEX_MPU_Access_Cacheable */
\r
70 uint8_t IsBufferable; /*!< Specifies the bufferable status of the protected region.
\r
71 This parameter can be a value of @ref CORTEX_MPU_Access_Bufferable */
\r
72 }MPU_Region_InitTypeDef;
\r
76 #endif /* __MPU_PRESENT */
\r
82 /* Exported constants --------------------------------------------------------*/
\r
84 /** @defgroup CORTEX_Exported_Constants CORTEX Exported Constants
\r
89 /** @defgroup CORTEX_Preemption_Priority_Group CORTEX Preemption Priority Group
\r
93 #define NVIC_PRIORITYGROUP_0 (0x00000007U) /*!< 0 bits for pre-emption priority
\r
94 4 bits for subpriority */
\r
95 #define NVIC_PRIORITYGROUP_1 (0x00000006U) /*!< 1 bits for pre-emption priority
\r
96 3 bits for subpriority */
\r
97 #define NVIC_PRIORITYGROUP_2 (0x00000005U) /*!< 2 bits for pre-emption priority
\r
98 2 bits for subpriority */
\r
99 #define NVIC_PRIORITYGROUP_3 (0x00000004U) /*!< 3 bits for pre-emption priority
\r
100 1 bits for subpriority */
\r
101 #define NVIC_PRIORITYGROUP_4 (0x00000003U) /*!< 4 bits for pre-emption priority
\r
102 0 bits for subpriority */
\r
107 /** @defgroup CORTEX_SysTick_clock_source CORTEX SysTick clock source
\r
110 #define SYSTICK_CLKSOURCE_HCLK_DIV8 (0x00000000U)
\r
111 #define SYSTICK_CLKSOURCE_HCLK (0x00000004U)
\r
117 #if (__MPU_PRESENT == 1)
\r
118 /** @defgroup CORTEX_MPU_HFNMI_PRIVDEF_Control MPU HFNMI and PRIVILEGED Access control
\r
121 #define MPU_HFNMI_PRIVDEF_NONE (0x00000000U)
\r
122 #define MPU_HARDFAULT_NMI (MPU_CTRL_HFNMIENA_Msk)
\r
123 #define MPU_PRIVILEGED_DEFAULT (MPU_CTRL_PRIVDEFENA_Msk)
\r
124 #define MPU_HFNMI_PRIVDEF (MPU_CTRL_HFNMIENA_Msk | MPU_CTRL_PRIVDEFENA_Msk)
\r
130 /** @defgroup CORTEX_MPU_Region_Enable CORTEX MPU Region Enable
\r
133 #define MPU_REGION_ENABLE ((uint8_t)0x01)
\r
134 #define MPU_REGION_DISABLE ((uint8_t)0x00)
\r
139 /** @defgroup CORTEX_MPU_Instruction_Access CORTEX MPU Instruction Access
\r
142 #define MPU_INSTRUCTION_ACCESS_ENABLE ((uint8_t)0x00)
\r
143 #define MPU_INSTRUCTION_ACCESS_DISABLE ((uint8_t)0x01)
\r
148 /** @defgroup CORTEX_MPU_Access_Shareable CORTEX MPU Instruction Access Shareable
\r
151 #define MPU_ACCESS_SHAREABLE ((uint8_t)0x01)
\r
152 #define MPU_ACCESS_NOT_SHAREABLE ((uint8_t)0x00)
\r
157 /** @defgroup CORTEX_MPU_Access_Cacheable CORTEX MPU Instruction Access Cacheable
\r
160 #define MPU_ACCESS_CACHEABLE ((uint8_t)0x01)
\r
161 #define MPU_ACCESS_NOT_CACHEABLE ((uint8_t)0x00)
\r
166 /** @defgroup CORTEX_MPU_Access_Bufferable CORTEX MPU Instruction Access Bufferable
\r
169 #define MPU_ACCESS_BUFFERABLE ((uint8_t)0x01)
\r
170 #define MPU_ACCESS_NOT_BUFFERABLE ((uint8_t)0x00)
\r
175 /** @defgroup CORTEX_MPU_TEX_Levels MPU TEX Levels
\r
178 #define MPU_TEX_LEVEL0 ((uint8_t)0x00)
\r
179 #define MPU_TEX_LEVEL1 ((uint8_t)0x01)
\r
180 #define MPU_TEX_LEVEL2 ((uint8_t)0x02)
\r
185 /** @defgroup CORTEX_MPU_Region_Size CORTEX MPU Region Size
\r
188 #define MPU_REGION_SIZE_32B ((uint8_t)0x04)
\r
189 #define MPU_REGION_SIZE_64B ((uint8_t)0x05)
\r
190 #define MPU_REGION_SIZE_128B ((uint8_t)0x06)
\r
191 #define MPU_REGION_SIZE_256B ((uint8_t)0x07)
\r
192 #define MPU_REGION_SIZE_512B ((uint8_t)0x08)
\r
193 #define MPU_REGION_SIZE_1KB ((uint8_t)0x09)
\r
194 #define MPU_REGION_SIZE_2KB ((uint8_t)0x0A)
\r
195 #define MPU_REGION_SIZE_4KB ((uint8_t)0x0B)
\r
196 #define MPU_REGION_SIZE_8KB ((uint8_t)0x0C)
\r
197 #define MPU_REGION_SIZE_16KB ((uint8_t)0x0D)
\r
198 #define MPU_REGION_SIZE_32KB ((uint8_t)0x0E)
\r
199 #define MPU_REGION_SIZE_64KB ((uint8_t)0x0F)
\r
200 #define MPU_REGION_SIZE_128KB ((uint8_t)0x10)
\r
201 #define MPU_REGION_SIZE_256KB ((uint8_t)0x11)
\r
202 #define MPU_REGION_SIZE_512KB ((uint8_t)0x12)
\r
203 #define MPU_REGION_SIZE_1MB ((uint8_t)0x13)
\r
204 #define MPU_REGION_SIZE_2MB ((uint8_t)0x14)
\r
205 #define MPU_REGION_SIZE_4MB ((uint8_t)0x15)
\r
206 #define MPU_REGION_SIZE_8MB ((uint8_t)0x16)
\r
207 #define MPU_REGION_SIZE_16MB ((uint8_t)0x17)
\r
208 #define MPU_REGION_SIZE_32MB ((uint8_t)0x18)
\r
209 #define MPU_REGION_SIZE_64MB ((uint8_t)0x19)
\r
210 #define MPU_REGION_SIZE_128MB ((uint8_t)0x1A)
\r
211 #define MPU_REGION_SIZE_256MB ((uint8_t)0x1B)
\r
212 #define MPU_REGION_SIZE_512MB ((uint8_t)0x1C)
\r
213 #define MPU_REGION_SIZE_1GB ((uint8_t)0x1D)
\r
214 #define MPU_REGION_SIZE_2GB ((uint8_t)0x1E)
\r
215 #define MPU_REGION_SIZE_4GB ((uint8_t)0x1F)
\r
220 /** @defgroup CORTEX_MPU_Region_Permission_Attributes CORTEX MPU Region Permission Attributes
\r
223 #define MPU_REGION_NO_ACCESS ((uint8_t)0x00)
\r
224 #define MPU_REGION_PRIV_RW ((uint8_t)0x01)
\r
225 #define MPU_REGION_PRIV_RW_URO ((uint8_t)0x02)
\r
226 #define MPU_REGION_FULL_ACCESS ((uint8_t)0x03)
\r
227 #define MPU_REGION_PRIV_RO ((uint8_t)0x05)
\r
228 #define MPU_REGION_PRIV_RO_URO ((uint8_t)0x06)
\r
233 /** @defgroup CORTEX_MPU_Region_Number CORTEX MPU Region Number
\r
236 #define MPU_REGION_NUMBER0 ((uint8_t)0x00)
\r
237 #define MPU_REGION_NUMBER1 ((uint8_t)0x01)
\r
238 #define MPU_REGION_NUMBER2 ((uint8_t)0x02)
\r
239 #define MPU_REGION_NUMBER3 ((uint8_t)0x03)
\r
240 #define MPU_REGION_NUMBER4 ((uint8_t)0x04)
\r
241 #define MPU_REGION_NUMBER5 ((uint8_t)0x05)
\r
242 #define MPU_REGION_NUMBER6 ((uint8_t)0x06)
\r
243 #define MPU_REGION_NUMBER7 ((uint8_t)0x07)
\r
247 #endif /* __MPU_PRESENT */
\r
252 /* Exported Macros -----------------------------------------------------------*/
\r
253 /** @defgroup CORTEX_Exported_Macros CORTEX Exported Macros
\r
257 /** @defgroup CORTEX_Preemption_Priority_Group_Macro CORTEX Preemption Priority Group
\r
260 #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PRIORITYGROUP_0) || \
\r
261 ((GROUP) == NVIC_PRIORITYGROUP_1) || \
\r
262 ((GROUP) == NVIC_PRIORITYGROUP_2) || \
\r
263 ((GROUP) == NVIC_PRIORITYGROUP_3) || \
\r
264 ((GROUP) == NVIC_PRIORITYGROUP_4))
\r
266 #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
\r
268 #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
\r
270 #define IS_NVIC_DEVICE_IRQ(IRQ) ((IRQ) >= 0x00)
\r
280 /* Private macro -------------------------------------------------------------*/
\r
281 /** @defgroup CORTEX_Private_Macros CORTEX Private Macros
\r
285 /** @defgroup CORTEX_SysTick_clock_source_Macro_Private CORTEX SysTick clock source
\r
288 #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SYSTICK_CLKSOURCE_HCLK) || \
\r
289 ((SOURCE) == SYSTICK_CLKSOURCE_HCLK_DIV8))
\r
294 #if (__MPU_PRESENT == 1)
\r
295 #define IS_MPU_REGION_ENABLE(STATE) (((STATE) == MPU_REGION_ENABLE) || \
\r
296 ((STATE) == MPU_REGION_DISABLE))
\r
298 #define IS_MPU_INSTRUCTION_ACCESS(STATE) (((STATE) == MPU_INSTRUCTION_ACCESS_ENABLE) || \
\r
299 ((STATE) == MPU_INSTRUCTION_ACCESS_DISABLE))
\r
301 #define IS_MPU_ACCESS_SHAREABLE(STATE) (((STATE) == MPU_ACCESS_SHAREABLE) || \
\r
302 ((STATE) == MPU_ACCESS_NOT_SHAREABLE))
\r
304 #define IS_MPU_ACCESS_CACHEABLE(STATE) (((STATE) == MPU_ACCESS_CACHEABLE) || \
\r
305 ((STATE) == MPU_ACCESS_NOT_CACHEABLE))
\r
307 #define IS_MPU_ACCESS_BUFFERABLE(STATE) (((STATE) == MPU_ACCESS_BUFFERABLE) || \
\r
308 ((STATE) == MPU_ACCESS_NOT_BUFFERABLE))
\r
310 #define IS_MPU_TEX_LEVEL(TYPE) (((TYPE) == MPU_TEX_LEVEL0) || \
\r
311 ((TYPE) == MPU_TEX_LEVEL1) || \
\r
312 ((TYPE) == MPU_TEX_LEVEL2))
\r
314 #define IS_MPU_REGION_PERMISSION_ATTRIBUTE(TYPE) (((TYPE) == MPU_REGION_NO_ACCESS) || \
\r
315 ((TYPE) == MPU_REGION_PRIV_RW) || \
\r
316 ((TYPE) == MPU_REGION_PRIV_RW_URO) || \
\r
317 ((TYPE) == MPU_REGION_FULL_ACCESS) || \
\r
318 ((TYPE) == MPU_REGION_PRIV_RO) || \
\r
319 ((TYPE) == MPU_REGION_PRIV_RO_URO))
\r
321 #define IS_MPU_REGION_NUMBER(NUMBER) (((NUMBER) == MPU_REGION_NUMBER0) || \
\r
322 ((NUMBER) == MPU_REGION_NUMBER1) || \
\r
323 ((NUMBER) == MPU_REGION_NUMBER2) || \
\r
324 ((NUMBER) == MPU_REGION_NUMBER3) || \
\r
325 ((NUMBER) == MPU_REGION_NUMBER4) || \
\r
326 ((NUMBER) == MPU_REGION_NUMBER5) || \
\r
327 ((NUMBER) == MPU_REGION_NUMBER6) || \
\r
328 ((NUMBER) == MPU_REGION_NUMBER7))
\r
330 #define IS_MPU_REGION_SIZE(SIZE) (((SIZE) == MPU_REGION_SIZE_32B) || \
\r
331 ((SIZE) == MPU_REGION_SIZE_64B) || \
\r
332 ((SIZE) == MPU_REGION_SIZE_128B) || \
\r
333 ((SIZE) == MPU_REGION_SIZE_256B) || \
\r
334 ((SIZE) == MPU_REGION_SIZE_512B) || \
\r
335 ((SIZE) == MPU_REGION_SIZE_1KB) || \
\r
336 ((SIZE) == MPU_REGION_SIZE_2KB) || \
\r
337 ((SIZE) == MPU_REGION_SIZE_4KB) || \
\r
338 ((SIZE) == MPU_REGION_SIZE_8KB) || \
\r
339 ((SIZE) == MPU_REGION_SIZE_16KB) || \
\r
340 ((SIZE) == MPU_REGION_SIZE_32KB) || \
\r
341 ((SIZE) == MPU_REGION_SIZE_64KB) || \
\r
342 ((SIZE) == MPU_REGION_SIZE_128KB) || \
\r
343 ((SIZE) == MPU_REGION_SIZE_256KB) || \
\r
344 ((SIZE) == MPU_REGION_SIZE_512KB) || \
\r
345 ((SIZE) == MPU_REGION_SIZE_1MB) || \
\r
346 ((SIZE) == MPU_REGION_SIZE_2MB) || \
\r
347 ((SIZE) == MPU_REGION_SIZE_4MB) || \
\r
348 ((SIZE) == MPU_REGION_SIZE_8MB) || \
\r
349 ((SIZE) == MPU_REGION_SIZE_16MB) || \
\r
350 ((SIZE) == MPU_REGION_SIZE_32MB) || \
\r
351 ((SIZE) == MPU_REGION_SIZE_64MB) || \
\r
352 ((SIZE) == MPU_REGION_SIZE_128MB) || \
\r
353 ((SIZE) == MPU_REGION_SIZE_256MB) || \
\r
354 ((SIZE) == MPU_REGION_SIZE_512MB) || \
\r
355 ((SIZE) == MPU_REGION_SIZE_1GB) || \
\r
356 ((SIZE) == MPU_REGION_SIZE_2GB) || \
\r
357 ((SIZE) == MPU_REGION_SIZE_4GB))
\r
359 #define IS_MPU_SUB_REGION_DISABLE(SUBREGION) ((SUBREGION) < (uint16_t)0x00FF)
\r
360 #endif /* __MPU_PRESENT */
\r
366 /* Private functions ---------------------------------------------------------*/
\r
367 /** @defgroup CORTEX_Private_Functions CORTEX Private Functions
\r
368 * @brief CORTEX private functions
\r
377 /* Exported functions --------------------------------------------------------*/
\r
378 /** @addtogroup CORTEX_Exported_Functions
\r
382 /** @addtogroup CORTEX_Exported_Functions_Group1
\r
385 /* Initialization and de-initialization functions *****************************/
\r
386 void HAL_NVIC_SetPriorityGrouping(uint32_t PriorityGroup);
\r
387 void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority);
\r
388 void HAL_NVIC_EnableIRQ(IRQn_Type IRQn);
\r
389 void HAL_NVIC_DisableIRQ(IRQn_Type IRQn);
\r
390 void HAL_NVIC_SystemReset(void);
\r
391 uint32_t HAL_SYSTICK_Config(uint32_t TicksNumb);
\r
396 /** @addtogroup CORTEX_Exported_Functions_Group2
\r
399 /* Peripheral Control functions ***********************************************/
\r
400 #if (__MPU_PRESENT == 1)
\r
401 void HAL_MPU_Enable(uint32_t MPU_Control);
\r
402 void HAL_MPU_Disable(void);
\r
403 void HAL_MPU_ConfigRegion(MPU_Region_InitTypeDef *MPU_Init);
\r
404 #endif /* __MPU_PRESENT */
\r
405 uint32_t HAL_NVIC_GetPriorityGrouping(void);
\r
406 void HAL_NVIC_GetPriority(IRQn_Type IRQn, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority);
\r
407 uint32_t HAL_NVIC_GetPendingIRQ(IRQn_Type IRQn);
\r
408 void HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn);
\r
409 void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn);
\r
410 uint32_t HAL_NVIC_GetActive(IRQn_Type IRQn);
\r
411 void HAL_SYSTICK_CLKSourceConfig(uint32_t CLKSource);
\r
412 void HAL_SYSTICK_IRQHandler(void);
\r
413 void HAL_SYSTICK_Callback(void);
\r
434 #endif /* __STM32L1xx_HAL_CORTEX_H */
\r
437 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r