efm32_emu.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /***************************************************************************//**
  2. * @file
  3. * @brief Energy management unit (EMU) peripheral API for EFM32.
  4. * @author Energy Micro AS
  5. * @version 1.3.0
  6. *******************************************************************************
  7. * @section License
  8. * <b>(C) Copyright 2010 Energy Micro AS, http://www.energymicro.com</b>
  9. *******************************************************************************
  10. *
  11. * This source code is the property of Energy Micro AS. The source and compiled
  12. * code may only be used on Energy Micro "EFM32" microcontrollers.
  13. *
  14. * This copyright notice may not be removed from the source code nor changed.
  15. *
  16. * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
  17. * obligation to support this Software. Energy Micro AS is providing the
  18. * Software "AS IS", with no express or implied warranties of any kind,
  19. * including, but not limited to, any implied warranties of merchantability
  20. * or fitness for any particular purpose or warranties against infringement
  21. * of any proprietary rights of a third party.
  22. *
  23. * Energy Micro AS will not be liable for any consequential, incidental, or
  24. * special damages, or any other relief, or for any claim by any third party,
  25. * arising from your use of this Software.
  26. *
  27. ******************************************************************************/
  28. #ifndef __EFM32_EMU_H
  29. #define __EFM32_EMU_H
  30. #include <stdbool.h>
  31. #include "efm32.h"
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /***************************************************************************//**
  36. * @addtogroup EFM32_Library
  37. * @{
  38. ******************************************************************************/
  39. /***************************************************************************//**
  40. * @addtogroup EMU
  41. * @{
  42. ******************************************************************************/
  43. /*******************************************************************************
  44. ***************************** PROTOTYPES **********************************
  45. ******************************************************************************/
  46. /***************************************************************************//**
  47. * @brief
  48. * Enter energy mode 1 (EM1).
  49. ******************************************************************************/
  50. static __INLINE void EMU_EnterEM1(void)
  51. {
  52. /* Just enter Cortex-M3 sleep mode */
  53. SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
  54. __WFI();
  55. }
  56. void EMU_EnterEM2(bool restore);
  57. void EMU_EnterEM3(bool restore);
  58. void EMU_EnterEM4(void);
  59. /***************************************************************************//**
  60. * @brief
  61. * Lock the EMU in order to protect all its registers against unintended
  62. * modification.
  63. *
  64. * @note
  65. * If locking the EMU registers, they must be unlocked prior to using any
  66. * EMU API functions modifying EMU registers. An exception to this is the
  67. * energy mode entering API (EMU_EnterEMn()), which can be used when the
  68. * EMU registers are locked.
  69. ******************************************************************************/
  70. static __INLINE void EMU_Lock(void)
  71. {
  72. EMU->LOCK = EMU_LOCK_LOCKKEY_LOCK;
  73. }
  74. void EMU_MemPwrDown(uint32_t blocks);
  75. /***************************************************************************//**
  76. * @brief
  77. * Unlock the EMU so that writing to locked registers again is possible.
  78. ******************************************************************************/
  79. static __INLINE void EMU_Unlock(void)
  80. {
  81. EMU->LOCK = EMU_LOCK_LOCKKEY_UNLOCK;
  82. }
  83. void EMU_UpdateOscConfig(void);
  84. /** @} (end addtogroup EMU) */
  85. /** @} (end addtogroup EFM32_Library) */
  86. #ifdef __cplusplus
  87. }
  88. #endif
  89. #endif /* __EFM32_EMU_H */