Lancaster University's (short term!) clone of mbed-src for micro:bit. This is a copy of the github branch https://github.com/lancaster-university/mbed-classic

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Fri Aug 14 13:15:17 2015 +0100
Revision:
610:813dcc80987e
Synchronized with git revision 6d84db41c6833e0b9b024741eb0616a5f62d5599

Full URL: https://github.com/mbedmicro/mbed/commit/6d84db41c6833e0b9b024741eb0616a5f62d5599/

DISCO_F746NG - Improvements

Who changed what in which revision?

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