lp.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. /**
  2. * @file lp.h
  3. * @brief Low power function prototypes and data types.
  4. */
  5. /* ****************************************************************************
  6. * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a
  9. * copy of this software and associated documentation files (the "Software"),
  10. * to deal in the Software without restriction, including without limitation
  11. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  12. * and/or sell copies of the Software, and to permit persons to whom the
  13. * Software is furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included
  16. * in all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  21. * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
  22. * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  23. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  24. * OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. * Except as contained in this notice, the name of Maxim Integrated
  27. * Products, Inc. shall not be used except as stated in the Maxim Integrated
  28. * Products, Inc. Branding Policy.
  29. *
  30. * The mere transfer of this software does not imply any licenses
  31. * of trade secrets, proprietary technology, copyrights, patents,
  32. * trademarks, maskwork rights, or any other form of intellectual
  33. * property whatsoever. Maxim Integrated Products, Inc. retains all
  34. * ownership rights.
  35. *
  36. * $Date: 2018-09-26 08:48:30 -0500 (Wed, 26 Sep 2018) $
  37. * $Revision: 38105 $
  38. *
  39. *************************************************************************** */
  40. // Define to prevent redundant inclusion
  41. #ifndef _LP_H_
  42. #define _LP_H_
  43. /***** Includes *****/
  44. #include "gpio.h"
  45. #include "pwrseq_regs.h"
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49. /** @brief System reset0 enumeration. Used in SYS_PeriphReset0 function */
  50. typedef enum {
  51. LP_OVR_0_9 = MXC_S_PWRSEQ_LP_CTRL_OVR_0_9V, /**< Reset DMA */
  52. LP_OVR_1_0 = MXC_S_PWRSEQ_LP_CTRL_OVR_1_0V, /**< Reset DMA */
  53. LP_OVR_1_1 = MXC_S_PWRSEQ_LP_CTRL_OVR_1_1V, /**< Reset DMA */
  54. } lp_ovr_t;
  55. /**
  56. * @brief Clears the low power wakeup flags
  57. */
  58. void LP_ClearWakeStatus(void);
  59. /**
  60. * @brief Enables power to RAM addresses 0x20010000-0x20017FFF.
  61. */
  62. void LP_EnableSRAM3(void);
  63. /**
  64. * @brief Enables power to RAM addresses 0x20008000-0x2000FFFF.
  65. */
  66. void LP_EnableSRAM2(void);
  67. /**
  68. * @brief Enables power to RAM addresses 0x20004000-0x20007FFF.
  69. */
  70. void LP_EnableSRAM1(void);
  71. /**
  72. * @brief Enables power to RAM addresses 0x20000000-0x20003FFF.
  73. */
  74. void LP_EnableSRAM0(void);
  75. /**
  76. * @brief Disables power to RAM addresses 0x20010000-0x20017FFF. The contents of the RAM are destroyed.
  77. */
  78. void LP_DisableSRAM3(void);
  79. /**
  80. * @brief Disables power to RAM addresses 0x20008000-0x2000FFFF. The contents of the RAM are destroyed.
  81. */
  82. void LP_DisableSRAM2(void);
  83. /**
  84. * @brief Disables power to RAM addresses 0x20004000-0x20007FFF. The contents of the RAM are destroyed.
  85. */
  86. void LP_DisableSRAM1(void);
  87. /**
  88. * @brief Disables power to RAM addresses 0x20000000-0x20003FFF. The contents of the RAM are destroyed.
  89. */
  90. void LP_DisableSRAM0(void);
  91. /**
  92. * @brief Places the instruction cache in light sleep mode. Data will be unavailable for read/write operations but will be retained.
  93. */
  94. void LP_EnableICacheLightSleep(void);
  95. /**
  96. * @brief Places addresses 0x20010000 to 0x20017FFF of the RAM in light sleep mode. Data will be unavailable for read/write operations but will be retained.
  97. */
  98. void LP_EnableSysRAM3LightSleep(void);
  99. /**
  100. * @brief Places addresses 0x20008000 to 0x2000FFFF of the RAM in light sleep mode. Data will be unavailable for read/write operations but will be retained.
  101. */
  102. void LP_EnableSysRAM2LightSleep(void);
  103. /**
  104. * @brief Places addresses 0x20004000 to 0x20007FFF of the RAM in light sleep mode. Data will be unavailable for read/write operations but will be retained.
  105. */
  106. void LP_EnableSysRAM1LightSleep(void);
  107. /**
  108. * @brief Places addresses 0x20000000 to 0x20003FFF of the RAM in light sleep mode. Data will be unavailable for read/write operations but will be retained.
  109. */
  110. void LP_EnableSysRAM0LightSleep(void);
  111. /**
  112. * @brief Places the instruction cache in active mode.
  113. */
  114. void LP_DisableICacheLightSleep(void);
  115. /**
  116. * @brief Places addresses 0x20010000 to 0x20017FFF of the RAM in active mode.
  117. */
  118. void LP_DisableSysRAM3LightSleep(void);
  119. /**
  120. * @brief Places addresses 0x20008000 to 0x2000FFFF of the RAM in active mode.
  121. */
  122. void LP_DisableSysRAM2LightSleep(void);
  123. /**
  124. * @brief Places addresses 0x20004000 to 0x20007FFF of the RAM in active mode.
  125. */
  126. void LP_DisableSysRAM1LightSleep(void);
  127. /**
  128. * @brief Places addresses 0x20000000 to 0x20003FFF of the RAM in active mode.
  129. */
  130. void LP_DisableSysRAM0LightSleep(void);
  131. /**
  132. * @brief Enables the selected GPIO port and its selected pins to wake up the device from any low power mode.
  133. * Call this function multiple times to enable pins on multiple ports. This function does not configure
  134. * the GPIO pins nor does it setup their interrupt functionality.
  135. * @param wu_pins The port and pins to configure as wakeup sources. Only the gpio and mask fields of the
  136. * structure are used. The func and pad fields are ignored.
  137. */
  138. void LP_EnableGPIOWakeup(const gpio_cfg_t *wu_pins);
  139. /**
  140. * @brief Disables the selected GPIO port and its selected pins as a wake up source.
  141. * Call this function multiple times to disable pins on multiple ports.
  142. * @param wu_pins The port and pins to disable as wakeup sources. Only the gpio and mask fields of the
  143. * structure are used. The func and pad fields are ignored.
  144. */
  145. void LP_DisableGPIOWakeup(const gpio_cfg_t *wu_pins);
  146. /**
  147. * @brief Enables the RTC alarm to wake up the device from any low power mode.
  148. */
  149. void LP_EnableRTCAlarmWakeup(void);
  150. /**
  151. * @brief Disables the RTC alarm from waking up the device.
  152. */
  153. void LP_DisableRTCAlarmWakeup(void);
  154. /**
  155. * @brief Places the device into SLEEP mode. This function returns once any interrupt occurs.
  156. * @note LP_ClearWakeStatus should be called before this function, to avoid immediately waking up again
  157. */
  158. void LP_EnterSleepMode(void);
  159. /**
  160. * @brief Places the device into DEEPSLEEP mode. This function returns once an RTC or external interrupt occur.
  161. * @note LP_ClearWakeStatus should be called before this function, to avoid immediately waking up again
  162. */
  163. void LP_EnterDeepSleepMode(void);
  164. /**
  165. * @brief Places the device into BACKUP mode. CPU state is not maintained in this mode, so this function never returns.
  166. * Instead, the device will restart once an RTC or external interrupt occur.
  167. * @note LP_ClearWakeStatus should be called before this function, to avoid immediately waking up again
  168. */
  169. void LP_EnterBackupMode(void);
  170. /**
  171. * @brief Places the device into Shutdown mode. CPU state is not maintained in this mode, so this function never returns.
  172. * Instead, the device will restart once an RTC, USB wakeup, or external interrupt occur.
  173. */
  174. void LP_EnterShutDownMode(void);
  175. /**
  176. * @brief Set operating voltage and change the clock to match the new voltage.
  177. * @param system reset configuration struct
  178. */
  179. void LP_SetOperatingVoltage(lp_ovr_t ovr);
  180. /**
  181. * @brief Enables Data Retention to RAM addresses 0x20000000-0x20003FFF.
  182. */
  183. void LP_EnableSRamRet0(void);
  184. /**
  185. * @brief Disables Data Retention to RAM addresses 0x20000000-0x20003FFF.
  186. */
  187. void LP_DisableSRamRet0(void);
  188. /**
  189. * @brief Enables Data Retention to RAM addresses 0x20004000-0x20007FFF.
  190. */
  191. void LP_EnableSRamRet1(void);
  192. /**
  193. * @brief Disables Data Retention to RAM addresses 0x20004000-0x20007FFF.
  194. */
  195. void LP_DisableSRamRet1(void);
  196. /**
  197. * @brief Enables Data Retention to RAM addresses 0x20008000-0x2000FFFF.
  198. */
  199. void LP_EnableSRamRet2(void);
  200. /**
  201. * @brief Disables Data Retention to RAM addresses 0x20008000-0x2000FFFF.
  202. */
  203. void LP_DisableSRamRet2(void);
  204. /**
  205. * @brief Enables Data Retention to RAM addresses 0x20010000-0x20017FFF.
  206. */
  207. void LP_EnableSRamRet3(void);
  208. /**
  209. * @brief Disables Data Retention to RAM addresses 0x20010000-0x20017FFF.
  210. */
  211. void LP_DisableSRamRet3(void);
  212. /**
  213. * @brief Enables Bypassing the hardware detection of an external supply on V CORE enables a faster wakeup time.
  214. */
  215. void LP_EnableBlockDetect(void);
  216. /**
  217. * @brief Disables Bypassing the hardware detection of an external supply on V CORE enables a faster wakeup time
  218. */
  219. void LP_DisableBlockDetect(void);
  220. /**
  221. * @brief RAM Retention Regulator Enable for BACKUP Mode
  222. */
  223. void LP_EnableRamRetReg(void);
  224. /**
  225. * @brief RAM Retention Regulator Disabels for BACKUP Mode
  226. */
  227. void LP_DisableRamRetReg(void);
  228. /**
  229. * @brief Enables Fast wake up from deepsleep
  230. */
  231. void LP_EnableFastWk(void);
  232. /**
  233. * @brief Disables Fast wake up from deepsleep
  234. */
  235. void LP_DisableFastWk(void);
  236. /**
  237. * @brief Turns on band gap during deepsleep and backup mode.
  238. */
  239. void LP_EnableBandGap(void);
  240. /**
  241. * @brief Turns off band gap during deepsleep and backup mode.
  242. */
  243. void LP_DisableBandGap(void);
  244. /**
  245. * @brief Enables signal for power on reset when the device is int DEEPSLEEP or BACKUP mode
  246. */
  247. void LP_EnableVCorePORSignal(void);
  248. /**
  249. * @brief Disables signal for power on reset when the device is int DEEPSLEEP or BACKUP mode
  250. */
  251. void LP_DisableVCorePORSignal(void);
  252. /**
  253. * @brief Enables signal for power on reset when the device is int DEEPSLEEP or BACKUP mode
  254. */
  255. void LP_EnableLDO(void);
  256. /**
  257. * @brief Disables signal for power on reset when the device is int DEEPSLEEP or BACKUP mode
  258. */
  259. void LP_DisableLDO(void);
  260. /**
  261. * @brief Enables V CORE Supply Voltage Monitor
  262. */
  263. void LP_EnableVCoreSVM(void);
  264. /**
  265. * @brief Disables V CORE Supply Voltage Monitor
  266. */
  267. void LP_DisableVCoreSVM(void);
  268. /**
  269. * @brief Enables VDDIO Power-On-Reset Monitor
  270. */
  271. void LP_EnableVDDIOPorMonitor(void);
  272. /**
  273. * @brief Disables VDDIO Power-On-Reset Monitor
  274. */
  275. void LP_DisableVDDIOPorMonitor(void);
  276. #ifdef __cplusplus
  277. }
  278. #endif
  279. #endif /* _LP_H_ */