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