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