am_hal_mcuctrl.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. //*****************************************************************************
  2. //
  3. // am_hal_mcuctrl.h
  4. //! @file
  5. //!
  6. //! @brief Functions for accessing and configuring the MCUCTRL.
  7. //!
  8. //! @addtogroup mcuctrl2 MCU Control (MCUCTRL)
  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.9 of the AmbiqSuite Development Package.
  45. //
  46. //*****************************************************************************
  47. #ifndef AM_HAL_MCUCTRL_H
  48. #define AM_HAL_MCUCTRL_H
  49. #ifdef __cplusplus
  50. extern "C"
  51. {
  52. #endif
  53. //
  54. // Deprecate the am_hal_mcuctrl_bucks_enable() and disable() functions.
  55. // This functionality is now handled in pwrctrl.
  56. //
  57. #define am_hal_mcuctrl_bucks_enable am_hal_pwrctrl_bucks_enable
  58. #define am_hal_mcuctrl_bucks_disable am_hal_pwrctrl_bucks_disable
  59. //*****************************************************************************
  60. //
  61. // Define CHIP_INFO fields, which for Apollo2 are not defined in the register
  62. // definitions.
  63. //
  64. //*****************************************************************************
  65. #define AM_HAL_MCUCTRL_CHIP_INFO_CLASS_M 0xFF000000
  66. #define AM_HAL_MCUCTRL_CHIP_INFO_CLASS_S 24
  67. #define AM_HAL_MCUCTRL_CHIP_INFO_FLASH_SIZE_M 0x00F00000
  68. #define AM_HAL_MCUCTRL_CHIP_INFO_FLASH_SIZE_S 20
  69. #define AM_HAL_MCUCTRL_CHIP_INFO_SRAM_SIZE_M 0x000F0000
  70. #define AM_HAL_MCUCTRL_CHIP_INFO_SRAM_SIZE_S 16
  71. #define AM_HAL_MCUCTRL_CHIP_INFO_REV_M 0x0000FF00
  72. #define AM_HAL_MCUCTRL_CHIP_INFO_REV_S 8
  73. #define AM_HAL_MCUCTRL_CHIP_INFO_PKG_M 0x000000C0
  74. #define AM_HAL_MCUCTRL_CHIP_INFO_PKG_S 6
  75. #define AM_HAL_MCUCTRL_CHIP_INFO_PINS_M 0x00000038
  76. #define AM_HAL_MCUCTRL_CHIP_INFO_PINS_S 3
  77. #define AM_HAL_MCUCTRL_CHIP_INFO_TEMP_M 0x00000006
  78. #define AM_HAL_MCUCTRL_CHIP_INFO_TEMP_S 1
  79. #define AM_HAL_MCUCTRL_CHIP_INFO_QUAL_M 0x00000001
  80. #define AM_HAL_MCUCTRL_CHIP_INFO_QUAL_S 0
  81. //*****************************************************************************
  82. //
  83. // Apollo Number Decode.
  84. //
  85. //*****************************************************************************
  86. extern const uint32_t g_am_hal_mcuctrl_flash_size[];
  87. extern const uint32_t g_am_hal_mcuctrl_sram_size[];
  88. //*****************************************************************************
  89. //
  90. //! MCUCTRL device structure
  91. //
  92. //*****************************************************************************
  93. typedef struct
  94. {
  95. //
  96. //! Device part number. (BCD format)
  97. //
  98. uint32_t ui32ChipPN;
  99. //
  100. //! Unique Chip ID 0.
  101. //
  102. uint32_t ui32ChipID0;
  103. //
  104. //! Unique Chip ID 1.
  105. //
  106. uint32_t ui32ChipID1;
  107. //
  108. //! Chip Revision.
  109. //
  110. uint32_t ui32ChipRev;
  111. //
  112. //! Vendor ID.
  113. //
  114. uint32_t ui32VendorID;
  115. //
  116. //! Qualified chip.
  117. //
  118. uint32_t ui32Qualified;
  119. //
  120. //! Flash Size.
  121. //
  122. uint32_t ui32FlashSize;
  123. //
  124. //! SRAM Size.
  125. //
  126. uint32_t ui32SRAMSize;
  127. //
  128. // JEDEC chip info
  129. //
  130. uint32_t ui32JedecPN;
  131. uint32_t ui32JedecJEPID;
  132. uint32_t ui32JedecCHIPREV;
  133. uint32_t ui32JedecCID;
  134. }
  135. am_hal_mcuctrl_device_t;
  136. //*****************************************************************************
  137. //
  138. //! MCUCTRL fault structure
  139. //
  140. //*****************************************************************************
  141. typedef struct
  142. {
  143. //
  144. //! ICODE bus fault occurred.
  145. //
  146. bool bICODE;
  147. //
  148. //! ICODE bus fault address.
  149. //
  150. uint32_t ui32ICODE;
  151. //
  152. //! DCODE bus fault occurred.
  153. //
  154. bool bDCODE;
  155. //
  156. //! DCODE bus fault address.
  157. //
  158. uint32_t ui32DCODE;
  159. //
  160. //! SYS bus fault occurred.
  161. //
  162. bool bSYS;
  163. //
  164. //! SYS bus fault address.
  165. //
  166. uint32_t ui32SYS;
  167. }
  168. am_hal_mcuctrl_fault_t;
  169. //*****************************************************************************
  170. //
  171. // External function definitions
  172. //
  173. //*****************************************************************************
  174. extern void am_hal_mcuctrl_device_info_get(am_hal_mcuctrl_device_t *psDevice);
  175. extern void am_hal_mcuctrl_fault_capture_enable(void);
  176. extern void am_hal_mcuctrl_fault_capture_disable(void);
  177. extern void am_hal_mcuctrl_fault_status(am_hal_mcuctrl_fault_t *psFault);
  178. #ifdef __cplusplus
  179. }
  180. #endif
  181. #endif // AM_HAL_MCUCTRL_H
  182. //*****************************************************************************
  183. //
  184. // End Doxygen group.
  185. //! @}
  186. //
  187. //*****************************************************************************