]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_ATSAM3X_Atmel_Studio/src/asf/common/services/clock/genclk.h
Add SAM3X-EK demo.
[freertos] / FreeRTOS / Demo / CORTEX_ATSAM3X_Atmel_Studio / src / asf / common / services / clock / genclk.h
1 /**\r
2  * \file\r
3  *\r
4  * \brief Generic clock management\r
5  *\r
6  * Copyright (c) 2010-2011 Atmel Corporation. All rights reserved.\r
7  *\r
8  * \asf_license_start\r
9  *\r
10  * \page License\r
11  *\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
14  *\r
15  * 1. Redistributions of source code must retain the above copyright notice,\r
16  *    this list of conditions and the following disclaimer.\r
17  *\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
21  *\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
24  *\r
25  * 4. This software may only be redistributed and used in connection with an\r
26  *    Atmel microcontroller product.\r
27  *\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
39  *\r
40  * \asf_license_stop\r
41  *\r
42  */\r
43 #ifndef CLK_GENCLK_H_INCLUDED\r
44 #define CLK_GENCLK_H_INCLUDED\r
45 \r
46 #include "parts.h"\r
47 \r
48 #if SAM3S\r
49 # include "sam3s/genclk.h"\r
50 #elif SAM3U\r
51 # include "sam3u/genclk.h"\r
52 #elif SAM3N\r
53 # include "sam3n/genclk.h"\r
54 #elif SAM3XA\r
55 # include "sam3x/genclk.h"\r
56 #elif SAM4S\r
57 # include "sam4s/genclk.h"\r
58 #elif (UC3A0 || UC3A1)\r
59 # include "uc3a0_a1/genclk.h"\r
60 #elif UC3A3\r
61 # include "uc3a3_a4/genclk.h"\r
62 #elif UC3B\r
63 # include "uc3b0_b1/genclk.h"\r
64 #elif UC3C\r
65 # include "uc3c/genclk.h"\r
66 #elif UC3D\r
67 # include "uc3d/genclk.h"\r
68 #elif UC3L\r
69 # include "uc3l/genclk.h"\r
70 #else\r
71 # error Unsupported chip type\r
72 #endif\r
73 \r
74 /**\r
75  * \ingroup clk_group\r
76  * \defgroup genclk_group Generic Clock Management\r
77  *\r
78  * Generic clocks are configurable clocks which run outside the system\r
79  * clock domain. They are often connected to peripherals which have an\r
80  * asynchronous component running independently of the bus clock, e.g.\r
81  * USB controllers, low-power timers and RTCs, etc.\r
82  *\r
83  * Note that not all platforms have support for generic clocks; on such\r
84  * platforms, this API will not be available.\r
85  *\r
86  * @{\r
87  */\r
88 \r
89 /**\r
90  * \def GENCLK_DIV_MAX\r
91  * \brief Maximum divider supported by the generic clock implementation\r
92  */\r
93 /**\r
94  * \enum genclk_source\r
95  * \brief Generic clock source ID\r
96  *\r
97  * Each generic clock may be generated from a different clock source.\r
98  * These are the available alternatives provided by the chip.\r
99  */\r
100 \r
101 //! \name Generic clock configuration\r
102 //@{\r
103 /**\r
104  * \struct genclk_config\r
105  * \brief Hardware representation of a set of generic clock parameters\r
106  */\r
107 /**\r
108  * \fn void genclk_config_defaults(struct genclk_config *cfg,\r
109  *              unsigned int id)\r
110  * \brief Initialize \a cfg to the default configuration for the clock\r
111  * identified by \a id.\r
112  */\r
113 /**\r
114  * \fn void genclk_config_read(struct genclk_config *cfg, unsigned int id)\r
115  * \brief Read the currently active configuration of the clock\r
116  * identified by \a id into \a cfg.\r
117  */\r
118 /**\r
119  * \fn void genclk_config_write(const struct genclk_config *cfg,\r
120  *              unsigned int id)\r
121  * \brief Activate the configuration \a cfg on the clock identified by\r
122  * \a id.\r
123  */\r
124 /**\r
125  * \fn void genclk_config_set_source(struct genclk_config *cfg,\r
126  *              enum genclk_source src)\r
127  * \brief Select a new source clock \a src in configuration \a cfg.\r
128  */\r
129 /**\r
130  * \fn void genclk_config_set_divider(struct genclk_config *cfg,\r
131  *              unsigned int divider)\r
132  * \brief Set a new \a divider in configuration \a cfg.\r
133  */\r
134 /**\r
135  * \fn void genclk_enable_source(enum genclk_source src)\r
136  * \brief Enable the source clock \a src used by a generic clock.\r
137  */\r
138  //@}\r
139 \r
140 //! \name Enabling and disabling Generic Clocks\r
141 //@{\r
142 /**\r
143  * \fn void genclk_enable(const struct genclk_config *cfg, unsigned int id)\r
144  * \brief Activate the configuration \a cfg on the clock identified by\r
145  * \a id and enable it.\r
146  */\r
147 /**\r
148  * \fn void genclk_disable(unsigned int id)\r
149  * \brief Disable the generic clock identified by \a id.\r
150  */\r
151 //@}\r
152 \r
153 /**\r
154  * \brief Enable the configuration defined by \a src and \a divider\r
155  * for the generic clock identified by \a id.\r
156  *\r
157  * \param id      The ID of the generic clock.\r
158  * \param src     The source clock of the generic clock.\r
159  * \param divider The divider used to generate the generic clock.\r
160  */\r
161 static inline void genclk_enable_config(unsigned int id, enum genclk_source src, unsigned int divider)\r
162 {\r
163         struct genclk_config gcfg;\r
164 \r
165         genclk_config_defaults(&gcfg, id);\r
166         genclk_enable_source(src);\r
167         genclk_config_set_source(&gcfg, src);\r
168         genclk_config_set_divider(&gcfg, divider);\r
169         genclk_enable(&gcfg, id);\r
170 }\r
171 \r
172 //! @}\r
173 \r
174 #endif /* CLK_GENCLK_H_INCLUDED */\r