power_lib_5410x.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * @brief LPC5410x Power library 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 __POWER_LIB_5410X_H_
  32. #define __POWER_LIB_5410X_H_
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /** @defgroup POWER_LIBRARY_5410X CHIP: LPC5410X Power LIBRARY functions
  37. * The power library provides functions to control system power usage and
  38. * place the device into low power modes.<br>
  39. *
  40. * <b>Clock shutdown in sleep and power down modes</b><br>
  41. * When using the Chip_POWER_EnterPowerMode() function, system clocks are
  42. * shutdown based on the selected sleep or power down mode and the device
  43. * version being used. The following list details which clocks are shut down
  44. * in which modes for which device versions. You can keep a clock enabled
  45. * for a sleep or power down mode by enabling it in the 'peripheral_ctrl'
  46. * field in the Chip_POWER_EnterPowerMode() function.<br>
  47. *
  48. * Mode: Sleep<br>
  49. * No clocks are disabled for any chip version.<br>
  50. *
  51. * Mode: Deep sleep<br>
  52. * SYSCON_PDRUNCFG_PD_IRC_OSC<br>
  53. * SYSCON_PDRUNCFG_PD_IRC<br>
  54. * SYSCON_PDRUNCFG_PD_FLASH (v17.1 and later only)<br>
  55. * SYSCON_PDRUNCFG_PD_BOD_INTR<br>
  56. * SYSCON_PDRUNCFG_PD_ADC0<br>
  57. * SYSCON_PDRUNCFG_PD_ROM<br>
  58. * SYSCON_PDRUNCFG_PD_VDDA_ENA<br>
  59. * SYSCON_PDRUNCFG_PD_SYS_PLL<br>
  60. * SYSCON_PDRUNCFG_PD_VREFP<br>
  61. *
  62. * Mode: Power down<br>
  63. * SYSCON_PDRUNCFG_PD_IRC_OSC<br>
  64. * SYSCON_PDRUNCFG_PD_IRC<br>
  65. * SYSCON_PDRUNCFG_PD_FLASH (v17.1 and later only)<br>
  66. * SYSCON_PDRUNCFG_PD_BOD_RST<br>
  67. * SYSCON_PDRUNCFG_PD_BOD_INTR<br>
  68. * SYSCON_PDRUNCFG_PD_ADC0<br>
  69. * SYSCON_PDRUNCFG_PD_SRAM0B<br>
  70. * SYSCON_PDRUNCFG_PD_SRAM1<br>
  71. * SYSCON_PDRUNCFG_PD_SRAM2<br>
  72. * SYSCON_PDRUNCFG_PD_ROM<br>
  73. * SYSCON_PDRUNCFG_PD_VDDA_ENA<br>
  74. * SYSCON_PDRUNCFG_PD_WDT_OSC<br>
  75. * SYSCON_PDRUNCFG_PD_SYS_PLL<br>
  76. * SYSCON_PDRUNCFG_PD_VREFP<br>
  77. * SYSCON_PDRUNCFG_PD_32K_OSC<br>
  78. *
  79. * Mode: Deep power down<br>
  80. * All clocks are disabled for all chip versions.<br>
  81. *
  82. * If you are using a peripheral was a wakeup source for a power down mode,
  83. * it needs to be kept active with the call to Chip_POWER_EnterPowerMode(). For
  84. * example, if you are using the RTC to wake the system up from power down mode,
  85. * the 32KHz RTC oscillator needs to remain active, so the power down call would
  86. * look like this:<br>
  87. * Chip_POWER_EnterPowerMode(POWER_POWER_DOWN, SYSCON_PDRUNCFG_PD_32K_OSC);<br>
  88. * If your application uses internal RAM beyond the first 8K, you will also need
  89. * to prevent power down of the IRAM like this:<br>
  90. * Chip_POWER_EnterPowerMode(POWER_POWER_DOWN, (SYSCON_PDRUNCFG_PD_32K_OSC | SYSCON_PDRUNCFG_PD_SRAM0A));<br>
  91. * @ingroup CHIP_5410X_DRIVERS
  92. * @{
  93. */
  94. /**
  95. * @brief Sets up the System PLL given the PLL input frequency and feedback multiplier
  96. * @param multiply_by : PLL multiplier, minimum of 1, maximum of 16
  97. * @param input_freq : Input frequency into the PLL
  98. * @return LPC_OK on success, or an error code (see error.h)
  99. */
  100. uint32_t Chip_POWER_SetPLL(uint32_t multiply_by, uint32_t input_freq);
  101. /**
  102. * @brief Set optimal system voltage based on passed system frequency
  103. * @param mode : Power mode
  104. * @param desired_freq : System (CPU) frequency
  105. * @return LPC_OK on success, or an error code (see error.h)
  106. * @note This function will adjust the system voltages to the lowest
  107. * levels that will support the passed mode and CPU frequency.
  108. */
  109. uint32_t Chip_POWER_SetVoltage(PERF_MODE_T mode, uint32_t desired_freq);
  110. /**
  111. * @brief Enters the selected power state
  112. * @param mode : Power mode
  113. * @param peripheral_ctrl : Peripherals that will remain powered up in the power state
  114. * @return Nothing
  115. * @note The 'peripheral_ctrl' field is a bitmask of bits from the
  116. * PDRUNCFG register (SYSCON_PDRUNCFG_PD_*) that describe which
  117. * peripherals can wake up the chip from the power state. These
  118. * peripherals are not powered down during the power state.<br>
  119. */
  120. void Chip_POWER_EnterPowerMode(POWER_MODE_T mode, uint32_t peripheral_ctrl);
  121. /* ROM versions */
  122. #define LPC5410X_ROMVER_0 (0x1100)
  123. #define LPC5410X_ROMVER_1 (0x1101)
  124. #define LPC5410X_ROMVER_2 (0x1102)
  125. /**
  126. * @brief Fast powerdown for IRAM based applications
  127. * @param peripheral_ctrl : Peripherals that will remain powered up in the power down state
  128. * @return Nothing
  129. * @note The 'peripheral_ctrl' field is a bitmask of bits from the
  130. * PDRUNCFG register (SYSCON_PDRUNCFG_PD_*) that describe which
  131. * peripherals can wake up the chip from the power state. These
  132. * peripherals are not powered down during the power state.<br>
  133. * This function should only be used when not executing code in FLASH.
  134. * It will power down FLASH and leave it powered down on exit, so all
  135. * code should be placed in IRAM prior to calling. It provides a quicker
  136. * wakeup response than the default powerdown function
  137. * (Chip_POWER_EnterPowerMode(POWER_POWER_DOWN, ...)).
  138. */
  139. void Chip_POWER_EnterPowerModeIramOnly(uint32_t peripheral_ctrl);
  140. /**
  141. * @brief Return ROM version
  142. * @return ROM version
  143. * @note Will return one of the following version numbers:<br>
  144. * (0x1100) for v17.0 ROMs.<br>
  145. * (0x1101) for v17.1 ROMs.<br>
  146. * (0x1102) for v17.2 ROMs.<br>
  147. */
  148. uint32_t Chip_POWER_GetROMVersion(void);
  149. /**
  150. * @}
  151. */
  152. #ifdef __cplusplus
  153. }
  154. #endif
  155. #endif /* __POWER_LIB_5410X_H_ */