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