]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_MPU_STM32L4_Discovery_GCC_IAR_Keil/ST_Code/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c
Rename STM32Cube to GCC for STM32L4 Discovery projects as GCC is
[freertos] / FreeRTOS / Demo / CORTEX_MPU_STM32L4_Discovery_GCC_IAR_Keil / ST_Code / Drivers / STM32L4xx_HAL_Driver / Src / stm32l4xx_hal_cortex.c
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32l4xx_hal_cortex.c\r
4   * @author  MCD Application Team\r
5   * @brief   CORTEX HAL module driver.\r
6   *          This file provides firmware functions to manage the following\r
7   *          functionalities of the CORTEX:\r
8   *           + Initialization and Configuration functions\r
9   *           + Peripheral Control functions\r
10   *\r
11   @verbatim\r
12   ==============================================================================\r
13                         ##### How to use this driver #####\r
14   ==============================================================================\r
15 \r
16     [..]\r
17     *** How to configure Interrupts using CORTEX HAL driver ***\r
18     ===========================================================\r
19     [..]\r
20     This section provides functions allowing to configure the NVIC interrupts (IRQ).\r
21     The Cortex-M4 exceptions are managed by CMSIS functions.\r
22 \r
23     (#) Configure the NVIC Priority Grouping using HAL_NVIC_SetPriorityGrouping() function.\r
24     (#) Configure the priority of the selected IRQ Channels using HAL_NVIC_SetPriority().\r
25     (#) Enable the selected IRQ Channels using HAL_NVIC_EnableIRQ().\r
26 \r
27      -@- When the NVIC_PRIORITYGROUP_0 is selected, IRQ pre-emption is no more possible.\r
28          The pending IRQ priority will be managed only by the sub priority.\r
29 \r
30      -@- IRQ priority order (sorted by highest to lowest priority):\r
31         (+@) Lowest pre-emption priority\r
32         (+@) Lowest sub priority\r
33         (+@) Lowest hardware priority (IRQ number)\r
34 \r
35     [..]\r
36     *** How to configure SysTick using CORTEX HAL driver ***\r
37     ========================================================\r
38     [..]\r
39     Setup SysTick Timer for time base.\r
40 \r
41    (+) The HAL_SYSTICK_Config() function calls the SysTick_Config() function which\r
42        is a CMSIS function that:\r
43         (++) Configures the SysTick Reload register with value passed as function parameter.\r
44         (++) Configures the SysTick IRQ priority to the lowest value (0x0F).\r
45         (++) Resets the SysTick Counter register.\r
46         (++) Configures the SysTick Counter clock source to be Core Clock Source (HCLK).\r
47         (++) Enables the SysTick Interrupt.\r
48         (++) Starts the SysTick Counter.\r
49 \r
50    (+) You can change the SysTick Clock source to be HCLK_Div8 by calling the macro\r
51        __HAL_CORTEX_SYSTICKCLK_CONFIG(SYSTICK_CLKSOURCE_HCLK_DIV8) just after the\r
52        HAL_SYSTICK_Config() function call. The __HAL_CORTEX_SYSTICKCLK_CONFIG() macro is defined\r
53        inside the stm32l4xx_hal_cortex.h file.\r
54 \r
55    (+) You can change the SysTick IRQ priority by calling the\r
56        HAL_NVIC_SetPriority(SysTick_IRQn,...) function just after the HAL_SYSTICK_Config() function\r
57        call. The HAL_NVIC_SetPriority() call the NVIC_SetPriority() function which is a CMSIS function.\r
58 \r
59    (+) To adjust the SysTick time base, use the following formula:\r
60 \r
61        Reload Value = SysTick Counter Clock (Hz) x  Desired Time base (s)\r
62        (++) Reload Value is the parameter to be passed for HAL_SYSTICK_Config() function\r
63        (++) Reload Value should not exceed 0xFFFFFF\r
64 \r
65   @endverbatim\r
66   ******************************************************************************\r
67 \r
68   The table below gives the allowed values of the pre-emption priority and subpriority according\r
69   to the Priority Grouping configuration performed by HAL_NVIC_SetPriorityGrouping() function.\r
70 \r
71     ==========================================================================================================================\r
72       NVIC_PriorityGroup   | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority  |       Description\r
73     ==========================================================================================================================\r
74      NVIC_PRIORITYGROUP_0  |                0                  |            0-15             | 0 bit for pre-emption priority\r
75                            |                                   |                             | 4 bits for subpriority\r
76     --------------------------------------------------------------------------------------------------------------------------\r
77      NVIC_PRIORITYGROUP_1  |                0-1                |            0-7              | 1 bit for pre-emption priority\r
78                            |                                   |                             | 3 bits for subpriority\r
79     --------------------------------------------------------------------------------------------------------------------------\r
80      NVIC_PRIORITYGROUP_2  |                0-3                |            0-3              | 2 bits for pre-emption priority\r
81                            |                                   |                             | 2 bits for subpriority\r
82     --------------------------------------------------------------------------------------------------------------------------\r
83      NVIC_PRIORITYGROUP_3  |                0-7                |            0-1              | 3 bits for pre-emption priority\r
84                            |                                   |                             | 1 bit for subpriority\r
85     --------------------------------------------------------------------------------------------------------------------------\r
86      NVIC_PRIORITYGROUP_4  |                0-15               |            0                | 4 bits for pre-emption priority\r
87                            |                                   |                             | 0 bit for subpriority\r
88     ==========================================================================================================================\r
89 \r
90   ******************************************************************************\r
91   * @attention\r
92   *\r
93   * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.\r
94   * All rights reserved.</center></h2>\r
95   *\r
96   * This software component is licensed by ST under BSD 3-Clause license,\r
97   * the "License"; You may not use this file except in compliance with the\r
98   * License. You may obtain a copy of the License at:\r
99   *                        opensource.org/licenses/BSD-3-Clause\r
100   *\r
101   ******************************************************************************\r
102   */\r
103 \r
104 /* Includes ------------------------------------------------------------------*/\r
105 #include "stm32l4xx_hal.h"\r
106 \r
107 /** @addtogroup STM32L4xx_HAL_Driver\r
108   * @{\r
109   */\r
110 \r
111 /** @addtogroup CORTEX\r
112   * @{\r
113   */\r
114 \r
115 #ifdef HAL_CORTEX_MODULE_ENABLED\r
116 \r
117 /* Private types -------------------------------------------------------------*/\r
118 /* Private variables ---------------------------------------------------------*/\r
119 /* Private constants ---------------------------------------------------------*/\r
120 /* Private macros ------------------------------------------------------------*/\r
121 /* Private functions ---------------------------------------------------------*/\r
122 /* Exported functions --------------------------------------------------------*/\r
123 \r
124 /** @addtogroup CORTEX_Exported_Functions\r
125   * @{\r
126   */\r
127 \r
128 \r
129 /** @addtogroup CORTEX_Exported_Functions_Group1\r
130  *  @brief    Initialization and Configuration functions\r
131  *\r
132 @verbatim\r
133   ==============================================================================\r
134               ##### Initialization and Configuration functions #####\r
135   ==============================================================================\r
136     [..]\r
137       This section provides the CORTEX HAL driver functions allowing to configure Interrupts\r
138       SysTick functionalities\r
139 \r
140 @endverbatim\r
141   * @{\r
142   */\r
143 \r
144 \r
145 /**\r
146   * @brief  Set the priority grouping field (pre-emption priority and subpriority)\r
147   *         using the required unlock sequence.\r
148   * @param  PriorityGroup: The priority grouping bits length.\r
149   *         This parameter can be one of the following values:\r
150   *         @arg NVIC_PRIORITYGROUP_0: 0 bit  for pre-emption priority,\r
151   *                                    4 bits for subpriority\r
152   *         @arg NVIC_PRIORITYGROUP_1: 1 bit  for pre-emption priority,\r
153   *                                    3 bits for subpriority\r
154   *         @arg NVIC_PRIORITYGROUP_2: 2 bits for pre-emption priority,\r
155   *                                    2 bits for subpriority\r
156   *         @arg NVIC_PRIORITYGROUP_3: 3 bits for pre-emption priority,\r
157   *                                    1 bit  for subpriority\r
158   *         @arg NVIC_PRIORITYGROUP_4: 4 bits for pre-emption priority,\r
159   *                                    0 bit  for subpriority\r
160   * @note   When the NVIC_PriorityGroup_0 is selected, IRQ pre-emption is no more possible.\r
161   *         The pending IRQ priority will be managed only by the subpriority.\r
162   * @retval None\r
163   */\r
164 void HAL_NVIC_SetPriorityGrouping(uint32_t PriorityGroup)\r
165 {\r
166   /* Check the parameters */\r
167   assert_param(IS_NVIC_PRIORITY_GROUP(PriorityGroup));\r
168 \r
169   /* Set the PRIGROUP[10:8] bits according to the PriorityGroup parameter value */\r
170   NVIC_SetPriorityGrouping(PriorityGroup);\r
171 }\r
172 \r
173 /**\r
174   * @brief  Set the priority of an interrupt.\r
175   * @param  IRQn: External interrupt number.\r
176   *         This parameter can be an enumerator of IRQn_Type enumeration\r
177   *         (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32l4xxxx.h))\r
178   * @param  PreemptPriority: The pre-emption priority for the IRQn channel.\r
179   *         This parameter can be a value between 0 and 15\r
180   *         A lower priority value indicates a higher priority\r
181   * @param  SubPriority: the subpriority level for the IRQ channel.\r
182   *         This parameter can be a value between 0 and 15\r
183   *         A lower priority value indicates a higher priority.\r
184   * @retval None\r
185   */\r
186 void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)\r
187 {\r
188   uint32_t prioritygroup = 0x00;\r
189 \r
190   /* Check the parameters */\r
191   assert_param(IS_NVIC_SUB_PRIORITY(SubPriority));\r
192   assert_param(IS_NVIC_PREEMPTION_PRIORITY(PreemptPriority));\r
193 \r
194   prioritygroup = NVIC_GetPriorityGrouping();\r
195 \r
196   NVIC_SetPriority(IRQn, NVIC_EncodePriority(prioritygroup, PreemptPriority, SubPriority));\r
197 }\r
198 \r
199 /**\r
200   * @brief  Enable a device specific interrupt in the NVIC interrupt controller.\r
201   * @note   To configure interrupts priority correctly, the NVIC_PriorityGroupConfig()\r
202   *         function should be called before.\r
203   * @param  IRQn External interrupt number.\r
204   *         This parameter can be an enumerator of IRQn_Type enumeration\r
205   *         (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32l4xxxx.h))\r
206   * @retval None\r
207   */\r
208 void HAL_NVIC_EnableIRQ(IRQn_Type IRQn)\r
209 {\r
210   /* Check the parameters */\r
211   assert_param(IS_NVIC_DEVICE_IRQ(IRQn));\r
212 \r
213   /* Enable interrupt */\r
214   NVIC_EnableIRQ(IRQn);\r
215 }\r
216 \r
217 /**\r
218   * @brief  Disable a device specific interrupt in the NVIC interrupt controller.\r
219   * @param  IRQn External interrupt number.\r
220   *         This parameter can be an enumerator of IRQn_Type enumeration\r
221   *         (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32l4xxxx.h))\r
222   * @retval None\r
223   */\r
224 void HAL_NVIC_DisableIRQ(IRQn_Type IRQn)\r
225 {\r
226   /* Check the parameters */\r
227   assert_param(IS_NVIC_DEVICE_IRQ(IRQn));\r
228 \r
229   /* Disable interrupt */\r
230   NVIC_DisableIRQ(IRQn);\r
231 }\r
232 \r
233 /**\r
234   * @brief  Initiate a system reset request to reset the MCU.\r
235   * @retval None\r
236   */\r
237 void HAL_NVIC_SystemReset(void)\r
238 {\r
239   /* System Reset */\r
240   NVIC_SystemReset();\r
241 }\r
242 \r
243 /**\r
244   * @brief  Initialize the System Timer with interrupt enabled and start the System Tick Timer (SysTick):\r
245   *         Counter is in free running mode to generate periodic interrupts.\r
246   * @param  TicksNumb: Specifies the ticks Number of ticks between two interrupts.\r
247   * @retval status:  - 0  Function succeeded.\r
248   *                  - 1  Function failed.\r
249   */\r
250 uint32_t HAL_SYSTICK_Config(uint32_t TicksNumb)\r
251 {\r
252    return SysTick_Config(TicksNumb);\r
253 }\r
254 /**\r
255   * @}\r
256   */\r
257 \r
258 /** @addtogroup CORTEX_Exported_Functions_Group2\r
259  *  @brief   Cortex control functions\r
260  *\r
261 @verbatim\r
262   ==============================================================================\r
263                       ##### Peripheral Control functions #####\r
264   ==============================================================================\r
265     [..]\r
266       This subsection provides a set of functions allowing to control the CORTEX\r
267       (NVIC, SYSTICK, MPU) functionalities.\r
268 \r
269 \r
270 @endverbatim\r
271   * @{\r
272   */\r
273 \r
274 /**\r
275   * @brief  Get the priority grouping field from the NVIC Interrupt Controller.\r
276   * @retval Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field)\r
277   */\r
278 uint32_t HAL_NVIC_GetPriorityGrouping(void)\r
279 {\r
280   /* Get the PRIGROUP[10:8] field value */\r
281   return NVIC_GetPriorityGrouping();\r
282 }\r
283 \r
284 /**\r
285   * @brief  Get the priority of an interrupt.\r
286   * @param  IRQn: External interrupt number.\r
287   *         This parameter can be an enumerator of IRQn_Type enumeration\r
288   *         (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32l4xxxx.h))\r
289   * @param   PriorityGroup: the priority grouping bits length.\r
290   *         This parameter can be one of the following values:\r
291   *           @arg NVIC_PRIORITYGROUP_0: 0 bit for pre-emption priority,\r
292   *                                      4 bits for subpriority\r
293   *           @arg NVIC_PRIORITYGROUP_1: 1 bit for pre-emption priority,\r
294   *                                      3 bits for subpriority\r
295   *           @arg NVIC_PRIORITYGROUP_2: 2 bits for pre-emption priority,\r
296   *                                      2 bits for subpriority\r
297   *           @arg NVIC_PRIORITYGROUP_3: 3 bits for pre-emption priority,\r
298   *                                      1 bit for subpriority\r
299   *           @arg NVIC_PRIORITYGROUP_4: 4 bits for pre-emption priority,\r
300   *                                      0 bit for subpriority\r
301   * @param  pPreemptPriority: Pointer on the Preemptive priority value (starting from 0).\r
302   * @param  pSubPriority: Pointer on the Subpriority value (starting from 0).\r
303   * @retval None\r
304   */\r
305 void HAL_NVIC_GetPriority(IRQn_Type IRQn, uint32_t PriorityGroup, uint32_t *pPreemptPriority, uint32_t *pSubPriority)\r
306 {\r
307   /* Check the parameters */\r
308   assert_param(IS_NVIC_PRIORITY_GROUP(PriorityGroup));\r
309  /* Get priority for Cortex-M system or device specific interrupts */\r
310   NVIC_DecodePriority(NVIC_GetPriority(IRQn), PriorityGroup, pPreemptPriority, pSubPriority);\r
311 }\r
312 \r
313 /**\r
314   * @brief  Set Pending bit of an external interrupt.\r
315   * @param  IRQn External interrupt number\r
316   *         This parameter can be an enumerator of IRQn_Type enumeration\r
317   *         (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32l4xxxx.h))\r
318   * @retval None\r
319   */\r
320 void HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn)\r
321 {\r
322   /* Check the parameters */\r
323   assert_param(IS_NVIC_DEVICE_IRQ(IRQn));\r
324 \r
325   /* Set interrupt pending */\r
326   NVIC_SetPendingIRQ(IRQn);\r
327 }\r
328 \r
329 /**\r
330   * @brief  Get Pending Interrupt (read the pending register in the NVIC\r
331   *         and return the pending bit for the specified interrupt).\r
332   * @param  IRQn External interrupt number.\r
333   *          This parameter can be an enumerator of IRQn_Type enumeration\r
334   *         (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32l4xxxx.h))\r
335   * @retval status: - 0  Interrupt status is not pending.\r
336   *                 - 1  Interrupt status is pending.\r
337   */\r
338 uint32_t HAL_NVIC_GetPendingIRQ(IRQn_Type IRQn)\r
339 {\r
340   /* Check the parameters */\r
341   assert_param(IS_NVIC_DEVICE_IRQ(IRQn));\r
342 \r
343   /* Return 1 if pending else 0 */\r
344   return NVIC_GetPendingIRQ(IRQn);\r
345 }\r
346 \r
347 /**\r
348   * @brief  Clear the pending bit of an external interrupt.\r
349   * @param  IRQn External interrupt number.\r
350   *         This parameter can be an enumerator of IRQn_Type enumeration\r
351   *         (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32l4xxxx.h))\r
352   * @retval None\r
353   */\r
354 void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn)\r
355 {\r
356   /* Check the parameters */\r
357   assert_param(IS_NVIC_DEVICE_IRQ(IRQn));\r
358 \r
359   /* Clear pending interrupt */\r
360   NVIC_ClearPendingIRQ(IRQn);\r
361 }\r
362 \r
363 /**\r
364   * @brief Get active interrupt (read the active register in NVIC and return the active bit).\r
365   * @param IRQn External interrupt number\r
366   *         This parameter can be an enumerator of IRQn_Type enumeration\r
367   *         (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32l4xxxx.h))\r
368   * @retval status: - 0  Interrupt status is not pending.\r
369   *                 - 1  Interrupt status is pending.\r
370   */\r
371 uint32_t HAL_NVIC_GetActive(IRQn_Type IRQn)\r
372 {\r
373   /* Return 1 if active else 0 */\r
374   return NVIC_GetActive(IRQn);\r
375 }\r
376 \r
377 /**\r
378   * @brief  Configure the SysTick clock source.\r
379   * @param  CLKSource: specifies the SysTick clock source.\r
380   *          This parameter can be one of the following values:\r
381   *             @arg SYSTICK_CLKSOURCE_HCLK_DIV8: AHB clock divided by 8 selected as SysTick clock source.\r
382   *             @arg SYSTICK_CLKSOURCE_HCLK: AHB clock selected as SysTick clock source.\r
383   * @retval None\r
384   */\r
385 void HAL_SYSTICK_CLKSourceConfig(uint32_t CLKSource)\r
386 {\r
387   /* Check the parameters */\r
388   assert_param(IS_SYSTICK_CLK_SOURCE(CLKSource));\r
389   if (CLKSource == SYSTICK_CLKSOURCE_HCLK)\r
390   {\r
391     SysTick->CTRL |= SYSTICK_CLKSOURCE_HCLK;\r
392   }\r
393   else\r
394   {\r
395     SysTick->CTRL &= ~SYSTICK_CLKSOURCE_HCLK;\r
396   }\r
397 }\r
398 \r
399 /**\r
400   * @brief  Handle SYSTICK interrupt request.\r
401   * @retval None\r
402   */\r
403 void HAL_SYSTICK_IRQHandler(void)\r
404 {\r
405   HAL_SYSTICK_Callback();\r
406 }\r
407 \r
408 /**\r
409   * @brief  SYSTICK callback.\r
410   * @retval None\r
411   */\r
412 __weak void HAL_SYSTICK_Callback(void)\r
413 {\r
414   /* NOTE : This function should not be modified, when the callback is needed,\r
415             the HAL_SYSTICK_Callback could be implemented in the user file\r
416    */\r
417 }\r
418 \r
419 #if (__MPU_PRESENT == 1)\r
420 /**\r
421   * @brief  Disable the MPU.\r
422   * @retval None\r
423   */\r
424 void HAL_MPU_Disable(void)\r
425 {\r
426   /* Make sure outstanding transfers are done */\r
427   __DMB();\r
428 \r
429   /* Disable fault exceptions */\r
430   SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;\r
431 \r
432   /* Disable the MPU and clear the control register*/\r
433   MPU->CTRL = 0U;\r
434 }\r
435 \r
436 /**\r
437   * @brief  Enable the MPU.\r
438   * @param  MPU_Control: Specifies the control mode of the MPU during hard fault,\r
439   *          NMI, FAULTMASK and privileged accessto the default memory\r
440   *          This parameter can be one of the following values:\r
441   *            @arg MPU_HFNMI_PRIVDEF_NONE\r
442   *            @arg MPU_HARDFAULT_NMI\r
443   *            @arg MPU_PRIVILEGED_DEFAULT\r
444   *            @arg MPU_HFNMI_PRIVDEF\r
445   * @retval None\r
446   */\r
447 void HAL_MPU_Enable(uint32_t MPU_Control)\r
448 {\r
449   /* Enable the MPU */\r
450   MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk;\r
451 \r
452   /* Enable fault exceptions */\r
453   SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;\r
454 \r
455   /* Ensure MPU settings take effects */\r
456   __DSB();\r
457   __ISB();\r
458 }\r
459 \r
460 /**\r
461   * @brief  Initialize and configure the Region and the memory to be protected.\r
462   * @param  MPU_Init: Pointer to a MPU_Region_InitTypeDef structure that contains\r
463   *                the initialization and configuration information.\r
464   * @retval None\r
465   */\r
466 void HAL_MPU_ConfigRegion(MPU_Region_InitTypeDef *MPU_Init)\r
467 {\r
468   /* Check the parameters */\r
469   assert_param(IS_MPU_REGION_NUMBER(MPU_Init->Number));\r
470   assert_param(IS_MPU_REGION_ENABLE(MPU_Init->Enable));\r
471 \r
472   /* Set the Region number */\r
473   MPU->RNR = MPU_Init->Number;\r
474 \r
475   if ((MPU_Init->Enable) != RESET)\r
476   {\r
477     /* Check the parameters */\r
478     assert_param(IS_MPU_INSTRUCTION_ACCESS(MPU_Init->DisableExec));\r
479     assert_param(IS_MPU_REGION_PERMISSION_ATTRIBUTE(MPU_Init->AccessPermission));\r
480     assert_param(IS_MPU_TEX_LEVEL(MPU_Init->TypeExtField));\r
481     assert_param(IS_MPU_ACCESS_SHAREABLE(MPU_Init->IsShareable));\r
482     assert_param(IS_MPU_ACCESS_CACHEABLE(MPU_Init->IsCacheable));\r
483     assert_param(IS_MPU_ACCESS_BUFFERABLE(MPU_Init->IsBufferable));\r
484     assert_param(IS_MPU_SUB_REGION_DISABLE(MPU_Init->SubRegionDisable));\r
485     assert_param(IS_MPU_REGION_SIZE(MPU_Init->Size));\r
486 \r
487     MPU->RBAR = MPU_Init->BaseAddress;\r
488     MPU->RASR = ((uint32_t)MPU_Init->DisableExec        << MPU_RASR_XN_Pos)   |\r
489                 ((uint32_t)MPU_Init->AccessPermission   << MPU_RASR_AP_Pos)   |\r
490                 ((uint32_t)MPU_Init->TypeExtField       << MPU_RASR_TEX_Pos)  |\r
491                 ((uint32_t)MPU_Init->IsShareable        << MPU_RASR_S_Pos)    |\r
492                 ((uint32_t)MPU_Init->IsCacheable        << MPU_RASR_C_Pos)    |\r
493                 ((uint32_t)MPU_Init->IsBufferable       << MPU_RASR_B_Pos)    |\r
494                 ((uint32_t)MPU_Init->SubRegionDisable   << MPU_RASR_SRD_Pos)  |\r
495                 ((uint32_t)MPU_Init->Size               << MPU_RASR_SIZE_Pos) |\r
496                 ((uint32_t)MPU_Init->Enable             << MPU_RASR_ENABLE_Pos);\r
497   }\r
498   else\r
499   {\r
500     MPU->RBAR = 0x00;\r
501     MPU->RASR = 0x00;\r
502   }\r
503 }\r
504 #endif /* __MPU_PRESENT */\r
505 \r
506 /**\r
507   * @}\r
508   */\r
509 \r
510 /**\r
511   * @}\r
512   */\r
513 \r
514 #endif /* HAL_CORTEX_MODULE_ENABLED */\r
515 /**\r
516   * @}\r
517   */\r
518 \r
519 /**\r
520   * @}\r
521   */\r
522 \r
523 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r