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