uc-sdk
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
lpc17xx_exti.c
Go to the documentation of this file.
1 
20 /* Peripheral group ----------------------------------------------------------- */
25 /* Includes ------------------------------------------------------------------- */
26 #include "lpc17xx_exti.h"
27 
28 /* If this source file built with example, the LPC17xx FW library configuration
29  * file in each example directory ("lpc17xx_libcfg.h") must be included,
30  * otherwise the default FW library configuration file must be included instead
31  */
32 #ifdef __BUILD_WITH_EXAMPLE__
33 #include "lpc17xx_libcfg.h"
34 #else
35 #include "lpc17xx_libcfg_default.h"
36 #endif /* __BUILD_WITH_EXAMPLE__ */
37 
38 
39 #ifdef _EXTI
40 
41 /* Public Functions ----------------------------------------------------------- */
46 /*********************************************************************/
52 void EXTI_Init(void)
53 {
54  LPC_SC->EXTINT = 0xF;
55  LPC_SC->EXTMODE = 0x0;
56  LPC_SC->EXTPOLAR = 0x0;
57 }
58 
59 
60 /*********************************************************************/
65 void EXTI_DeInit(void)
66 {
67  ;
68 }
69 
70 /*********************************************************************/
78 void EXTI_Config(EXTI_InitTypeDef *EXTICfg)
79 {
80  LPC_SC->EXTINT = 0x0;
81  EXTI_SetMode(EXTICfg->EXTI_Line, EXTICfg->EXTI_Mode);
82  EXTI_SetPolarity(EXTICfg->EXTI_Line, EXTICfg->EXTI_polarity);
83 }
84 
85 /*********************************************************************/
97 void EXTI_SetMode(EXTI_LINE_ENUM EXTILine, EXTI_MODE_ENUM mode)
98 {
99  if(mode == EXTI_MODE_EDGE_SENSITIVE)
100  {
101  LPC_SC->EXTMODE |= (1 << EXTILine);
102  }
103  else if(mode == EXTI_MODE_LEVEL_SENSITIVE)
104  {
105  LPC_SC->EXTMODE &= ~(1 << EXTILine);
106  }
107 }
108 
109 /*********************************************************************/
121 void EXTI_SetPolarity(EXTI_LINE_ENUM EXTILine, EXTI_POLARITY_ENUM polarity)
122 {
124  {
125  LPC_SC->EXTPOLAR |= (1 << EXTILine);
126  }
127  else if(polarity == EXTI_POLARITY_LOW_ACTIVE_OR_FALLING_EDGE)
128  {
129  LPC_SC->EXTPOLAR &= ~(1 << EXTILine);
130  }
131 }
132 
133 /*********************************************************************/
142 void EXTI_ClearEXTIFlag(EXTI_LINE_ENUM EXTILine)
143 {
144  LPC_SC->EXTINT |= (1 << EXTILine);
145 }
146 
151 #endif /* _EXTI */
152 
157 /* --------------------------------- End Of File ------------------------------ */
158