pmu_5410x.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * @brief LPC5410X Power Management declarations and functions
  3. *
  4. * @note
  5. * Copyright(C) NXP Semiconductors, 2014
  6. * All rights reserved.
  7. *
  8. * @par
  9. * Software that is described herein is for illustrative purposes only
  10. * which provides customers with programming information regarding the
  11. * LPC products. This software is supplied "AS IS" without any warranties of
  12. * any kind, and NXP Semiconductors and its licensor disclaim any and
  13. * all warranties, express or implied, including all implied warranties of
  14. * merchantability, fitness for a particular purpose and non-infringement of
  15. * intellectual property rights. NXP Semiconductors assumes no responsibility
  16. * or liability for the use of the software, conveys no license or rights under any
  17. * patent, copyright, mask work right, or any other intellectual property rights in
  18. * or to any products. NXP Semiconductors reserves the right to make changes
  19. * in the software without notification. NXP Semiconductors also makes no
  20. * representation or warranty that such application will be suitable for the
  21. * specified use without further testing or modification.
  22. *
  23. * @par
  24. * Permission to use, copy, modify, and distribute this software and its
  25. * documentation is hereby granted, under NXP Semiconductors' and its
  26. * licensor's relevant copyrights in the software, without fee, provided that it
  27. * is used in conjunction with NXP Semiconductors microcontrollers. This
  28. * copyright, permission, and disclaimer notice must appear in all copies of
  29. * this code.
  30. */
  31. #ifndef __PMU_5410X_H_
  32. #define __PMU_5410X_H_
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /** @defgroup PMU_5410X CHIP: LPC5410X Power Management declarations and functions
  37. * @ingroup CHIP_5410X_DRIVERS
  38. * @{
  39. */
  40. /**
  41. * @brief PMU register block structure
  42. * @note Most of the PMU support is handled by the PMU library.
  43. */
  44. typedef struct {
  45. __I uint32_t RESERVED0[4];
  46. __I uint32_t RESERVED1[4];
  47. __I uint32_t RESERVED2[4];
  48. __I uint32_t RESERVED3[4];
  49. __I uint32_t RESERVED4;
  50. __IO uint32_t BODCTRL;
  51. __I uint32_t RESERVED5;
  52. __I uint32_t RESERVED6;
  53. __IO uint32_t DPDWAKESRC;
  54. } LPC_PMU_T;
  55. /**
  56. * Brown-out detector reset level
  57. */
  58. typedef enum {
  59. PMU_BODRSTLVL_0, /*!< Brown-out reset at ~1.5v */
  60. PMU_BODRSTLVL_1_50V = PMU_BODRSTLVL_0,
  61. PMU_BODRSTLVL_1, /*!< Brown-out reset at ~1.85v */
  62. PMU_BODRSTLVL_1_85V = PMU_BODRSTLVL_1,
  63. PMU_BODRSTLVL_2, /*!< Brown-out reset at ~2.0v */
  64. PMU_BODRSTLVL_2_00V = PMU_BODRSTLVL_2,
  65. PMU_BODRSTLVL_3, /*!< Brown-out reset at ~2.3v */
  66. PMU_BODRSTLVL_2_30V = PMU_BODRSTLVL_3
  67. } CHIP_PMU_BODRSTLVL_T;
  68. /**
  69. * Brown-out detector interrupt level
  70. */
  71. typedef enum CHIP_PMU_BODRINTVAL {
  72. PMU_BODINTVAL_LVL0, /*!< Brown-out interrupt at ~2.05v */
  73. PMU_BODINTVAL_2_05v = PMU_BODINTVAL_LVL0,
  74. PMU_BODINTVAL_LVL1, /*!< Brown-out interrupt at ~2.45v */
  75. PMU_BODINTVAL_2_45v = PMU_BODINTVAL_LVL1,
  76. PMU_BODINTVAL_LVL2, /*!< Brown-out interrupt at ~2.75v */
  77. PMU_BODINTVAL_2_75v = PMU_BODINTVAL_LVL2,
  78. PMU_BODINTVAL_LVL3, /*!< Brown-out interrupt at ~3.05v */
  79. PMU_BODINTVAL_3_05v = PMU_BODINTVAL_LVL3
  80. } CHIP_PMU_BODRINTVAL_T;
  81. /**
  82. * brown-out detection reset status (in BODCTRL register)
  83. */
  84. #define PMU_BOD_RST (1 << 6)
  85. /**
  86. * brown-out detection interrupt status (in BODCTRL register)
  87. */
  88. #define PMU_BOD_INT (1 << 7)
  89. /**
  90. * @brief Set brown-out detection interrupt and reset levels
  91. * @param rstlvl : Brown-out detector reset level
  92. * @param intlvl : Brown-out interrupt level
  93. * @return Nothing
  94. * @note Brown-out detection reset will be disabled upon exiting this function.
  95. * Use Chip_PMU_EnableBODReset() to re-enable.
  96. */
  97. STATIC INLINE void Chip_PMU_SetBODLevels(CHIP_PMU_BODRSTLVL_T rstlvl,
  98. CHIP_PMU_BODRINTVAL_T intlvl)
  99. {
  100. LPC_PMU->BODCTRL = ((uint32_t) rstlvl) | (((uint32_t) intlvl) << 2);
  101. }
  102. /**
  103. * @brief Enable brown-out detection reset
  104. * @return Nothing
  105. */
  106. STATIC INLINE void Chip_PMU_EnableBODReset(void)
  107. {
  108. LPC_PMU->BODCTRL |= (1 << 4);
  109. }
  110. /**
  111. * @brief Disable brown-out detection reset
  112. * @return Nothing
  113. */
  114. STATIC INLINE void Chip_PMU_DisableBODReset(void)
  115. {
  116. LPC_PMU->BODCTRL &= ~(1 << 4);
  117. }
  118. /**
  119. * @brief Enable brown-out detection interrupt
  120. * @return Nothing
  121. */
  122. STATIC INLINE void Chip_PMU_EnableBODInt(void)
  123. {
  124. LPC_PMU->BODCTRL |= (1 << 5);
  125. }
  126. /**
  127. * @brief Disable brown-out detection interrupt
  128. * @return Nothing
  129. */
  130. STATIC INLINE void Chip_PMU_DisableBODInt(void)
  131. {
  132. LPC_PMU->BODCTRL &= ~(1 << 5);
  133. }
  134. /**
  135. * Deep power down reset sources
  136. */
  137. #define PMU_DPDWU_RESET (1 << 0) /*!< Deep powerdown wakeup by reset pin */
  138. #define PMU_DPDWU_RTC (1 << 1) /*!< Deep powerdown wakeup by RTC */
  139. #define PMU_DPDWU_BODRESET (1 << 2) /*!< Deep powerdown wakeup by brown out reset*/
  140. #define PMU_DPDWU_BODINTR (1 << 3) /*!< Deep powerdown wakeup by brown out interrupt */
  141. /**
  142. * @brief Return wakeup sources from deep power down mode
  143. * @return Deep power down mode wakeup sources
  144. * @note Mask the return value with a PMU_DPDWU_* value to determine
  145. * the wakeup source from deep power down.
  146. */
  147. STATIC INLINE uint32_t Chip_PMU_GetDPDWUSource(void)
  148. {
  149. return LPC_PMU->DPDWAKESRC;
  150. }
  151. /**
  152. * @brief Clear a deep power down mode wakeup source
  153. * @param mask : Or'ed PMU_DPDWU_* values to clear
  154. * @return Nothing
  155. */
  156. STATIC INLINE void Chip_PMU_ClearDPDWUSource(uint32_t mask)
  157. {
  158. LPC_PMU->DPDWAKESRC = mask;
  159. }
  160. /**
  161. * @}
  162. */
  163. #ifdef __cplusplus
  164. }
  165. #endif
  166. #endif /* __PMU_5410X_H_ */