stm32f30x_exti.c
Go to the documentation of this file.
1 
80 /* Includes ------------------------------------------------------------------*/
81 #include "stm32f30x_exti.h"
82 
93 /* Private typedef -----------------------------------------------------------*/
94 /* Private define ------------------------------------------------------------*/
95 #define EXTI_LINENONE ((uint32_t)0x00000) /* No interrupt selected */
96 
97 /* Private macro -------------------------------------------------------------*/
98 /* Private variables ---------------------------------------------------------*/
99 /* Private function prototypes -----------------------------------------------*/
100 /* Private functions ---------------------------------------------------------*/
101 
124 void EXTI_DeInit(void)
125 {
126  EXTI->IMR = 0x1F800000;
127  EXTI->EMR = 0x00000000;
128  EXTI->RTSR = 0x00000000;
129  EXTI->FTSR = 0x00000000;
130  EXTI->SWIER = 0x00000000;
131  EXTI->PR = 0xE07FFFFF;
132  EXTI->IMR2 = 0x0000000C;
133  EXTI->EMR2 = 0x00000000;
134  EXTI->RTSR2 = 0x00000000;
135  EXTI->FTSR2 = 0x00000000;
136  EXTI->SWIER2 = 0x00000000;
137  EXTI->PR2 = 0x00000003;
138 }
139 
154 void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct)
155 {
156  uint32_t tmp = 0;
157 
158  /* Check the parameters */
159  assert_param(IS_EXTI_MODE(EXTI_InitStruct->EXTI_Mode));
160  assert_param(IS_EXTI_TRIGGER(EXTI_InitStruct->EXTI_Trigger));
161  assert_param(IS_EXTI_LINE_ALL(EXTI_InitStruct->EXTI_Line));
162  assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->EXTI_LineCmd));
163 
164  tmp = (uint32_t)EXTI_BASE;
165 
166  if (EXTI_InitStruct->EXTI_LineCmd != DISABLE)
167  {
168  /* Clear EXTI line configuration */
169  *(__IO uint32_t *) (((uint32_t) &(EXTI->IMR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) &= ~(uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
170  *(__IO uint32_t *) (((uint32_t) &(EXTI->EMR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) &= ~(uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
171 
172  tmp += EXTI_InitStruct->EXTI_Mode + (((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20);
173 
174  *(__IO uint32_t *) tmp |= (uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
175 
176  tmp = (uint32_t)EXTI_BASE;
177 
178  /* Clear Rising Falling edge configuration */
179  *(__IO uint32_t *) (((uint32_t) &(EXTI->RTSR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) &= ~(uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
180  *(__IO uint32_t *) (((uint32_t) &(EXTI->FTSR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) &= ~(uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
181 
182  /* Select the trigger for the selected interrupts */
183  if (EXTI_InitStruct->EXTI_Trigger == EXTI_Trigger_Rising_Falling)
184  {
185  /* Rising Falling edge */
186  *(__IO uint32_t *) (((uint32_t) &(EXTI->RTSR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) |= (uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
187  *(__IO uint32_t *) (((uint32_t) &(EXTI->FTSR)) + ((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20) |= (uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
188  }
189  else
190  {
191  tmp += EXTI_InitStruct->EXTI_Trigger + (((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20);
192 
193  *(__IO uint32_t *) tmp |= (uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
194  }
195  }
196 
197  else
198  {
199  tmp += EXTI_InitStruct->EXTI_Mode + (((EXTI_InitStruct->EXTI_Line) >> 5 ) * 0x20);
200 
201  /* Disable the selected external lines */
202  *(__IO uint32_t *) tmp &= ~(uint32_t)(1 << (EXTI_InitStruct->EXTI_Line & 0x1F));
203  }
204 
205 }
206 
213 void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct)
214 {
215  EXTI_InitStruct->EXTI_Line = EXTI_LINENONE;
216  EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt;
217  EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Rising_Falling;
218  EXTI_InitStruct->EXTI_LineCmd = DISABLE;
219 }
220 
228 void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line)
229 {
230  /* Check the parameters */
231  assert_param(IS_EXTI_LINE_EXT(EXTI_Line));
232 
233  *(__IO uint32_t *) (((uint32_t) &(EXTI->SWIER)) + ((EXTI_Line) >> 5 ) * 0x20) |= (uint32_t)(1 << (EXTI_Line & 0x1F));
234 
235 }
236 
262 FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line)
263 {
264  FlagStatus bitstatus = RESET;
265 
266  /* Check the parameters */
267  assert_param(IS_GET_EXTI_LINE(EXTI_Line));
268 
269  if ((*(__IO uint32_t *) (((uint32_t) &(EXTI->PR)) + ((EXTI_Line) >> 5 ) * 0x20)& (uint32_t)(1 << (EXTI_Line & 0x1F))) != (uint32_t)RESET)
270  {
271  bitstatus = SET;
272  }
273  else
274  {
275  bitstatus = RESET;
276  }
277  return bitstatus;
278 }
279 
286 void EXTI_ClearFlag(uint32_t EXTI_Line)
287 {
288  /* Check the parameters */
289  assert_param(IS_EXTI_LINE_EXT(EXTI_Line));
290 
291  *(__IO uint32_t *) (((uint32_t) &(EXTI->PR)) + ((EXTI_Line) >> 5 ) * 0x20) = (1 << (EXTI_Line & 0x1F));
292 }
293 
300 ITStatus EXTI_GetITStatus(uint32_t EXTI_Line)
301 {
302  ITStatus bitstatus = RESET;
303 
304  /* Check the parameters */
305  assert_param(IS_GET_EXTI_LINE(EXTI_Line));
306 
307  if ((*(__IO uint32_t *) (((uint32_t) &(EXTI->PR)) + ((EXTI_Line) >> 5 ) * 0x20)& (uint32_t)(1 << (EXTI_Line & 0x1F))) != (uint32_t)RESET)
308  {
309  bitstatus = SET;
310  }
311  else
312  {
313  bitstatus = RESET;
314  }
315  return bitstatus;
316 
317 }
318 
325 void EXTI_ClearITPendingBit(uint32_t EXTI_Line)
326 {
327  /* Check the parameters */
328  assert_param(IS_EXTI_LINE_EXT(EXTI_Line));
329 
330  *(__IO uint32_t *) (((uint32_t) &(EXTI->PR)) + ((EXTI_Line) >> 5 ) * 0x20) = (1 << (EXTI_Line & 0x1F));
331 }
332 
349 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
FunctionalState EXTI_LineCmd
FlagStatus
Definition: stm32f4xx.h:706
#define IS_EXTI_MODE(MODE)
EXTITrigger_TypeDef EXTI_Trigger
void EXTI_DeInit(void)
Deinitializes the EXTI peripheral registers to their default reset values.
#define IS_GET_EXTI_LINE(LINE)
EXTI Init Structure definition.
#define IS_EXTI_LINE_ALL(LINE)
#define EXTI_LINENONE
void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line)
Generates a Software interrupt on selected EXTI line.
#define IS_EXTI_LINE_EXT(LINE)
#define EXTI
Definition: stm32f4xx.h:2090
void assert_param(int val)
void EXTI_StructInit(EXTI_InitTypeDef *EXTI_InitStruct)
Fills each EXTI_InitStruct member with its reset value.
#define IS_FUNCTIONAL_STATE(STATE)
Definition: stm32f4xx.h:709
ITStatus EXTI_GetITStatus(uint32_t EXTI_Line)
Checks whether the specified EXTI line is asserted or not.
Definition: stm32f4xx.h:706
enum FlagStatus ITStatus
void EXTI_Init(EXTI_InitTypeDef *EXTI_InitStruct)
Initializes the EXTI peripheral according to the specified parameters in the EXTI_InitStruct. EXTI_Line specifies the EXTI line (EXTI0....EXTI35). EXTI_Mode specifies which EXTI line is used as interrupt or an event. EXTI_Trigger selects the trigger. When the trigger occurs, interrupt pending bit will be set. EXTI_LineCmd controls (Enable/Disable) the EXTI line.
FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line)
Checks whether the specified EXTI line flag is set or not.
#define __IO
Definition: core_cm0.h:198
EXTIMode_TypeDef EXTI_Mode
This file contains all the functions prototypes for the EXTI firmware library.
void EXTI_ClearFlag(uint32_t EXTI_Line)
Clears the EXTI&#39;s line pending flags.
#define IS_EXTI_TRIGGER(TRIGGER)
void EXTI_ClearITPendingBit(uint32_t EXTI_Line)
Clears the EXTI&#39;s line pending bits.
#define EXTI_BASE
Definition: stm32f4xx.h:1937


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Wed Jul 3 2019 19:59:25