CARME-M4 BSP  V1.5
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  FlagStatus bitstatus = RESET;
267  /* Check the parameters */
268  assert_param(IS_GET_EXTI_LINE(EXTI_Line));
269 
270  if ((EXTI->PR & EXTI_Line) != (uint32_t)RESET)
271  {
272  bitstatus = SET;
273  }
274  else
275  {
276  bitstatus = RESET;
277  }
278  return bitstatus;
279 
280 }
281 
288 void EXTI_ClearITPendingBit(uint32_t EXTI_Line)
289 {
290  /* Check the parameters */
291  assert_param(IS_EXTI_LINE(EXTI_Line));
292 
293  EXTI->PR = EXTI_Line;
294 }
295 
312 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
void EXTI_Init(EXTI_InitTypeDef *EXTI_InitStruct)
Initializes the EXTI peripheral according to the specified parameters in the EXTI_InitStruct.
void EXTI_StructInit(EXTI_InitTypeDef *EXTI_InitStruct)
Fills each EXTI_InitStruct member with its reset value.
ITStatus EXTI_GetITStatus(uint32_t EXTI_Line)
Checks whether the specified EXTI line is asserted or not.
EXTIMode_TypeDef EXTI_Mode
void EXTI_DeInit(void)
Deinitializes the EXTI peripheral registers to their default reset values.
EXTI Init Structure definition.
void EXTI_ClearFlag(uint32_t EXTI_Line)
Clears the EXTI's line pending flags.
FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line)
Checks whether the specified EXTI line flag is set or not.
void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line)
Generates a Software interrupt on selected EXTI line.
EXTITrigger_TypeDef EXTI_Trigger
This file contains all the functions prototypes for the EXTI firmware library.
void EXTI_ClearITPendingBit(uint32_t EXTI_Line)
Clears the EXTI's line pending bits.
FunctionalState EXTI_LineCmd