system_MCIMX6Y2.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. ** ###################################################################
  3. ** Processors: MCIMX6Y2CVM05
  4. ** MCIMX6Y2CVM08
  5. ** MCIMX6Y2DVM05
  6. ** MCIMX6Y2DVM09
  7. **
  8. ** Compilers: Keil ARM C/C++ Compiler
  9. ** GNU C Compiler
  10. ** IAR ANSI C/C++ Compiler for ARM
  11. **
  12. ** Reference manual: IMX6ULLRM, Rev. 1, Feb. 2017
  13. ** Version: rev. 3.0, 2017-02-28
  14. ** Build: b170410
  15. **
  16. ** Abstract:
  17. ** Provides a system configuration function and a global variable that
  18. ** contains the system frequency. It configures the device and initializes
  19. ** the oscillator (PLL) that is part of the microcontroller device.
  20. **
  21. ** Copyright 2016 Freescale Semiconductor, Inc.
  22. ** Copyright 2016-2017 NXP
  23. ** Redistribution and use in source and binary forms, with or without modification,
  24. ** are permitted provided that the following conditions are met:
  25. **
  26. ** o Redistributions of source code must retain the above copyright notice, this list
  27. ** of conditions and the following disclaimer.
  28. **
  29. ** o Redistributions in binary form must reproduce the above copyright notice, this
  30. ** list of conditions and the following disclaimer in the documentation and/or
  31. ** other materials provided with the distribution.
  32. **
  33. ** o Neither the name of the copyright holder nor the names of its
  34. ** contributors may be used to endorse or promote products derived from this
  35. ** software without specific prior written permission.
  36. **
  37. ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  38. ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  39. ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  40. ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  41. ** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  42. ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  43. ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  44. ** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  45. ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  46. ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  47. **
  48. ** http: www.nxp.com
  49. ** mail: support@nxp.com
  50. **
  51. ** Revisions:
  52. ** - rev. 1.0 (2015-12-18)
  53. ** Initial version.
  54. ** - rev. 2.0 (2016-08-02)
  55. ** Rev.B Header GA
  56. ** - rev. 3.0 (2017-02-28)
  57. ** Rev.1 Header GA
  58. **
  59. ** ###################################################################
  60. */
  61. /*!
  62. * @file MCIMX6Y2
  63. * @version 3.0
  64. * @date 2017-02-28
  65. * @brief Device specific configuration file for MCIMX6Y2 (header file)
  66. *
  67. * Provides a system configuration function and a global variable that contains
  68. * the system frequency. It configures the device and initializes the oscillator
  69. * (PLL) that is part of the microcontroller device.
  70. */
  71. #ifndef _SYSTEM_MCIMX6Y2_H_
  72. #define _SYSTEM_MCIMX6Y2_H_ /**< Symbol preventing repeated inclusion */
  73. #ifdef __cplusplus
  74. extern "C" {
  75. #endif
  76. #include <stdint.h>
  77. #define DEFAULT_SYSTEM_CLOCK 528000000u /* Default System clock value */
  78. typedef void (*system_irq_handler_t) (uint32_t giccIar, void *param);
  79. /**
  80. * @brief IRQ handle for specific IRQ
  81. */
  82. typedef struct _sys_irq_handle
  83. {
  84. system_irq_handler_t irqHandler; /**< IRQ handler for specific IRQ */
  85. void *userParam; /**< User param for handler callback */
  86. } sys_irq_handle_t;
  87. /**
  88. * @brief System clock frequency (core clock)
  89. *
  90. * The system clock frequency supplied to the SysTick timer and the processor
  91. * core clock. This variable can be used by the user application to setup the
  92. * SysTick timer or configure other parameters. It may also be used by debugger to
  93. * query the frequency of the debug timer or configure the trace clock speed
  94. * SystemCoreClock is initialized with a correct predefined value.
  95. */
  96. extern uint32_t SystemCoreClock;
  97. /**
  98. * @brief Setup the microcontroller system.
  99. *
  100. * Typically this function configures the oscillator (PLL) that is part of the
  101. * microcontroller device. For systems with variable clock speed it also updates
  102. * the variable SystemCoreClock. SystemInit is called from startup_device file.
  103. */
  104. void SystemInit (void);
  105. /**
  106. * @brief Updates the SystemCoreClock variable.
  107. *
  108. * It must be called whenever the core clock is changed during program
  109. * execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates
  110. * the current core clock.
  111. */
  112. void SystemCoreClockUpdate (void);
  113. /**
  114. * @brief Initialize IRQ table, set default handlers
  115. */
  116. void SystemInitIrqTable (void);
  117. /**
  118. * @brief Install IRQ handler for specific IRQ
  119. *
  120. * It can't be called at interrupt context to avoid IRQ table corrupt during interrupt preemption
  121. *
  122. * @param irq IRQ number corresponds to the installed handler
  123. * @param handler IRQ handler for the IRQ number
  124. * @param userParam User specified parameter for IRQ handler callback
  125. */
  126. void SystemInstallIrqHandler (IRQn_Type irq, system_irq_handler_t handler, void *userParam);
  127. /**
  128. * @brief System IRQ handler which dispatches specific IRQ to corresponding registered handler.
  129. *
  130. * It is called from IRQ exception context and dispatches to registered handler according to
  131. * GICC_IAR interrupt number.
  132. * The default implementation is weak and user can override this function with his own SystemIrqHandler.
  133. *
  134. * @param giccIar IRQ acknowledge value read from GICC_IAR
  135. */
  136. void SystemIrqHandler (uint32_t giccIar);
  137. /**
  138. * @brief Get IRQ nesting level of current context.
  139. *
  140. * If the return value is 0, then the context is not ISR, otherwise the context is ISR.
  141. *
  142. * @return IRQ nesting level
  143. */
  144. uint32_t SystemGetIRQNestingLevel (void);
  145. /**
  146. * @brief Setup systick for RTOS system.
  147. *
  148. * @param tickRateHz Tick number per second
  149. * @param tickHandler IRQ callback handler for tick
  150. * @param intPriority IRQ interrupt priority (the smaller, the higher priority)
  151. */
  152. void SystemSetupSystick (uint32_t tickRateHz, void *tickHandler, uint32_t intPriority);
  153. /**
  154. * @brief Clear systick flag status so that next tick interrupt may occur.
  155. */
  156. void SystemClearSystickFlag (void);
  157. #ifdef __cplusplus
  158. }
  159. #endif
  160. #endif /* _SYSTEM_MCIMX6Y2_H_ */