am_hal_reset.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //*****************************************************************************
  2. //
  3. // am_hal_reset.h
  4. //! @file
  5. //!
  6. //! @brief Hardware abstraction layer for the Reset Generator module.
  7. //!
  8. //! @addtogroup wdt2 Watchdog Timer (RSTGEN)
  9. //! @ingroup apollo2hal
  10. //! @{
  11. //
  12. //*****************************************************************************
  13. //*****************************************************************************
  14. //
  15. // Copyright (c) 2017, Ambiq Micro
  16. // All rights reserved.
  17. //
  18. // Redistribution and use in source and binary forms, with or without
  19. // modification, are permitted provided that the following conditions are met:
  20. //
  21. // 1. Redistributions of source code must retain the above copyright notice,
  22. // this list of conditions and the following disclaimer.
  23. //
  24. // 2. Redistributions in binary form must reproduce the above copyright
  25. // notice, this list of conditions and the following disclaimer in the
  26. // documentation and/or other materials provided with the distribution.
  27. //
  28. // 3. Neither the name of the copyright holder nor the names of its
  29. // contributors may be used to endorse or promote products derived from this
  30. // software without specific prior written permission.
  31. //
  32. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  33. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  34. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  35. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  36. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  37. // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  38. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  39. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  40. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  41. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  42. // POSSIBILITY OF SUCH DAMAGE.
  43. //
  44. // This is part of revision 1.2.11 of the AmbiqSuite Development Package.
  45. //
  46. //*****************************************************************************
  47. #ifndef AM_HAL_RSTGEN_H
  48. #define AM_HAL_RSTGEN_H
  49. //*****************************************************************************
  50. //
  51. //! @name Reset Generator Configuration
  52. //! @brief These macros may be used to set the reset generator's configuration.
  53. //! @{
  54. //
  55. //*****************************************************************************
  56. #define AM_HAL_RESET_CFG_WDT_RESET_ENABLE (AM_REG_RSTGEN_CFG_WDREN(1))
  57. // Brown out high (2.1v) reset enable.
  58. #define AM_HAL_RESET_CFG_BOD_HIGH_RESET_ENABLE (AM_REG_RSTGEN_CFG_BODHREN(1))
  59. //! @}
  60. //*****************************************************************************
  61. //
  62. //! @name Reset Generator Status Bit Masks
  63. //! @brief These macros may be used to determine which type(s) of resets have
  64. //! been seen.
  65. //! @{
  66. //
  67. //*****************************************************************************
  68. // Reset was initiated by a Watchdog Timer Reset.
  69. #define AM_HAL_RESET_STAT_WDT (AM_REG_RSTGEN_STAT_WDRSTAT_M)
  70. // Reset was a initiated by Debugger Reset.
  71. #define AM_HAL_RESET_STAT_DEBUG (AM_REG_RSTGEN_STAT_DBGRSTAT_M)
  72. // Reset was a initiated by Software POI Reset.
  73. #define AM_HAL_RESET_STAT_POI (AM_REG_RSTGEN_STAT_POIRSTAT_M)
  74. // Reset was a initiated by Software POR or AIRCR Reset.
  75. #define AM_HAL_RESET_STAT_SOFTWARE (AM_REG_RSTGEN_STAT_SWRSTAT_M)
  76. // Reset was initiated by a Brown-Out Reset.
  77. #define AM_HAL_RESET_STAT_BOD (AM_REG_RSTGEN_STAT_BORSTAT_M)
  78. // Reset was initiated by a Power Cycle
  79. #define AM_HAL_RESET_STAT_POWER_CYCLE (AM_REG_RSTGEN_STAT_PORSTAT_M)
  80. // Reset was initiated by an External Reset.
  81. #define AM_HAL_RESET_STAT_EXTERNAL (AM_REG_RSTGEN_STAT_EXRSTAT_M)
  82. //! @}
  83. #ifdef __cplusplus
  84. extern "C"
  85. {
  86. #endif
  87. //*****************************************************************************
  88. //
  89. // External function definitions
  90. //
  91. //*****************************************************************************
  92. extern void am_hal_reset_init(uint32_t ui32Config);
  93. extern void am_hal_reset_por(void);
  94. extern void am_hal_reset_poi(void);
  95. extern uint32_t am_hal_reset_status_get(void);
  96. extern void am_hal_reset_status_clear(void);
  97. #ifdef __cplusplus
  98. }
  99. #endif
  100. #endif // AM_HAL_RSTGEN_H
  101. //*****************************************************************************
  102. //
  103. // End Doxygen group.
  104. //! @}
  105. //
  106. //*****************************************************************************