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