lpc177x_8x_clkpwr.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /**********************************************************************
  2. * $Id$ lpc177x_8x_clkpwr.h 2011-06-02
  3. *//**
  4. * @file lpc177x_8x_clkpwr.h
  5. * @brief Contains all macro definitions and function prototypes
  6. * support for Clock and Power Control firmware library on
  7. * LPC177x_8x
  8. * @version 1.0
  9. * @date 02. June. 2011
  10. * @author NXP MCU SW Application Team
  11. *
  12. * Copyright(C) 2011, NXP Semiconductor
  13. * All rights reserved.
  14. *
  15. ***********************************************************************
  16. * Software that is described herein is for illustrative purposes only
  17. * which provides customers with programming information regarding the
  18. * products. This software is supplied "AS IS" without any warranties.
  19. * NXP Semiconductors assumes no responsibility or liability for the
  20. * use of the software, conveys no license or title under any patent,
  21. * copyright, or mask work right to the product. NXP Semiconductors
  22. * reserves the right to make changes in the software without
  23. * notification. NXP Semiconductors also make no representation or
  24. * warranty that such application will be suitable for the specified
  25. * use without further testing or modification.
  26. **********************************************************************/
  27. /* Peripheral group ----------------------------------------------------------- */
  28. /** @defgroup CLKPWR Clock Power
  29. * @ingroup LPC177x_8xCMSIS_FwLib_Drivers
  30. * @{
  31. */
  32. #ifndef __LPC177X_8X_CLKPWR_H_
  33. #define __LPC177X_8X_CLKPWR_H_
  34. /* Includes ------------------------------------------------------------------- */
  35. #include "LPC177x_8x.h"
  36. #include "lpc_types.h"
  37. #include "system_LPC177x_8x.h"
  38. #ifdef __cplusplus
  39. extern "C"
  40. {
  41. #endif
  42. /* Public Macros -------------------------------------------------------------- */
  43. /** @defgroup CLKPWR_Public_Macros CLKPWR Public Macros
  44. * @{
  45. */
  46. /********************************************************************
  47. * Clock Source Selection Definitions
  48. **********************************************************************/
  49. #define CLKPWR_CLKSRCSEL_IRCOSC ((uint32_t)(0))
  50. #define CLKPWR_CLKSRCSEL_MAINOSC ((uint32_t)(1))
  51. /********************************************************************
  52. * Clock type/domain Definitions (calculated from input and pre-configuration
  53. * parameter(s)
  54. **********************************************************************/
  55. #define CLKPWR_CLKTYPE_CPU ((uint32_t)(0))
  56. #define CLKPWR_CLKTYPE_PER ((uint32_t)(1))
  57. #define CLKPWR_CLKTYPE_EMC ((uint32_t)(2))
  58. #define CLKPWR_CLKTYPE_USB ((uint32_t)(3))
  59. /********************************************************************
  60. * Power Control for Peripherals Definitions
  61. **********************************************************************/
  62. /** LCD controller power/clock control bit */
  63. #define CLKPWR_PCONP_PCLCD ((uint32_t)(1<<0))
  64. /** Timer/Counter 0 power/clock control bit */
  65. #define CLKPWR_PCONP_PCTIM0 ((uint32_t)(1<<1))
  66. /* Timer/Counter 1 power/clock control bit */
  67. #define CLKPWR_PCONP_PCTIM1 ((uint32_t)(1<<2))
  68. /** UART0 power/clock control bit */
  69. #define CLKPWR_PCONP_PCUART0 ((uint32_t)(1<<3))
  70. /** UART1 power/clock control bit */
  71. #define CLKPWR_PCONP_PCUART1 ((uint32_t)(1<<4))
  72. /** PWM0 power/clock control bit */
  73. #define CLKPWR_PCONP_PCPWM0 ((uint32_t)(1<<5))
  74. /** PWM1 power/clock control bit */
  75. #define CLKPWR_PCONP_PCPWM1 ((uint32_t)(1<<6))
  76. /** The I2C0 interface power/clock control bit */
  77. #define CLKPWR_PCONP_PCI2C0 ((uint32_t)(1<<7))
  78. /** UART4 power/clock control bit */
  79. #define CLKPWR_PCONP_PCUART4 ((uint32_t)(1<<8))
  80. /** The RTC power/clock control bit */
  81. #define CLKPWR_PCONP_PCRTC ((uint32_t)(1<<9))
  82. /** The SSP1 interface power/clock control bit */
  83. #define CLKPWR_PCONP_PCSSP1 ((uint32_t)(1<<10))
  84. /** External Memory controller power/clock control bit */
  85. #define CLKPWR_PCONP_PCEMC ((uint32_t)(1<<11))
  86. /** A/D converter 0 (ADC0) power/clock control bit */
  87. #define CLKPWR_PCONP_PCADC ((uint32_t)(1<<12))
  88. /** CAN Controller 1 power/clock control bit */
  89. #define CLKPWR_PCONP_PCAN1 ((uint32_t)(1<<13))
  90. /** CAN Controller 2 power/clock control bit */
  91. #define CLKPWR_PCONP_PCAN2 ((uint32_t)(1<<14))
  92. /** GPIO power/clock control bit */
  93. #define CLKPWR_PCONP_PCGPIO ((uint32_t)(1<<15))
  94. /** Motor Control PWM */
  95. #define CLKPWR_PCONP_PCMCPWM ((uint32_t)(1<<17))
  96. /** Quadrature Encoder Interface power/clock control bit */
  97. #define CLKPWR_PCONP_PCQEI ((uint32_t)(1<<18))
  98. /** The I2C1 interface power/clock control bit */
  99. #define CLKPWR_PCONP_PCI2C1 ((uint32_t)(1<<19))
  100. /** The SSP2 interface power/clock control bit */
  101. #define CLKPWR_PCONP_PCSSP2 ((uint32_t)(1<<20))
  102. /** The SSP0 interface power/clock control bit */
  103. #define CLKPWR_PCONP_PCSSP0 ((uint32_t)(1<<21))
  104. /** Timer 2 power/clock control bit */
  105. #define CLKPWR_PCONP_PCTIM2 ((uint32_t)(1<<22))
  106. /** Timer 3 power/clock control bit */
  107. #define CLKPWR_PCONP_PCTIM3 ((uint32_t)(1<<23))
  108. /** UART 2 power/clock control bit */
  109. #define CLKPWR_PCONP_PCUART2 ((uint32_t)(1<<24))
  110. /** UART 3 power/clock control bit */
  111. #define CLKPWR_PCONP_PCUART3 ((uint32_t)(1<<25))
  112. /** I2C interface 2 power/clock control bit */
  113. #define CLKPWR_PCONP_PCI2C2 ((uint32_t)(1<<26))
  114. /** I2S interface power/clock control bit*/
  115. #define CLKPWR_PCONP_PCI2S ((uint32_t)(1<<27))
  116. /** SD card interface power/clock control bit */
  117. #define CLKPWR_PCONP_PCSDC ((uint32_t)(1<<28))
  118. /** GP DMA function power/clock control bit*/
  119. #define CLKPWR_PCONP_PCGPDMA ((uint32_t)(1<<29))
  120. /** Ethernet block power/clock control bit*/
  121. #define CLKPWR_PCONP_PCENET ((uint32_t)(1<<30))
  122. /** USB interface power/clock control bit*/
  123. #define CLKPWR_PCONP_PCUSB ((uint32_t)(1<<31))
  124. /********************************************************************
  125. * Power Control for Peripherals Definitions
  126. **********************************************************************/
  127. #define CLKPWR_RSTCON0_LCD ((uint32_t)(0))
  128. #define CLKPWR_RSTCON0_TIM0 ((uint32_t)(1))
  129. #define CLKPWR_RSTCON0_TIM1 ((uint32_t)(2))
  130. #define CLKPWR_RSTCON0_UART0 ((uint32_t)(3))
  131. #define CLKPWR_RSTCON0_UART1 ((uint32_t)(4))
  132. #define CLKPWR_RSTCON0_PWM0 ((uint32_t)(5))
  133. #define CLKPWR_RSTCON0_PWM1 ((uint32_t)(6))
  134. #define CLKPWR_RSTCON0_I2C0 ((uint32_t)(7))
  135. #define CLKPWR_RSTCON0_UART4 ((uint32_t)(8))
  136. #define CLKPWR_RSTCON0_RTC ((uint32_t)(9))
  137. #define CLKPWR_RSTCON0_SSP1 ((uint32_t)(10))
  138. #define CLKPWR_RSTCON0_EMC ((uint32_t)(11))
  139. #define CLKPWR_RSTCON0_ADC ((uint32_t)(12))
  140. #define CLKPWR_RSTCON0_CAN1 ((uint32_t)(13))
  141. #define CLKPWR_RSTCON0_CAN2 ((uint32_t)(14))
  142. #define CLKPWR_RSTCON0_GPIO ((uint32_t)(15))
  143. #define CLKPWR_RSTCON0_MCPWM ((uint32_t)(17))
  144. #define CLKPWR_RSTCON0_QEI ((uint32_t)(18))
  145. #define CLKPWR_RSTCON0_I2C1 ((uint32_t)(19))
  146. #define CLKPWR_RSTCON0_SSP2 ((uint32_t)(20))
  147. #define CLKPWR_RSTCON0_SSP0 ((uint32_t)(21))
  148. #define CLKPWR_RSTCON0_TIM2 ((uint32_t)(22))
  149. #define CLKPWR_RSTCON0_TIM3 ((uint32_t)(23))
  150. #define CLKPWR_RSTCON0_UART2 ((uint32_t)(24))
  151. #define CLKPWR_RSTCON0_UART3 ((uint32_t)(25))
  152. #define CLKPWR_RSTCON0_I2C2 ((uint32_t)(26))
  153. #define CLKPWR_RSTCON0_I2S ((uint32_t)(27))
  154. #define CLKPWR_RSTCON0_SDC ((uint32_t)(28))
  155. #define CLKPWR_RSTCON0_GPDMA ((uint32_t)(29))
  156. #define CLKPWR_RSTCON0_ENET ((uint32_t)(30))
  157. #define CLKPWR_RSTCON0_USB ((uint32_t)(31))
  158. #define CLKPWR_RSTCON1_IOCON ((uint32_t)(32))
  159. #define CLKPWR_RSTCON1_DAC ((uint32_t)(33))
  160. #define CLKPWR_RSTCON1_CANACC ((uint32_t)(34))
  161. /**
  162. * @}
  163. */
  164. /* External clock variable from system_LPC177x_8x.h */
  165. extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
  166. extern uint32_t PeripheralClock; /*!< Peripheral Clock Frequency (Pclk) */
  167. extern uint32_t EMCClock; /*!< EMC Clock Frequency */
  168. /* External clock variable from lpc177x_8x_clkpwr.h */
  169. extern uint32_t USBClock; /*!< USB Frequency */
  170. /* Public Functions ----------------------------------------------------------- */
  171. /** @defgroup CLKPWR_Public_Functions CLKPWR Public Functions
  172. * @{
  173. */
  174. void CLKPWR_SetCLKDiv(uint8_t ClkType, uint8_t DivVal);
  175. uint32_t CLKPWR_GetCLK(uint8_t ClkType);
  176. void CLKPWR_ConfigPPWR(uint32_t PPType, FunctionalState NewState);
  177. void CLKPWR_ConfigReset(uint8_t PType, FunctionalState NewState);
  178. void CLKPWR_Sleep(void);
  179. void CLKPWR_DeepSleep(void);
  180. void CLKPWR_PowerDown(void);
  181. void CLKPWR_DeepPowerDown(void);
  182. /**
  183. * @}
  184. */
  185. #ifdef __cplusplus
  186. }
  187. #endif
  188. #endif /* __LPC177X_8X_CLKPWR_H_ */
  189. /**
  190. * @}
  191. */
  192. /* --------------------------------- End Of File ------------------------------ */