system_ac7840x.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* Copyright Statement:
  2. *
  3. * This software/firmware and related documentation ("AutoChips Software") are
  4. * protected under relevant copyright laws. The information contained herein is
  5. * confidential and proprietary to AutoChips Inc. and/or its licensors. Without
  6. * the prior written permission of AutoChips inc. and/or its licensors, any
  7. * reproduction, modification, use or disclosure of AutoChips Software, and
  8. * information contained herein, in whole or in part, shall be strictly
  9. * prohibited.
  10. *
  11. * AutoChips Inc. (C) 2021. All rights reserved.
  12. *
  13. * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  14. * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("AUTOCHIPS SOFTWARE")
  15. * RECEIVED FROM AUTOCHIPS AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
  16. * ON AN "AS-IS" BASIS ONLY. AUTOCHIPS EXPRESSLY DISCLAIMS ANY AND ALL
  17. * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
  19. * NONINFRINGEMENT. NEITHER DOES AUTOCHIPS PROVIDE ANY WARRANTY WHATSOEVER WITH
  20. * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
  21. * INCORPORATED IN, OR SUPPLIED WITH THE AUTOCHIPS SOFTWARE, AND RECEIVER AGREES
  22. * TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
  23. * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
  24. * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN AUTOCHIPS
  25. * SOFTWARE. AUTOCHIPS SHALL ALSO NOT BE RESPONSIBLE FOR ANY AUTOCHIPS SOFTWARE
  26. * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
  27. * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND AUTOCHIPS'S
  28. * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE AUTOCHIPS SOFTWARE
  29. * RELEASED HEREUNDER WILL BE, AT AUTOCHIPS'S OPTION, TO REVISE OR REPLACE THE
  30. * AUTOCHIPS SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
  31. * CHARGE PAID BY RECEIVER TO AUTOCHIPS FOR SUCH AUTOCHIPS SOFTWARE AT ISSUE.
  32. */
  33. /*!
  34. * @file system_ac7840x.h
  35. *
  36. * @brief This file provides system clock config integration functions interfaces.
  37. *
  38. */
  39. #ifndef _SYSTEM_AC7840X_H
  40. #define _SYSTEM_AC7840X_H
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. /* =========================================== Includes =========================================== */
  45. #include <stdint.h>
  46. /* ============================================ Define ============================================ */
  47. /*!< Sram ECC read enable */
  48. #define SRAM_ECC_READ_ENABLE (1UL)
  49. /*!< Sram ECC 2bit error reset enable */
  50. #define SRAM_ECC_ERR_RST_ENABLE (0UL)
  51. /*!< Watchdog disable */
  52. #ifndef WDG_DISABLE
  53. #define WDG_DISABLE (1UL)
  54. #endif
  55. /*!< Default system clock */
  56. #define DEFAULT_SYSTEM_CLOCK (48000000UL)
  57. /*!< Default HSE(XOSC) frequency or user define */
  58. #define CKGEN_HSE_FREQ (8000000UL)
  59. /*!< System clock uses ckgen driver */
  60. #define SYSTEM_USE_CKGEN (0UL)
  61. /*!< Global interrupt control */
  62. #define EnableInterrupts __asm("CPSIE i");
  63. #define DisableInterrupts __asm("CPSID i");
  64. /*!< Global fault control */
  65. #define EnableFatules __asm("CPSIE F");
  66. #define DisableFatules __asm("CPSID F");
  67. /* =========================================== Typedef ============================================ */
  68. /* ========================================== Variables =========================================== */
  69. /* ==================================== Functions declaration ===================================== */
  70. /*!
  71. * @brief Initialize SPLL then set system clock to the SPLL clock
  72. * (just support SPLL refer clock 4/8/12/16/30MHz, others need to modify).
  73. *
  74. * @param[in] refClk: 0: HSI clock, 1: HSE clock
  75. * @param[in] freq: SPLL out frequency (16 - 120)
  76. * @return status 0: success others: error
  77. */
  78. uint32_t SetSysClkToSPLL(uint8_t refClk, uint8_t freq);
  79. /*!
  80. * @brief Initialize VHSI then set system clock to the VHSI clock.
  81. *
  82. * @param[in] none
  83. * @return status 0: success others: error
  84. */
  85. uint32_t SetSysClkToVHSI(void);
  86. /*!
  87. * @brief Initialize HSE then set system clock to the HSE clock.
  88. *
  89. * @param[in] bypass: 0: disable, 1: enable
  90. * @return status 0: success others: error
  91. */
  92. uint32_t SetSysClkToHSE(uint8_t bypass);
  93. /*!
  94. * @brief Initialize HSI then set system clock to the HSI clock.
  95. *
  96. * @param[in] none
  97. * @return status 0: success others: error
  98. */
  99. uint32_t SetSysClkToHSI(void);
  100. /*!
  101. * @brief Get UUID from devie
  102. *
  103. * @param[out] uuidBuffer: UUID buffer
  104. * @return none
  105. */
  106. void GetUUID(uint32_t *uuidBuffer);
  107. /*!
  108. * @brief Setup the microcontroller system. Initialize the System.
  109. *
  110. * @param[in] none
  111. * @return none
  112. */
  113. void SystemInit(void);
  114. /*!
  115. * @brief Update system clock frequence.
  116. *
  117. * @param[in] none
  118. * @return none
  119. */
  120. void SystemCoreClockUpdate(void);
  121. /*!
  122. * @brief Enable NMI, after set pinmux.
  123. *
  124. * @param[in] enable: enable state
  125. * @return none
  126. */
  127. void EnableNMI(uint8_t enable);
  128. #ifdef __cplusplus
  129. }
  130. #endif /* __cplusplus */
  131. #endif /* _SYSTEM_AC7840X_H */
  132. /* ============================================= EOF ============================================== */