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