My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lpc17xx_exti.c 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /**********************************************************************
  2. * $Id$ lpc17xx_exti.c 2010-06-18
  3. *//**
  4. * @file lpc17xx_exti.c
  5. * @brief Contains all functions support for External interrupt firmware
  6. * library on LPC17xx
  7. * @version 3.0
  8. * @date 18. June. 2010
  9. * @author NXP MCU SW Application Team
  10. *
  11. * Copyright(C) 2010, NXP Semiconductor
  12. * All rights reserved.
  13. *
  14. ***********************************************************************
  15. * Software that is described herein is for illustrative purposes only
  16. * which provides customers with programming information regarding the
  17. * products. This software is supplied "AS IS" without any warranties.
  18. * NXP Semiconductors assumes no responsibility or liability for the
  19. * use of the software, conveys no license or title under any patent,
  20. * copyright, or mask work right to the product. NXP Semiconductors
  21. * reserves the right to make changes in the software without
  22. * notification. NXP Semiconductors also make no representation or
  23. * warranty that such application will be suitable for the specified
  24. * use without further testing or modification.
  25. * Permission to use, copy, modify, and distribute this software and its
  26. * documentation is hereby granted, under NXP Semiconductors'
  27. * relevant copyright in the software, without fee, provided that it
  28. * is used in conjunction with NXP Semiconductors microcontrollers. This
  29. * copyright, permission, and disclaimer notice must appear in all copies of
  30. * this code.
  31. **********************************************************************/
  32. /* Peripheral group ----------------------------------------------------------- */
  33. /** @addtogroup EXTI
  34. * @{
  35. */
  36. /* Includes ------------------------------------------------------------------- */
  37. #include "lpc17xx_exti.h"
  38. /* If this source file built with example, the LPC17xx FW library configuration
  39. * file in each example directory ("lpc17xx_libcfg.h") must be included,
  40. * otherwise the default FW library configuration file must be included instead
  41. */
  42. #ifdef __BUILD_WITH_EXAMPLE__
  43. #include "lpc17xx_libcfg.h"
  44. #else
  45. #include "lpc17xx_libcfg_default.h"
  46. #endif /* __BUILD_WITH_EXAMPLE__ */
  47. #ifdef _EXTI
  48. /* Public Functions ----------------------------------------------------------- */
  49. /** @addtogroup EXTI_Public_Functions
  50. * @{
  51. */
  52. /*********************************************************************//**
  53. * @brief Initial for EXT
  54. * - Set EXTINT, EXTMODE, EXTPOLAR registers to default value
  55. * @param[in] None
  56. * @return None
  57. **********************************************************************/
  58. void EXTI_Init(void)
  59. {
  60. LPC_SC->EXTINT = 0xF;
  61. LPC_SC->EXTMODE = 0x0;
  62. LPC_SC->EXTPOLAR = 0x0;
  63. }
  64. /*********************************************************************//**
  65. * @brief Close EXT
  66. * @param[in] None
  67. * @return None
  68. **********************************************************************/
  69. void EXTI_DeInit(void)
  70. {
  71. ;
  72. }
  73. /*********************************************************************//**
  74. * @brief Configuration for EXT
  75. * - Set EXTINT, EXTMODE, EXTPOLAR register
  76. * @param[in] EXTICfg Pointer to a EXTI_InitTypeDef structure
  77. * that contains the configuration information for the
  78. * specified external interrupt
  79. * @return None
  80. **********************************************************************/
  81. void EXTI_Config(EXTI_InitTypeDef *EXTICfg)
  82. {
  83. LPC_SC->EXTINT = 0x0;
  84. EXTI_SetMode(EXTICfg->EXTI_Line, EXTICfg->EXTI_Mode);
  85. EXTI_SetPolarity(EXTICfg->EXTI_Line, EXTICfg->EXTI_polarity);
  86. }
  87. /*********************************************************************//**
  88. * @brief Set mode for EXTI pin
  89. * @param[in] EXTILine external interrupt line, should be:
  90. * - EXTI_EINT0: external interrupt line 0
  91. * - EXTI_EINT1: external interrupt line 1
  92. * - EXTI_EINT2: external interrupt line 2
  93. * - EXTI_EINT3: external interrupt line 3
  94. * @param[in] mode external mode, should be:
  95. * - EXTI_MODE_LEVEL_SENSITIVE
  96. * - EXTI_MODE_EDGE_SENSITIVE
  97. * @return None
  98. *********************************************************************/
  99. void EXTI_SetMode(EXTI_LINE_ENUM EXTILine, EXTI_MODE_ENUM mode)
  100. {
  101. if(mode == EXTI_MODE_EDGE_SENSITIVE)
  102. {
  103. LPC_SC->EXTMODE |= (1 << EXTILine);
  104. }
  105. else if(mode == EXTI_MODE_LEVEL_SENSITIVE)
  106. {
  107. LPC_SC->EXTMODE &= ~(1 << EXTILine);
  108. }
  109. }
  110. /*********************************************************************//**
  111. * @brief Set polarity for EXTI pin
  112. * @param[in] EXTILine external interrupt line, should be:
  113. * - EXTI_EINT0: external interrupt line 0
  114. * - EXTI_EINT1: external interrupt line 1
  115. * - EXTI_EINT2: external interrupt line 2
  116. * - EXTI_EINT3: external interrupt line 3
  117. * @param[in] polarity external polarity value, should be:
  118. * - EXTI_POLARITY_LOW_ACTIVE_OR_FALLING_EDGE
  119. * - EXTI_POLARITY_LOW_ACTIVE_OR_FALLING_EDGE
  120. * @return None
  121. *********************************************************************/
  122. void EXTI_SetPolarity(EXTI_LINE_ENUM EXTILine, EXTI_POLARITY_ENUM polarity)
  123. {
  124. if(polarity == EXTI_POLARITY_HIGH_ACTIVE_OR_RISING_EDGE)
  125. {
  126. LPC_SC->EXTPOLAR |= (1 << EXTILine);
  127. }
  128. else if(polarity == EXTI_POLARITY_LOW_ACTIVE_OR_FALLING_EDGE)
  129. {
  130. LPC_SC->EXTPOLAR &= ~(1 << EXTILine);
  131. }
  132. }
  133. /*********************************************************************//**
  134. * @brief Clear External interrupt flag
  135. * @param[in] EXTILine external interrupt line, should be:
  136. * - EXTI_EINT0: external interrupt line 0
  137. * - EXTI_EINT1: external interrupt line 1
  138. * - EXTI_EINT2: external interrupt line 2
  139. * - EXTI_EINT3: external interrupt line 3
  140. * @return None
  141. *********************************************************************/
  142. void EXTI_ClearEXTIFlag(EXTI_LINE_ENUM EXTILine)
  143. {
  144. LPC_SC->EXTINT = (1 << EXTILine);
  145. }
  146. /**
  147. * @}
  148. */
  149. #endif /* _EXTI */
  150. /**
  151. * @}
  152. */
  153. /* --------------------------------- End Of File ------------------------------ */