1
0

lpc_clkpwr.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /**********************************************************************
  2. * $Id$ lpc_clkpwr.h 2011-06-02
  3. *//**
  4. * @file lpc_clkpwr.h
  5. * @brief Contains all macro definitions and function prototypes
  6. * support for Clock and Power Control firmware library on
  7. * LPC
  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. * Permission to use, copy, modify, and distribute this software and its
  27. * documentation is hereby granted, under NXP Semiconductors'
  28. * relevant copyright in the software, without fee, provided that it
  29. * is used in conjunction with NXP Semiconductors microcontrollers. This
  30. * copyright, permission, and disclaimer notice must appear in all copies of
  31. * this code.
  32. **********************************************************************/
  33. /* Peripheral group ----------------------------------------------------------- */
  34. /** @defgroup CLKPWR CLKPWR (Clock Power)
  35. * @ingroup LPC_CMSIS_FwLib_Drivers
  36. * @{
  37. */
  38. #ifndef __LPC_CLKPWR_H_
  39. #define __LPC_CLKPWR_H_
  40. /* Includes ------------------------------------------------------------------- */
  41. #include "LPC407x_8x_177x_8x.h"
  42. #include "lpc_types.h"
  43. #include "system_LPC407x_8x_177x_8x.h"
  44. #ifdef __cplusplus
  45. extern "C"
  46. {
  47. #endif
  48. /* Public Macros -------------------------------------------------------------- */
  49. /** @defgroup CLKPWR_Public_Macros CLKPWR Public Macros
  50. * @{
  51. */
  52. /********************************************************************
  53. * Clock Source Selection Definitions
  54. **********************************************************************/
  55. #define CLKPWR_CLKSRCSEL_IRCOSC ((uint32_t)(0))
  56. #define CLKPWR_CLKSRCSEL_MAINOSC ((uint32_t)(1))
  57. /********************************************************************
  58. * Clock type/domain Definitions (calculated from input and pre-configuration
  59. * parameter(s)
  60. **********************************************************************/
  61. #define CLKPWR_CLKTYPE_CPU ((uint32_t)(0))
  62. #define CLKPWR_CLKTYPE_PER ((uint32_t)(1))
  63. #define CLKPWR_CLKTYPE_EMC ((uint32_t)(2))
  64. #define CLKPWR_CLKTYPE_USB ((uint32_t)(3))
  65. /********************************************************************
  66. * Power Control for Peripherals Definitions
  67. **********************************************************************/
  68. /** LCD controller power/clock control bit */
  69. #define CLKPWR_PCONP_PCLCD ((uint32_t)(1<<0))
  70. /** Timer/Counter 0 power/clock control bit */
  71. #define CLKPWR_PCONP_PCTIM0 ((uint32_t)(1<<1))
  72. /* Timer/Counter 1 power/clock control bit */
  73. #define CLKPWR_PCONP_PCTIM1 ((uint32_t)(1<<2))
  74. /** UART0 power/clock control bit */
  75. #define CLKPWR_PCONP_PCUART0 ((uint32_t)(1<<3))
  76. /** UART1 power/clock control bit */
  77. #define CLKPWR_PCONP_PCUART1 ((uint32_t)(1<<4))
  78. /** PWM0 power/clock control bit */
  79. #define CLKPWR_PCONP_PCPWM0 ((uint32_t)(1<<5))
  80. /** PWM1 power/clock control bit */
  81. #define CLKPWR_PCONP_PCPWM1 ((uint32_t)(1<<6))
  82. /** The I2C0 interface power/clock control bit */
  83. #define CLKPWR_PCONP_PCI2C0 ((uint32_t)(1<<7))
  84. /** UART4 power/clock control bit */
  85. #define CLKPWR_PCONP_PCUART4 ((uint32_t)(1<<8))
  86. /** The RTC power/clock control bit */
  87. #define CLKPWR_PCONP_PCRTC ((uint32_t)(1<<9))
  88. /** The SSP1 interface power/clock control bit */
  89. #define CLKPWR_PCONP_PCSSP1 ((uint32_t)(1<<10))
  90. /** External Memory controller power/clock control bit */
  91. #define CLKPWR_PCONP_PCEMC ((uint32_t)(1<<11))
  92. /** A/D converter 0 (ADC0) power/clock control bit */
  93. #define CLKPWR_PCONP_PCADC ((uint32_t)(1<<12))
  94. /** CAN Controller 1 power/clock control bit */
  95. #define CLKPWR_PCONP_PCAN1 ((uint32_t)(1<<13))
  96. /** CAN Controller 2 power/clock control bit */
  97. #define CLKPWR_PCONP_PCAN2 ((uint32_t)(1<<14))
  98. /** GPIO power/clock control bit */
  99. #define CLKPWR_PCONP_PCGPIO ((uint32_t)(1<<15))
  100. /** Motor Control PWM */
  101. #define CLKPWR_PCONP_PCMCPWM ((uint32_t)(1<<17))
  102. /** Quadrature Encoder Interface power/clock control bit */
  103. #define CLKPWR_PCONP_PCQEI ((uint32_t)(1<<18))
  104. /** The I2C1 interface power/clock control bit */
  105. #define CLKPWR_PCONP_PCI2C1 ((uint32_t)(1<<19))
  106. /** The SSP2 interface power/clock control bit */
  107. #define CLKPWR_PCONP_PCSSP2 ((uint32_t)(1<<20))
  108. /** The SSP0 interface power/clock control bit */
  109. #define CLKPWR_PCONP_PCSSP0 ((uint32_t)(1<<21))
  110. /** Timer 2 power/clock control bit */
  111. #define CLKPWR_PCONP_PCTIM2 ((uint32_t)(1<<22))
  112. /** Timer 3 power/clock control bit */
  113. #define CLKPWR_PCONP_PCTIM3 ((uint32_t)(1<<23))
  114. /** UART 2 power/clock control bit */
  115. #define CLKPWR_PCONP_PCUART2 ((uint32_t)(1<<24))
  116. /** UART 3 power/clock control bit */
  117. #define CLKPWR_PCONP_PCUART3 ((uint32_t)(1<<25))
  118. /** I2C interface 2 power/clock control bit */
  119. #define CLKPWR_PCONP_PCI2C2 ((uint32_t)(1<<26))
  120. /** I2S interface power/clock control bit*/
  121. #define CLKPWR_PCONP_PCI2S ((uint32_t)(1<<27))
  122. /** SD card interface power/clock control bit */
  123. #define CLKPWR_PCONP_PCSDC ((uint32_t)(1<<28))
  124. /** GP DMA function power/clock control bit*/
  125. #define CLKPWR_PCONP_PCGPDMA ((uint32_t)(1<<29))
  126. /** Ethernet block power/clock control bit*/
  127. #define CLKPWR_PCONP_PCENET ((uint32_t)(1<<30))
  128. /** USB interface power/clock control bit*/
  129. #define CLKPWR_PCONP_PCUSB ((uint32_t)(1<<31))
  130. /********************************************************************
  131. * Power Control for Peripherals Definitions
  132. **********************************************************************/
  133. #define CLKPWR_RSTCON0_LCD ((uint32_t)(0))
  134. #define CLKPWR_RSTCON0_TIM0 ((uint32_t)(1))
  135. #define CLKPWR_RSTCON0_TIM1 ((uint32_t)(2))
  136. #define CLKPWR_RSTCON0_UART0 ((uint32_t)(3))
  137. #define CLKPWR_RSTCON0_UART1 ((uint32_t)(4))
  138. #define CLKPWR_RSTCON0_PWM0 ((uint32_t)(5))
  139. #define CLKPWR_RSTCON0_PWM1 ((uint32_t)(6))
  140. #define CLKPWR_RSTCON0_I2C0 ((uint32_t)(7))
  141. #define CLKPWR_RSTCON0_UART4 ((uint32_t)(8))
  142. #define CLKPWR_RSTCON0_RTC ((uint32_t)(9))
  143. #define CLKPWR_RSTCON0_SSP1 ((uint32_t)(10))
  144. #define CLKPWR_RSTCON0_EMC ((uint32_t)(11))
  145. #define CLKPWR_RSTCON0_ADC ((uint32_t)(12))
  146. #define CLKPWR_RSTCON0_CAN1 ((uint32_t)(13))
  147. #define CLKPWR_RSTCON0_CAN2 ((uint32_t)(14))
  148. #define CLKPWR_RSTCON0_GPIO ((uint32_t)(15))
  149. #define CLKPWR_RSTCON0_MCPWM ((uint32_t)(17))
  150. #define CLKPWR_RSTCON0_QEI ((uint32_t)(18))
  151. #define CLKPWR_RSTCON0_I2C1 ((uint32_t)(19))
  152. #define CLKPWR_RSTCON0_SSP2 ((uint32_t)(20))
  153. #define CLKPWR_RSTCON0_SSP0 ((uint32_t)(21))
  154. #define CLKPWR_RSTCON0_TIM2 ((uint32_t)(22))
  155. #define CLKPWR_RSTCON0_TIM3 ((uint32_t)(23))
  156. #define CLKPWR_RSTCON0_UART2 ((uint32_t)(24))
  157. #define CLKPWR_RSTCON0_UART3 ((uint32_t)(25))
  158. #define CLKPWR_RSTCON0_I2C2 ((uint32_t)(26))
  159. #define CLKPWR_RSTCON0_I2S ((uint32_t)(27))
  160. #define CLKPWR_RSTCON0_SDC ((uint32_t)(28))
  161. #define CLKPWR_RSTCON0_GPDMA ((uint32_t)(29))
  162. #define CLKPWR_RSTCON0_ENET ((uint32_t)(30))
  163. #define CLKPWR_RSTCON0_USB ((uint32_t)(31))
  164. #define CLKPWR_RSTCON1_IOCON ((uint32_t)(32))
  165. #define CLKPWR_RSTCON1_DAC ((uint32_t)(33))
  166. #define CLKPWR_RSTCON1_CANACC ((uint32_t)(34))
  167. /**
  168. * @}
  169. */
  170. /* External clock variable from system_LPC407x_8x_177x_8x.h */
  171. extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
  172. extern uint32_t PeripheralClock; /*!< Peripheral Clock Frequency (Pclk) */
  173. extern uint32_t EMCClock; /*!< EMC Clock Frequency */
  174. /* External clock variable from lpc_clkpwr.h */
  175. extern uint32_t USBClock; /*!< USB Frequency */
  176. /* Public Functions ----------------------------------------------------------- */
  177. /** @defgroup CLKPWR_Public_Functions CLKPWR Public Functions
  178. * @{
  179. */
  180. void CLKPWR_SetCLKDiv(uint8_t ClkType, uint8_t DivVal);
  181. uint32_t CLKPWR_GetCLK(uint8_t ClkType);
  182. void CLKPWR_ConfigPPWR(uint32_t PPType, FunctionalState NewState);
  183. void CLKPWR_ConfigReset(uint8_t PType, FunctionalState NewState);
  184. void CLKPWR_Sleep(void);
  185. void CLKPWR_DeepSleep(void);
  186. void CLKPWR_PowerDown(void);
  187. void CLKPWR_DeepPowerDown(void);
  188. /**
  189. * @}
  190. */
  191. #ifdef __cplusplus
  192. }
  193. #endif
  194. #endif /* __LPC_CLKPWR_H_ */
  195. /**
  196. * @}
  197. */
  198. /* --------------------------------- End Of File ------------------------------ */