uc-sdk
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
misc.c
Go to the documentation of this file.
1 
23 /* Includes ------------------------------------------------------------------*/
24 #include "misc.h"
25 
47 #define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000)
48 
96 void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup)
97 {
98  /* Check the parameters */
99  assert_param(IS_NVIC_PRIORITY_GROUP(NVIC_PriorityGroup));
100 
101  /* Set the PRIGROUP[10:8] bits according to NVIC_PriorityGroup value */
102  SCB->AIRCR = AIRCR_VECTKEY_MASK | NVIC_PriorityGroup;
103 }
104 
112 void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct)
113 {
114  uint32_t tmppriority = 0x00, tmppre = 0x00, tmpsub = 0x0F;
115 
116  /* Check the parameters */
120 
121  if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE)
122  {
123  /* Compute the Corresponding IRQ Priority --------------------------------*/
124  tmppriority = (0x700 - ((SCB->AIRCR) & (uint32_t)0x700))>> 0x08;
125  tmppre = (0x4 - tmppriority);
126  tmpsub = tmpsub >> tmppriority;
127 
128  tmppriority = (uint32_t)NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority << tmppre;
129  tmppriority |= NVIC_InitStruct->NVIC_IRQChannelSubPriority & tmpsub;
130  tmppriority = tmppriority << 0x04;
131 
132  NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel] = tmppriority;
133 
134  /* Enable the Selected IRQ Channels --------------------------------------*/
135  NVIC->ISER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =
136  (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
137  }
138  else
139  {
140  /* Disable the Selected IRQ Channels -------------------------------------*/
141  NVIC->ICER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =
142  (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
143  }
144 }
145 
156 void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset)
157 {
158  /* Check the parameters */
159  assert_param(IS_NVIC_VECTTAB(NVIC_VectTab));
160  assert_param(IS_NVIC_OFFSET(Offset));
161 
162  SCB->VTOR = NVIC_VectTab | (Offset & (uint32_t)0x1FFFFF80);
163 }
164 
175 void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState)
176 {
177  /* Check the parameters */
178  assert_param(IS_NVIC_LP(LowPowerMode));
179  assert_param(IS_FUNCTIONAL_STATE(NewState));
180 
181  if (NewState != DISABLE)
182  {
183  SCB->SCR |= LowPowerMode;
184  }
185  else
186  {
187  SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode);
188  }
189 }
190 
199 void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource)
200 {
201  /* Check the parameters */
202  assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource));
203  if (SysTick_CLKSource == SysTick_CLKSource_HCLK)
204  {
206  }
207  else
208  {
210  }
211 }
212 
225 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/