mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Mon Jan 27 14:30:07 2014 +0000
Revision:
76:aeb1df146756
Child:
106:ced8cbb51063
Synchronized with git revision a31ec9c5f7bcb5c8a1b2eced103f6a1dfa921abd

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

Add NUCLEO_L152RE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 76:aeb1df146756 1 /**
mbed_official 76:aeb1df146756 2 ******************************************************************************
mbed_official 76:aeb1df146756 3 * @file stm32f0xx_misc.c
mbed_official 76:aeb1df146756 4 * @author MCD Application Team
mbed_official 76:aeb1df146756 5 * @version V1.3.0
mbed_official 76:aeb1df146756 6 * @date 16-January-2014
mbed_official 76:aeb1df146756 7 * @brief This file provides all the miscellaneous firmware functions (add-on
mbed_official 76:aeb1df146756 8 * to CMSIS functions).
mbed_official 76:aeb1df146756 9 ******************************************************************************
mbed_official 76:aeb1df146756 10 * @attention
mbed_official 76:aeb1df146756 11 *
mbed_official 76:aeb1df146756 12 * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
mbed_official 76:aeb1df146756 13 *
mbed_official 76:aeb1df146756 14 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
mbed_official 76:aeb1df146756 15 * You may not use this file except in compliance with the License.
mbed_official 76:aeb1df146756 16 * You may obtain a copy of the License at:
mbed_official 76:aeb1df146756 17 *
mbed_official 76:aeb1df146756 18 * http://www.st.com/software_license_agreement_liberty_v2
mbed_official 76:aeb1df146756 19 *
mbed_official 76:aeb1df146756 20 * Unless required by applicable law or agreed to in writing, software
mbed_official 76:aeb1df146756 21 * distributed under the License is distributed on an "AS IS" BASIS,
mbed_official 76:aeb1df146756 22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbed_official 76:aeb1df146756 23 * See the License for the specific language governing permissions and
mbed_official 76:aeb1df146756 24 * limitations under the License.
mbed_official 76:aeb1df146756 25 *
mbed_official 76:aeb1df146756 26 ******************************************************************************
mbed_official 76:aeb1df146756 27 */
mbed_official 76:aeb1df146756 28
mbed_official 76:aeb1df146756 29 /* Includes ------------------------------------------------------------------*/
mbed_official 76:aeb1df146756 30 #include "stm32f0xx_misc.h"
mbed_official 76:aeb1df146756 31
mbed_official 76:aeb1df146756 32 /** @addtogroup STM32F0xx_StdPeriph_Driver
mbed_official 76:aeb1df146756 33 * @{
mbed_official 76:aeb1df146756 34 */
mbed_official 76:aeb1df146756 35
mbed_official 76:aeb1df146756 36 /** @defgroup MISC
mbed_official 76:aeb1df146756 37 * @brief MISC driver modules
mbed_official 76:aeb1df146756 38 * @{
mbed_official 76:aeb1df146756 39 */
mbed_official 76:aeb1df146756 40
mbed_official 76:aeb1df146756 41 /* Private typedef -----------------------------------------------------------*/
mbed_official 76:aeb1df146756 42 /* Private define ------------------------------------------------------------*/
mbed_official 76:aeb1df146756 43 /* Private macro -------------------------------------------------------------*/
mbed_official 76:aeb1df146756 44 /* Private variables ---------------------------------------------------------*/
mbed_official 76:aeb1df146756 45 /* Private function prototypes -----------------------------------------------*/
mbed_official 76:aeb1df146756 46 /* Private functions ---------------------------------------------------------*/
mbed_official 76:aeb1df146756 47
mbed_official 76:aeb1df146756 48 /** @defgroup MISC_Private_Functions
mbed_official 76:aeb1df146756 49 * @{
mbed_official 76:aeb1df146756 50 */
mbed_official 76:aeb1df146756 51 /**
mbed_official 76:aeb1df146756 52 *
mbed_official 76:aeb1df146756 53 @verbatim
mbed_official 76:aeb1df146756 54 *******************************************************************************
mbed_official 76:aeb1df146756 55 ##### Interrupts configuration functions #####
mbed_official 76:aeb1df146756 56 *******************************************************************************
mbed_official 76:aeb1df146756 57 [..] This section provide functions allowing to configure the NVIC interrupts
mbed_official 76:aeb1df146756 58 (IRQ). The Cortex-M0 exceptions are managed by CMSIS functions.
mbed_official 76:aeb1df146756 59 (#) Enable and Configure the priority of the selected IRQ Channels.
mbed_official 76:aeb1df146756 60 The priority can be 0..3.
mbed_official 76:aeb1df146756 61
mbed_official 76:aeb1df146756 62 -@- Lower priority values gives higher priority.
mbed_official 76:aeb1df146756 63 -@- Priority Order:
mbed_official 76:aeb1df146756 64 (#@) Lowest priority.
mbed_official 76:aeb1df146756 65 (#@) Lowest hardware priority (IRQn position).
mbed_official 76:aeb1df146756 66
mbed_official 76:aeb1df146756 67 @endverbatim
mbed_official 76:aeb1df146756 68 */
mbed_official 76:aeb1df146756 69
mbed_official 76:aeb1df146756 70 /**
mbed_official 76:aeb1df146756 71 * @brief Initializes the NVIC peripheral according to the specified
mbed_official 76:aeb1df146756 72 * parameters in the NVIC_InitStruct.
mbed_official 76:aeb1df146756 73 * @param NVIC_InitStruct: pointer to a NVIC_InitTypeDef structure that contains
mbed_official 76:aeb1df146756 74 * the configuration information for the specified NVIC peripheral.
mbed_official 76:aeb1df146756 75 * @retval None
mbed_official 76:aeb1df146756 76 */
mbed_official 76:aeb1df146756 77 void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct)
mbed_official 76:aeb1df146756 78 {
mbed_official 76:aeb1df146756 79 uint32_t tmppriority = 0x00;
mbed_official 76:aeb1df146756 80
mbed_official 76:aeb1df146756 81 /* Check the parameters */
mbed_official 76:aeb1df146756 82 assert_param(IS_FUNCTIONAL_STATE(NVIC_InitStruct->NVIC_IRQChannelCmd));
mbed_official 76:aeb1df146756 83 assert_param(IS_NVIC_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelPriority));
mbed_official 76:aeb1df146756 84
mbed_official 76:aeb1df146756 85 if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE)
mbed_official 76:aeb1df146756 86 {
mbed_official 76:aeb1df146756 87 /* Compute the Corresponding IRQ Priority --------------------------------*/
mbed_official 76:aeb1df146756 88 tmppriority = NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel >> 0x02];
mbed_official 76:aeb1df146756 89 tmppriority &= (uint32_t)(~(((uint32_t)0xFF) << ((NVIC_InitStruct->NVIC_IRQChannel & 0x03) * 8)));
mbed_official 76:aeb1df146756 90 tmppriority |= (uint32_t)((((uint32_t)NVIC_InitStruct->NVIC_IRQChannelPriority << 6) & 0xFF) << ((NVIC_InitStruct->NVIC_IRQChannel & 0x03) * 8));
mbed_official 76:aeb1df146756 91
mbed_official 76:aeb1df146756 92 NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel >> 0x02] = tmppriority;
mbed_official 76:aeb1df146756 93
mbed_official 76:aeb1df146756 94 /* Enable the Selected IRQ Channels --------------------------------------*/
mbed_official 76:aeb1df146756 95 NVIC->ISER[0] = (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
mbed_official 76:aeb1df146756 96 }
mbed_official 76:aeb1df146756 97 else
mbed_official 76:aeb1df146756 98 {
mbed_official 76:aeb1df146756 99 /* Disable the Selected IRQ Channels -------------------------------------*/
mbed_official 76:aeb1df146756 100 NVIC->ICER[0] = (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
mbed_official 76:aeb1df146756 101 }
mbed_official 76:aeb1df146756 102 }
mbed_official 76:aeb1df146756 103
mbed_official 76:aeb1df146756 104 /**
mbed_official 76:aeb1df146756 105 * @brief Selects the condition for the system to enter low power mode.
mbed_official 76:aeb1df146756 106 * @param LowPowerMode: Specifies the new mode for the system to enter low power mode.
mbed_official 76:aeb1df146756 107 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 108 * @arg NVIC_LP_SEVONPEND: Low Power SEV on Pend.
mbed_official 76:aeb1df146756 109 * @arg NVIC_LP_SLEEPDEEP: Low Power DEEPSLEEP request.
mbed_official 76:aeb1df146756 110 * @arg NVIC_LP_SLEEPONEXIT: Low Power Sleep on Exit.
mbed_official 76:aeb1df146756 111 * @param NewState: new state of LP condition.
mbed_official 76:aeb1df146756 112 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 113 * @retval None
mbed_official 76:aeb1df146756 114 */
mbed_official 76:aeb1df146756 115 void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState)
mbed_official 76:aeb1df146756 116 {
mbed_official 76:aeb1df146756 117 /* Check the parameters */
mbed_official 76:aeb1df146756 118 assert_param(IS_NVIC_LP(LowPowerMode));
mbed_official 76:aeb1df146756 119
mbed_official 76:aeb1df146756 120 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 121
mbed_official 76:aeb1df146756 122 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 123 {
mbed_official 76:aeb1df146756 124 SCB->SCR |= LowPowerMode;
mbed_official 76:aeb1df146756 125 }
mbed_official 76:aeb1df146756 126 else
mbed_official 76:aeb1df146756 127 {
mbed_official 76:aeb1df146756 128 SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode);
mbed_official 76:aeb1df146756 129 }
mbed_official 76:aeb1df146756 130 }
mbed_official 76:aeb1df146756 131
mbed_official 76:aeb1df146756 132 /**
mbed_official 76:aeb1df146756 133 * @brief Configures the SysTick clock source.
mbed_official 76:aeb1df146756 134 * @param SysTick_CLKSource: specifies the SysTick clock source.
mbed_official 76:aeb1df146756 135 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 136 * @arg SysTick_CLKSource_HCLK_Div8: AHB clock divided by 8 selected as SysTick clock source.
mbed_official 76:aeb1df146756 137 * @arg SysTick_CLKSource_HCLK: AHB clock selected as SysTick clock source.
mbed_official 76:aeb1df146756 138 * @retval None
mbed_official 76:aeb1df146756 139 */
mbed_official 76:aeb1df146756 140 void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource)
mbed_official 76:aeb1df146756 141 {
mbed_official 76:aeb1df146756 142 /* Check the parameters */
mbed_official 76:aeb1df146756 143 assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource));
mbed_official 76:aeb1df146756 144
mbed_official 76:aeb1df146756 145 if (SysTick_CLKSource == SysTick_CLKSource_HCLK)
mbed_official 76:aeb1df146756 146 {
mbed_official 76:aeb1df146756 147 SysTick->CTRL |= SysTick_CLKSource_HCLK;
mbed_official 76:aeb1df146756 148 }
mbed_official 76:aeb1df146756 149 else
mbed_official 76:aeb1df146756 150 {
mbed_official 76:aeb1df146756 151 SysTick->CTRL &= SysTick_CLKSource_HCLK_Div8;
mbed_official 76:aeb1df146756 152 }
mbed_official 76:aeb1df146756 153 }
mbed_official 76:aeb1df146756 154
mbed_official 76:aeb1df146756 155 /**
mbed_official 76:aeb1df146756 156 * @}
mbed_official 76:aeb1df146756 157 */
mbed_official 76:aeb1df146756 158
mbed_official 76:aeb1df146756 159 /**
mbed_official 76:aeb1df146756 160 * @}
mbed_official 76:aeb1df146756 161 */
mbed_official 76:aeb1df146756 162
mbed_official 76:aeb1df146756 163 /**
mbed_official 76:aeb1df146756 164 * @}
mbed_official 76:aeb1df146756 165 */
mbed_official 76:aeb1df146756 166
mbed_official 76:aeb1df146756 167 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/