stm32l4xx_hal_cortex.c 22 KB

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