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