mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Wed Jul 01 09:45:11 2015 +0100
Revision:
579:53297373a894
Parent:
394:83f921546702
Synchronized with git revision d5b4d2ab9c47edb4dc5776e7177b0c2263459081

Full URL: https://github.com/mbedmicro/mbed/commit/d5b4d2ab9c47edb4dc5776e7177b0c2263459081/

Initial version of drivers for SAMR21

Who changed what in which revision?

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