4 * \brief System clock management
\r
6 * Copyright (c) 2010-2012 Atmel Corporation. All rights reserved.
\r
12 * Redistribution and use in source and binary forms, with or without
\r
13 * modification, are permitted provided that the following conditions are met:
\r
15 * 1. Redistributions of source code must retain the above copyright notice,
\r
16 * this list of conditions and the following disclaimer.
\r
18 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
19 * this list of conditions and the following disclaimer in the documentation
\r
20 * and/or other materials provided with the distribution.
\r
22 * 3. The name of Atmel may not be used to endorse or promote products derived
\r
23 * from this software without specific prior written permission.
\r
25 * 4. This software may only be redistributed and used in connection with an
\r
26 * Atmel microcontroller product.
\r
28 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
\r
29 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
30 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
31 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
\r
32 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
\r
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
\r
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
\r
36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
\r
37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
38 * POSSIBILITY OF SUCH DAMAGE.
\r
43 #ifndef SYSCLK_H_INCLUDED
\r
44 #define SYSCLK_H_INCLUDED
\r
47 #include "conf_clock.h"
\r
50 # include "sam3s/sysclk.h"
\r
52 # include "sam3u/sysclk.h"
\r
54 # include "sam3n/sysclk.h"
\r
56 # include "sam3x/sysclk.h"
\r
58 # include "sam4s/sysclk.h"
\r
59 #elif (UC3A0 || UC3A1)
\r
60 # include "uc3a0_a1/sysclk.h"
\r
62 # include "uc3a3_a4/sysclk.h"
\r
64 # include "uc3b0_b1/sysclk.h"
\r
66 # include "uc3c/sysclk.h"
\r
68 # include "uc3d/sysclk.h"
\r
70 # include "uc3l/sysclk.h"
\r
72 # include "xmega/sysclk.h"
\r
74 # error Unsupported chip type
\r
78 * \defgroup clk_group Clock Management
\r
82 * \ingroup clk_group
\r
83 * \defgroup sysclk_group System Clock Management
\r
85 * See \ref sysclk_quickstart.
\r
87 * The <em>sysclk</em> API covers the <em>system clock</em> and all
\r
88 * clocks derived from it. The system clock is a chip-internal clock on
\r
89 * which all <em>synchronous clocks</em>, i.e. CPU and bus/peripheral
\r
90 * clocks, are based. The system clock is typically generated from one
\r
91 * of a variety of sources, which may include crystal and RC oscillators
\r
92 * as well as PLLs. The clocks derived from the system clock are
\r
93 * sometimes also known as <em>synchronous clocks</em>, since they
\r
94 * always run synchronously with respect to each other, as opposed to
\r
95 * <em>generic clocks</em> which may run from different oscillators or
\r
98 * Most applications should simply call sysclk_init() to initialize
\r
99 * everything related to the system clock and its source (oscillator,
\r
100 * PLL or DFLL), and leave it at that. More advanced applications, and
\r
101 * platform-specific drivers, may require additional services from the
\r
102 * clock system, some of which may be platform-specific.
\r
104 * \section sysclk_group_platform Platform Dependencies
\r
106 * The sysclk API is partially chip- or platform-specific. While all
\r
107 * platforms provide mostly the same functionality, there are some
\r
108 * variations around how different bus types and clock tree structures
\r
111 * The following functions are available on all platforms with the same
\r
112 * parameters and functionality. These functions may be called freely by
\r
113 * portable applications, drivers and services:
\r
115 * - sysclk_set_source()
\r
116 * - sysclk_get_main_hz()
\r
117 * - sysclk_get_cpu_hz()
\r
118 * - sysclk_get_peripheral_bus_hz()
\r
120 * The following functions are available on all platforms, but there may
\r
121 * be variations in the function signature (i.e. parameters) and
\r
122 * behavior. These functions are typically called by platform-specific
\r
123 * parts of drivers, and applications that aren't intended to be
\r
125 * - sysclk_enable_peripheral_clock()
\r
126 * - sysclk_disable_peripheral_clock()
\r
127 * - sysclk_enable_module()
\r
128 * - sysclk_disable_module()
\r
129 * - sysclk_module_is_enabled()
\r
130 * - sysclk_set_prescalers()
\r
132 * All other functions should be considered platform-specific.
\r
133 * Enabling/disabling clocks to specific peripherals as well as
\r
134 * determining the speed of these clocks should be done by calling
\r
135 * functions provided by the driver for that peripheral.
\r
140 //! \name System Clock Initialization
\r
143 * \fn void sysclk_init(void)
\r
144 * \brief Initialize the synchronous clock system.
\r
146 * This function will initialize the system clock and its source. This
\r
148 * - Mask all synchronous clocks except for any clocks which are
\r
149 * essential for normal operation (for example internal memory
\r
151 * - Set up the system clock prescalers as specified by the
\r
152 * application's configuration file.
\r
153 * - Enable the clock source specified by the application's
\r
154 * configuration file (oscillator or PLL) and wait for it to become
\r
156 * - Set the main system clock source to the clock specified by the
\r
157 * application's configuration file.
\r
159 * Since all non-essential peripheral clocks are initially disabled, it
\r
160 * is the responsibility of the peripheral driver to re-enable any
\r
161 * clocks that are needed for normal operation.
\r
167 #endif /* SYSCLK_H_INCLUDED */
\r