2 ******************************************************************************
\r
4 * @author MCD Application Team
\r
7 * @brief This file provides all the miscellaneous firmware functions (add-on
\r
8 * to CMSIS functions).
\r
9 ******************************************************************************
\r
12 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
\r
13 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
\r
14 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
\r
15 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
\r
16 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
\r
17 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
\r
19 * <h2><center>© COPYRIGHT 2010 STMicroelectronics</center></h2>
\r
22 /* Includes ------------------------------------------------------------------*/
\r
25 /** @addtogroup STM32F10x_StdPeriph_Driver
\r
30 * @brief MISC driver modules
\r
34 /** @defgroup MISC_Private_TypesDefinitions
\r
42 /** @defgroup MISC_Private_Defines
\r
46 #define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000)
\r
51 /** @defgroup MISC_Private_Macros
\r
59 /** @defgroup MISC_Private_Variables
\r
67 /** @defgroup MISC_Private_FunctionPrototypes
\r
75 /** @defgroup MISC_Private_Functions
\r
80 * @brief Configures the priority grouping: pre-emption priority and subpriority.
\r
81 * @param NVIC_PriorityGroup: specifies the priority grouping bits length.
\r
82 * This parameter can be one of the following values:
\r
83 * @arg NVIC_PriorityGroup_0: 0 bits for pre-emption priority
\r
84 * 4 bits for subpriority
\r
85 * @arg NVIC_PriorityGroup_1: 1 bits for pre-emption priority
\r
86 * 3 bits for subpriority
\r
87 * @arg NVIC_PriorityGroup_2: 2 bits for pre-emption priority
\r
88 * 2 bits for subpriority
\r
89 * @arg NVIC_PriorityGroup_3: 3 bits for pre-emption priority
\r
90 * 1 bits for subpriority
\r
91 * @arg NVIC_PriorityGroup_4: 4 bits for pre-emption priority
\r
92 * 0 bits for subpriority
\r
95 void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup)
\r
97 /* Check the parameters */
\r
98 assert_param(IS_NVIC_PRIORITY_GROUP(NVIC_PriorityGroup));
\r
100 /* Set the PRIGROUP[10:8] bits according to NVIC_PriorityGroup value */
\r
101 SCB->AIRCR = AIRCR_VECTKEY_MASK | NVIC_PriorityGroup;
\r
105 * @brief Initializes the NVIC peripheral according to the specified
\r
106 * parameters in the NVIC_InitStruct.
\r
107 * @param NVIC_InitStruct: pointer to a NVIC_InitTypeDef structure that contains
\r
108 * the configuration information for the specified NVIC peripheral.
\r
111 void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct)
\r
113 uint32_t tmppriority = 0x00, tmppre = 0x00, tmpsub = 0x0F;
\r
115 /* Check the parameters */
\r
116 assert_param(IS_FUNCTIONAL_STATE(NVIC_InitStruct->NVIC_IRQChannelCmd));
\r
117 assert_param(IS_NVIC_PREEMPTION_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority));
\r
118 assert_param(IS_NVIC_SUB_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelSubPriority));
\r
120 if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE)
\r
122 /* Compute the Corresponding IRQ Priority --------------------------------*/
\r
123 tmppriority = (0x700 - ((SCB->AIRCR) & (uint32_t)0x700))>> 0x08;
\r
124 tmppre = (0x4 - tmppriority);
\r
125 tmpsub = tmpsub >> tmppriority;
\r
127 tmppriority = (uint32_t)NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority << tmppre;
\r
128 tmppriority |= NVIC_InitStruct->NVIC_IRQChannelSubPriority & tmpsub;
\r
129 tmppriority = tmppriority << 0x04;
\r
131 NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel] = tmppriority;
\r
133 /* Enable the Selected IRQ Channels --------------------------------------*/
\r
134 NVIC->ISER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =
\r
135 (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
\r
139 /* Disable the Selected IRQ Channels -------------------------------------*/
\r
140 NVIC->ICER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =
\r
141 (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
\r
146 * @brief Sets the vector table location and Offset.
\r
147 * @param NVIC_VectTab: specifies if the vector table is in RAM or FLASH memory.
\r
148 * This parameter can be one of the following values:
\r
149 * @arg NVIC_VectTab_RAM
\r
150 * @arg NVIC_VectTab_FLASH
\r
151 * @param Offset: Vector Table base offset field. This value must be a multiple of 0x100.
\r
154 void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset)
\r
156 /* Check the parameters */
\r
157 assert_param(IS_NVIC_VECTTAB(NVIC_VectTab));
\r
158 assert_param(IS_NVIC_OFFSET(Offset));
\r
160 SCB->VTOR = NVIC_VectTab | (Offset & (uint32_t)0x1FFFFF80);
\r
164 * @brief Selects the condition for the system to enter low power mode.
\r
165 * @param LowPowerMode: Specifies the new mode for the system to enter low power mode.
\r
166 * This parameter can be one of the following values:
\r
167 * @arg NVIC_LP_SEVONPEND
\r
168 * @arg NVIC_LP_SLEEPDEEP
\r
169 * @arg NVIC_LP_SLEEPONEXIT
\r
170 * @param NewState: new state of LP condition. This parameter can be: ENABLE or DISABLE.
\r
173 void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState)
\r
175 /* Check the parameters */
\r
176 assert_param(IS_NVIC_LP(LowPowerMode));
\r
177 assert_param(IS_FUNCTIONAL_STATE(NewState));
\r
179 if (NewState != DISABLE)
\r
181 SCB->SCR |= LowPowerMode;
\r
185 SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode);
\r
190 * @brief Configures the SysTick clock source.
\r
191 * @param SysTick_CLKSource: specifies the SysTick clock source.
\r
192 * This parameter can be one of the following values:
\r
193 * @arg SysTick_CLKSource_HCLK_Div8: AHB clock divided by 8 selected as SysTick clock source.
\r
194 * @arg SysTick_CLKSource_HCLK: AHB clock selected as SysTick clock source.
\r
197 void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource)
\r
199 /* Check the parameters */
\r
200 assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource));
\r
201 if (SysTick_CLKSource == SysTick_CLKSource_HCLK)
\r
203 SysTick->CTRL |= SysTick_CLKSource_HCLK;
\r
207 SysTick->CTRL &= SysTick_CLKSource_HCLK_Div8;
\r
223 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
\r