stm32f4xx_exti.c
Go to the documentation of this file.
1 
67 /* Includes ------------------------------------------------------------------*/
68 #include "stm32f4xx_exti.h"
69 
79 /* Private typedef -----------------------------------------------------------*/
80 /* Private define ------------------------------------------------------------*/
81 
82 #define EXTI_LINENONE ((uint32_t)0x00000) /* No interrupt selected */
83 
84 /* Private macro -------------------------------------------------------------*/
85 /* Private variables ---------------------------------------------------------*/
86 /* Private function prototypes -----------------------------------------------*/
87 /* Private functions ---------------------------------------------------------*/
88 
110 void EXTI_DeInit(void)
111 {
112  EXTI->IMR = 0x00000000;
113  EXTI->EMR = 0x00000000;
114  EXTI->RTSR = 0x00000000;
115  EXTI->FTSR = 0x00000000;
116  EXTI->PR = 0x007FFFFF;
117 }
118 
126 void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct)
127 {
128  uint32_t tmp = 0;
129 
130  /* Check the parameters */
131  assert_param(IS_EXTI_MODE(EXTI_InitStruct->EXTI_Mode));
132  assert_param(IS_EXTI_TRIGGER(EXTI_InitStruct->EXTI_Trigger));
133  assert_param(IS_EXTI_LINE(EXTI_InitStruct->EXTI_Line));
134  assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->EXTI_LineCmd));
135 
136  tmp = (uint32_t)EXTI_BASE;
137 
138  if (EXTI_InitStruct->EXTI_LineCmd != DISABLE)
139  {
140  /* Clear EXTI line configuration */
141  EXTI->IMR &= ~EXTI_InitStruct->EXTI_Line;
142  EXTI->EMR &= ~EXTI_InitStruct->EXTI_Line;
143 
144  tmp += EXTI_InitStruct->EXTI_Mode;
145 
146  *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line;
147 
148  /* Clear Rising Falling edge configuration */
149  EXTI->RTSR &= ~EXTI_InitStruct->EXTI_Line;
150  EXTI->FTSR &= ~EXTI_InitStruct->EXTI_Line;
151 
152  /* Select the trigger for the selected external interrupts */
153  if (EXTI_InitStruct->EXTI_Trigger == EXTI_Trigger_Rising_Falling)
154  {
155  /* Rising Falling edge */
156  EXTI->RTSR |= EXTI_InitStruct->EXTI_Line;
157  EXTI->FTSR |= EXTI_InitStruct->EXTI_Line;
158  }
159  else
160  {
161  tmp = (uint32_t)EXTI_BASE;
162  tmp += EXTI_InitStruct->EXTI_Trigger;
163 
164  *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line;
165  }
166  }
167  else
168  {
169  tmp += EXTI_InitStruct->EXTI_Mode;
170 
171  /* Disable the selected external lines */
172  *(__IO uint32_t *) tmp &= ~EXTI_InitStruct->EXTI_Line;
173  }
174 }
175 
182 void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct)
183 {
184  EXTI_InitStruct->EXTI_Line = EXTI_LINENONE;
185  EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt;
186  EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Falling;
187  EXTI_InitStruct->EXTI_LineCmd = DISABLE;
188 }
189 
197 void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line)
198 {
199  /* Check the parameters */
200  assert_param(IS_EXTI_LINE(EXTI_Line));
201 
202  EXTI->SWIER |= EXTI_Line;
203 }
204 
227 FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line)
228 {
229  FlagStatus bitstatus = RESET;
230  /* Check the parameters */
231  assert_param(IS_GET_EXTI_LINE(EXTI_Line));
232 
233  if ((EXTI->PR & EXTI_Line) != (uint32_t)RESET)
234  {
235  bitstatus = SET;
236  }
237  else
238  {
239  bitstatus = RESET;
240  }
241  return bitstatus;
242 }
243 
250 void EXTI_ClearFlag(uint32_t EXTI_Line)
251 {
252  /* Check the parameters */
253  assert_param(IS_EXTI_LINE(EXTI_Line));
254 
255  EXTI->PR = EXTI_Line;
256 }
257 
264 ITStatus EXTI_GetITStatus(uint32_t EXTI_Line)
265 {
266  ITStatus bitstatus = RESET;
267  uint32_t enablestatus = 0;
268  /* Check the parameters */
269  assert_param(IS_GET_EXTI_LINE(EXTI_Line));
270 
271  enablestatus = EXTI->IMR & EXTI_Line;
272  if (((EXTI->PR & EXTI_Line) != (uint32_t)RESET) && (enablestatus != (uint32_t)RESET))
273  {
274  bitstatus = SET;
275  }
276  else
277  {
278  bitstatus = RESET;
279  }
280  return bitstatus;
281 }
282 
289 void EXTI_ClearITPendingBit(uint32_t EXTI_Line)
290 {
291  /* Check the parameters */
292  assert_param(IS_EXTI_LINE(EXTI_Line));
293 
294  EXTI->PR = EXTI_Line;
295 }
296 
313 /************************ (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_ClearITPendingBit(uint32_t EXTI_Line)
Clears the EXTI's line pending bits.
#define IS_GET_EXTI_LINE(LINE)
EXTI Init Structure definition.
#define EXTI_LINENONE
void EXTI_StructInit(EXTI_InitTypeDef *EXTI_InitStruct)
Fills each EXTI_InitStruct member with its reset value.
void EXTI_DeInit(void)
Deinitializes the EXTI peripheral registers to their default reset values.
FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line)
Checks whether the specified EXTI line flag is set or not.
#define EXTI
Definition: stm32f4xx.h:2090
void assert_param(int val)
#define IS_FUNCTIONAL_STATE(STATE)
Definition: stm32f4xx.h:709
void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line)
Generates a Software interrupt on selected EXTI line.
void EXTI_ClearFlag(uint32_t EXTI_Line)
Clears the EXTI's line pending flags.
Definition: stm32f4xx.h:706
enum FlagStatus ITStatus
#define IS_EXTI_LINE(LINE)
#define __IO
Definition: core_cm0.h:198
EXTIMode_TypeDef EXTI_Mode
ITStatus EXTI_GetITStatus(uint32_t EXTI_Line)
Checks whether the specified EXTI line is asserted or not.
#define IS_EXTI_TRIGGER(TRIGGER)
void EXTI_Init(EXTI_InitTypeDef *EXTI_InitStruct)
Initializes the EXTI peripheral according to the specified parameters in the EXTI_InitStruct.
This file contains all the functions prototypes for the EXTI firmware library.
#define EXTI_BASE
Definition: stm32f4xx.h:1937


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