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