sysclk.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /**
  2. * \file
  3. *
  4. * \brief System clock management
  5. *
  6. * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
  7. *
  8. * \asf_license_start
  9. *
  10. * \page License
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions are met:
  14. *
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. *
  18. * 2. Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. *
  22. * 3. The name of Atmel may not be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * 4. This software may only be redistributed and used in connection with an
  26. * Atmel microcontroller product.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
  29. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  30. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  31. * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
  32. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  34. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  36. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  37. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  38. * POSSIBILITY OF SUCH DAMAGE.
  39. *
  40. * \asf_license_stop
  41. *
  42. */
  43. /*
  44. * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
  45. */
  46. #ifndef SYSCLK_H_INCLUDED
  47. #define SYSCLK_H_INCLUDED
  48. #include "parts.h"
  49. #include "conf_clock.h"
  50. #if SAM3S
  51. # include "sam3s/sysclk.h"
  52. #elif SAM3U
  53. # include "sam3u/sysclk.h"
  54. #elif SAM3N
  55. # include "sam3n/sysclk.h"
  56. #elif SAM3XA
  57. # include "sam3x/sysclk.h"
  58. #elif SAM4S
  59. # include "sam4s/sysclk.h"
  60. #elif SAM4E
  61. # include "sam4e/sysclk.h"
  62. #elif SAM4C
  63. # include "sam4c/sysclk.h"
  64. #elif SAM4CM
  65. # include "sam4cm/sysclk.h"
  66. #elif SAM4CP
  67. # include "sam4cp/sysclk.h"
  68. #elif SAM4L
  69. # include "sam4l/sysclk.h"
  70. #elif SAM4N
  71. # include "sam4n/sysclk.h"
  72. #elif SAMG
  73. # include "samg/sysclk.h"
  74. #elif SAMV71
  75. # include "samv71/sysclk.h"
  76. #elif SAMV70
  77. # include "samv70/sysclk.h"
  78. #elif SAME70
  79. # include "same70/sysclk.h"
  80. #elif SAMS70
  81. # include "sams70/sysclk.h"
  82. #elif (UC3A0 || UC3A1)
  83. # include "uc3a0_a1/sysclk.h"
  84. #elif UC3A3
  85. # include "uc3a3_a4/sysclk.h"
  86. #elif UC3B
  87. # include "uc3b0_b1/sysclk.h"
  88. #elif UC3C
  89. # include "uc3c/sysclk.h"
  90. #elif UC3D
  91. # include "uc3d/sysclk.h"
  92. #elif UC3L
  93. # include "uc3l/sysclk.h"
  94. #elif XMEGA
  95. # include "xmega/sysclk.h"
  96. #elif MEGA
  97. # include "mega/sysclk.h"
  98. #else
  99. # error Unsupported chip type
  100. #endif
  101. /**
  102. * \defgroup clk_group Clock Management
  103. */
  104. /**
  105. * \ingroup clk_group
  106. * \defgroup sysclk_group System Clock Management
  107. *
  108. * See \ref sysclk_quickstart.
  109. *
  110. * The <em>sysclk</em> API covers the <em>system clock</em> and all
  111. * clocks derived from it. The system clock is a chip-internal clock on
  112. * which all <em>synchronous clocks</em>, i.e. CPU and bus/peripheral
  113. * clocks, are based. The system clock is typically generated from one
  114. * of a variety of sources, which may include crystal and RC oscillators
  115. * as well as PLLs. The clocks derived from the system clock are
  116. * sometimes also known as <em>synchronous clocks</em>, since they
  117. * always run synchronously with respect to each other, as opposed to
  118. * <em>generic clocks</em> which may run from different oscillators or
  119. * PLLs.
  120. *
  121. * Most applications should simply call sysclk_init() to initialize
  122. * everything related to the system clock and its source (oscillator,
  123. * PLL or DFLL), and leave it at that. More advanced applications, and
  124. * platform-specific drivers, may require additional services from the
  125. * clock system, some of which may be platform-specific.
  126. *
  127. * \section sysclk_group_platform Platform Dependencies
  128. *
  129. * The sysclk API is partially chip- or platform-specific. While all
  130. * platforms provide mostly the same functionality, there are some
  131. * variations around how different bus types and clock tree structures
  132. * are handled.
  133. *
  134. * The following functions are available on all platforms with the same
  135. * parameters and functionality. These functions may be called freely by
  136. * portable applications, drivers and services:
  137. * - sysclk_init()
  138. * - sysclk_set_source()
  139. * - sysclk_get_main_hz()
  140. * - sysclk_get_cpu_hz()
  141. * - sysclk_get_peripheral_bus_hz()
  142. *
  143. * The following functions are available on all platforms, but there may
  144. * be variations in the function signature (i.e. parameters) and
  145. * behavior. These functions are typically called by platform-specific
  146. * parts of drivers, and applications that aren't intended to be
  147. * portable:
  148. * - sysclk_enable_peripheral_clock()
  149. * - sysclk_disable_peripheral_clock()
  150. * - sysclk_enable_module()
  151. * - sysclk_disable_module()
  152. * - sysclk_module_is_enabled()
  153. * - sysclk_set_prescalers()
  154. *
  155. * All other functions should be considered platform-specific.
  156. * Enabling/disabling clocks to specific peripherals as well as
  157. * determining the speed of these clocks should be done by calling
  158. * functions provided by the driver for that peripheral.
  159. *
  160. * @{
  161. */
  162. //! \name System Clock Initialization
  163. //@{
  164. /**
  165. * \fn void sysclk_init(void)
  166. * \brief Initialize the synchronous clock system.
  167. *
  168. * This function will initialize the system clock and its source. This
  169. * includes:
  170. * - Mask all synchronous clocks except for any clocks which are
  171. * essential for normal operation (for example internal memory
  172. * clocks).
  173. * - Set up the system clock prescalers as specified by the
  174. * application's configuration file.
  175. * - Enable the clock source specified by the application's
  176. * configuration file (oscillator or PLL) and wait for it to become
  177. * stable.
  178. * - Set the main system clock source to the clock specified by the
  179. * application's configuration file.
  180. *
  181. * Since all non-essential peripheral clocks are initially disabled, it
  182. * is the responsibility of the peripheral driver to re-enable any
  183. * clocks that are needed for normal operation.
  184. */
  185. //@}
  186. //! @}
  187. #endif /* SYSCLK_H_INCLUDED */