stm32f10x_exti.c
Go to the documentation of this file.
1 
22 /* Includes ------------------------------------------------------------------*/
23 #include "stm32f10x_exti.h"
24 
46 #define EXTI_LINENONE ((uint32_t)0x00000) /* No interrupt selected */
47 
85 void EXTI_DeInit(void)
86 {
87  EXTI->IMR = 0x00000000;
88  EXTI->EMR = 0x00000000;
89  EXTI->RTSR = 0x00000000;
90  EXTI->FTSR = 0x00000000;
91  EXTI->PR = 0x000FFFFF;
92 }
93 
101 void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct)
102 {
103  uint32_t tmp = 0;
104 
105  /* Check the parameters */
106  assert_param(IS_EXTI_MODE(EXTI_InitStruct->EXTI_Mode));
107  assert_param(IS_EXTI_TRIGGER(EXTI_InitStruct->EXTI_Trigger));
108  assert_param(IS_EXTI_LINE(EXTI_InitStruct->EXTI_Line));
109  assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->EXTI_LineCmd));
110 
111  tmp = (uint32_t)EXTI_BASE;
112 
113  if (EXTI_InitStruct->EXTI_LineCmd != DISABLE)
114  {
115  /* Clear EXTI line configuration */
116  EXTI->IMR &= ~EXTI_InitStruct->EXTI_Line;
117  EXTI->EMR &= ~EXTI_InitStruct->EXTI_Line;
118 
119  tmp += EXTI_InitStruct->EXTI_Mode;
120 
121  *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line;
122 
123  /* Clear Rising Falling edge configuration */
124  EXTI->RTSR &= ~EXTI_InitStruct->EXTI_Line;
125  EXTI->FTSR &= ~EXTI_InitStruct->EXTI_Line;
126 
127  /* Select the trigger for the selected external interrupts */
128  if (EXTI_InitStruct->EXTI_Trigger == EXTI_Trigger_Rising_Falling)
129  {
130  /* Rising Falling edge */
131  EXTI->RTSR |= EXTI_InitStruct->EXTI_Line;
132  EXTI->FTSR |= EXTI_InitStruct->EXTI_Line;
133  }
134  else
135  {
136  tmp = (uint32_t)EXTI_BASE;
137  tmp += EXTI_InitStruct->EXTI_Trigger;
138 
139  *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line;
140  }
141  }
142  else
143  {
144  tmp += EXTI_InitStruct->EXTI_Mode;
145 
146  /* Disable the selected external lines */
147  *(__IO uint32_t *) tmp &= ~EXTI_InitStruct->EXTI_Line;
148  }
149 }
150 
157 void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct)
158 {
159  EXTI_InitStruct->EXTI_Line = EXTI_LINENONE;
160  EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt;
161  EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Falling;
162  EXTI_InitStruct->EXTI_LineCmd = DISABLE;
163 }
164 
171 void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line)
172 {
173  /* Check the parameters */
174  assert_param(IS_EXTI_LINE(EXTI_Line));
175 
176  EXTI->SWIER |= EXTI_Line;
177 }
178 
186 FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line)
187 {
188  FlagStatus bitstatus = RESET;
189  /* Check the parameters */
190  assert_param(IS_GET_EXTI_LINE(EXTI_Line));
191 
192  if ((EXTI->PR & EXTI_Line) != (uint32_t)RESET)
193  {
194  bitstatus = SET;
195  }
196  else
197  {
198  bitstatus = RESET;
199  }
200  return bitstatus;
201 }
202 
209 void EXTI_ClearFlag(uint32_t EXTI_Line)
210 {
211  /* Check the parameters */
212  assert_param(IS_EXTI_LINE(EXTI_Line));
213 
214  EXTI->PR = EXTI_Line;
215 }
216 
224 ITStatus EXTI_GetITStatus(uint32_t EXTI_Line)
225 {
226  ITStatus bitstatus = RESET;
227  uint32_t enablestatus = 0;
228  /* Check the parameters */
229  assert_param(IS_GET_EXTI_LINE(EXTI_Line));
230 
231  enablestatus = EXTI->IMR & EXTI_Line;
232  if (((EXTI->PR & EXTI_Line) != (uint32_t)RESET) && (enablestatus != (uint32_t)RESET))
233  {
234  bitstatus = SET;
235  }
236  else
237  {
238  bitstatus = RESET;
239  }
240  return bitstatus;
241 }
242 
249 void EXTI_ClearITPendingBit(uint32_t EXTI_Line)
250 {
251  /* Check the parameters */
252  assert_param(IS_EXTI_LINE(EXTI_Line));
253 
254  EXTI->PR = EXTI_Line;
255 }
256 
269 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
FunctionalState EXTI_LineCmd
FlagStatus
Definition: stm32f4xx.h:706
#define IS_EXTI_MODE(MODE)
EXTITrigger_TypeDef EXTI_Trigger
void EXTI_Init(EXTI_InitTypeDef *EXTI_InitStruct)
Initializes the EXTI peripheral according to the specified parameters in the EXTI_InitStruct.
#define IS_GET_EXTI_LINE(LINE)
EXTI Init Structure definition.
#define EXTI
Definition: stm32f4xx.h:2090
void assert_param(int val)
#define EXTI_LINENONE
void EXTI_ClearFlag(uint32_t EXTI_Line)
Clears the EXTI's line pending flags.
#define IS_FUNCTIONAL_STATE(STATE)
Definition: stm32f4xx.h:709
void EXTI_StructInit(EXTI_InitTypeDef *EXTI_InitStruct)
Fills each EXTI_InitStruct member with its reset value.
Definition: stm32f4xx.h:706
void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line)
Generates a Software interrupt.
This file contains all the functions prototypes for the EXTI firmware library.
FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line)
Checks whether the specified EXTI line flag is set or not.
enum FlagStatus ITStatus
#define IS_EXTI_LINE(LINE)
#define __IO
Definition: core_cm0.h:198
EXTIMode_TypeDef EXTI_Mode
#define IS_EXTI_TRIGGER(TRIGGER)
ITStatus EXTI_GetITStatus(uint32_t EXTI_Line)
Checks whether the specified EXTI line is asserted or not.
void EXTI_ClearITPendingBit(uint32_t EXTI_Line)
Clears the EXTI's line pending bits.
void EXTI_DeInit(void)
Deinitializes the EXTI peripheral registers to their default reset values.
#define EXTI_BASE
Definition: stm32f4xx.h:1937


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