stm32f30x_misc.c
Go to the documentation of this file.
1 
57 /* Includes ------------------------------------------------------------------*/
58 #include "stm32f30x_misc.h"
59 
69 /* Private typedef -----------------------------------------------------------*/
70 /* Private define ------------------------------------------------------------*/
71 #define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000)
72 
73 /* Private macro -------------------------------------------------------------*/
74 /* Private variables ---------------------------------------------------------*/
75 /* Private function prototypes -----------------------------------------------*/
76 /* Private functions ---------------------------------------------------------*/
77 
100 void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup)
101 {
102  /* Check the parameters */
103  assert_param(IS_NVIC_PRIORITY_GROUP(NVIC_PriorityGroup));
104 
105  /* Set the PRIGROUP[10:8] bits according to NVIC_PriorityGroup value */
106  SCB->AIRCR = AIRCR_VECTKEY_MASK | NVIC_PriorityGroup;
107 }
108 
118 void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct)
119 {
120  uint32_t tmppriority = 0x00, tmppre = 0x00, tmpsub = 0x0F;
121 
122  /* Check the parameters */
126 
127  if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE)
128  {
129  /* Compute the Corresponding IRQ Priority --------------------------------*/
130  tmppriority = (0x700 - ((SCB->AIRCR) & (uint32_t)0x700))>> 0x08;
131  tmppre = (0x4 - tmppriority);
132  tmpsub = tmpsub >> tmppriority;
133 
134  tmppriority = (uint32_t)NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority << tmppre;
135  tmppriority |= NVIC_InitStruct->NVIC_IRQChannelSubPriority & tmpsub;
136  tmppriority = tmppriority << 0x04;
137 
138  NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel] = tmppriority;
139 
140  /* Enable the Selected IRQ Channels --------------------------------------*/
141  NVIC->ISER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =
142  (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
143  }
144  else
145  {
146  /* Disable the Selected IRQ Channels -------------------------------------*/
147  NVIC->ICER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =
148  (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
149  }
150 }
151 
161 void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset)
162 {
163  /* Check the parameters */
164  assert_param(IS_NVIC_VECTTAB(NVIC_VectTab));
165  assert_param(IS_NVIC_OFFSET(Offset));
166 
167  SCB->VTOR = NVIC_VectTab | (Offset & (uint32_t)0x1FFFFF80);
168 }
169 
180 void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState)
181 {
182  /* Check the parameters */
183  assert_param(IS_NVIC_LP(LowPowerMode));
184  assert_param(IS_FUNCTIONAL_STATE(NewState));
185 
186  if (NewState != DISABLE)
187  {
188  SCB->SCR |= LowPowerMode;
189  }
190  else
191  {
192  SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode);
193  }
194 }
195 
204 void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource)
205 {
206  /* Check the parameters */
207  assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource));
208  if (SysTick_CLKSource == SysTick_CLKSource_HCLK)
209  {
211  }
212  else
213  {
215  }
216 }
217 
230 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
void NVIC_Init(NVIC_InitTypeDef *NVIC_InitStruct)
Initializes the NVIC peripheral according to the specified parameters in the NVIC_InitStruct.
void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup)
Configures the priority grouping: pre-emption priority and subpriority.
FunctionalState
Definition: stm32f4xx.h:708
void assert_param(int val)
#define IS_FUNCTIONAL_STATE(STATE)
Definition: stm32f4xx.h:709
#define SCB
Definition: core_cm0.h:503
#define SysTick
Definition: core_cm0.h:504
This file contains all the functions prototypes for the miscellaneous firmware library functions (add...
#define NVIC
Definition: core_cm0.h:505
void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset)
Sets the vector table location and Offset.
void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource)
Configures the SysTick clock source.
void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState)
Selects the condition for the system to enter low power mode.
#define AIRCR_VECTKEY_MASK


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Apr 15 2021 05:07:48