airbourne/airbourne/lib/STM32F4xx_StdPeriph_Driver/src/misc.c
Go to the documentation of this file.
1 
75 /* Includes ------------------------------------------------------------------*/
76 #include "misc.h"
77 
87 /* Private typedef -----------------------------------------------------------*/
88 /* Private define ------------------------------------------------------------*/
89 #define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000)
90 
91 /* Private macro -------------------------------------------------------------*/
92 /* Private variables ---------------------------------------------------------*/
93 /* Private function prototypes -----------------------------------------------*/
94 /* Private functions ---------------------------------------------------------*/
95 
118 void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup)
119 {
120  /* Check the parameters */
121  assert_param(IS_NVIC_PRIORITY_GROUP(NVIC_PriorityGroup));
122 
123  /* Set the PRIGROUP[10:8] bits according to NVIC_PriorityGroup value */
124  SCB->AIRCR = AIRCR_VECTKEY_MASK | NVIC_PriorityGroup;
125 }
126 
136 void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct)
137 {
138  uint8_t tmppriority = 0x00, tmppre = 0x00, tmpsub = 0x0F;
139 
140  /* Check the parameters */
144 
145  if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE)
146  {
147  /* Compute the Corresponding IRQ Priority --------------------------------*/
148  tmppriority = (0x700 - ((SCB->AIRCR) & (uint32_t)0x700))>> 0x08;
149  tmppre = (0x4 - tmppriority);
150  tmpsub = tmpsub >> tmppriority;
151 
152  tmppriority = NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority << tmppre;
153  tmppriority |= (uint8_t)(NVIC_InitStruct->NVIC_IRQChannelSubPriority & tmpsub);
154 
155  tmppriority = tmppriority << 0x04;
156 
157  NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel] = tmppriority;
158 
159  /* Enable the Selected IRQ Channels --------------------------------------*/
160  NVIC->ISER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =
161  (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
162  }
163  else
164  {
165  /* Disable the Selected IRQ Channels -------------------------------------*/
166  NVIC->ICER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =
167  (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
168  }
169 }
170 
180 void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset)
181 {
182  /* Check the parameters */
183  assert_param(IS_NVIC_VECTTAB(NVIC_VectTab));
184  assert_param(IS_NVIC_OFFSET(Offset));
185 
186  SCB->VTOR = NVIC_VectTab | (Offset & (uint32_t)0x1FFFFF80);
187 }
188 
199 void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState)
200 {
201  /* Check the parameters */
202  assert_param(IS_NVIC_LP(LowPowerMode));
203  assert_param(IS_FUNCTIONAL_STATE(NewState));
204 
205  if (NewState != DISABLE)
206  {
207  SCB->SCR |= LowPowerMode;
208  }
209  else
210  {
211  SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode);
212  }
213 }
214 
223 void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource)
224 {
225  /* Check the parameters */
226  assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource));
227  if (SysTick_CLKSource == SysTick_CLKSource_HCLK)
228  {
230  }
231  else
232  {
234  }
235 }
236 
249 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState)
Selects the condition for the system to enter low power mode.
FunctionalState
Definition: stm32f4xx.h:708
void NVIC_Init(NVIC_InitTypeDef *NVIC_InitStruct)
Initializes the NVIC peripheral according to the specified parameters in the NVIC_InitStruct.
void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource)
Configures the SysTick clock source.
void assert_param(int val)
#define IS_FUNCTIONAL_STATE(STATE)
Definition: stm32f4xx.h:709
void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset)
Sets the vector table location and Offset.
#define SCB
Definition: core_cm0.h:503
#define SysTick
Definition: core_cm0.h:504
#define NVIC
Definition: core_cm0.h:505
void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup)
Configures the priority grouping: pre-emption priority and subpriority.


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Oct 24 2019 03:17:19