]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/asf/common/services/clock/genclk.h
Add SAM4L demo.
[freertos] / FreeRTOS / Demo / CORTEX_M4_ATSAM4L_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-2012 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 SAM4L\r
59 # include "sam4l/genclk.h"\r
60 #elif SAM4E\r
61 # include "sam4e/genclk.h"\r
62 #elif (UC3A0 || UC3A1)\r
63 # include "uc3a0_a1/genclk.h"\r
64 #elif UC3A3\r
65 # include "uc3a3_a4/genclk.h"\r
66 #elif UC3B\r
67 # include "uc3b0_b1/genclk.h"\r
68 #elif UC3C\r
69 # include "uc3c/genclk.h"\r
70 #elif UC3D\r
71 # include "uc3d/genclk.h"\r
72 #elif UC3L\r
73 # include "uc3l/genclk.h"\r
74 #else\r
75 # error Unsupported chip type\r
76 #endif\r
77 \r
78 /**\r
79  * \ingroup clk_group\r
80  * \defgroup genclk_group Generic Clock Management\r
81  *\r
82  * Generic clocks are configurable clocks which run outside the system\r
83  * clock domain. They are often connected to peripherals which have an\r
84  * asynchronous component running independently of the bus clock, e.g.\r
85  * USB controllers, low-power timers and RTCs, etc.\r
86  *\r
87  * Note that not all platforms have support for generic clocks; on such\r
88  * platforms, this API will not be available.\r
89  *\r
90  * @{\r
91  */\r
92 \r
93 /**\r
94  * \def GENCLK_DIV_MAX\r
95  * \brief Maximum divider supported by the generic clock implementation\r
96  */\r
97 /**\r
98  * \enum genclk_source\r
99  * \brief Generic clock source ID\r
100  *\r
101  * Each generic clock may be generated from a different clock source.\r
102  * These are the available alternatives provided by the chip.\r
103  */\r
104 \r
105 //! \name Generic clock configuration\r
106 //@{\r
107 /**\r
108  * \struct genclk_config\r
109  * \brief Hardware representation of a set of generic clock parameters\r
110  */\r
111 /**\r
112  * \fn void genclk_config_defaults(struct genclk_config *cfg,\r
113  *              unsigned int id)\r
114  * \brief Initialize \a cfg to the default configuration for the clock\r
115  * identified by \a id.\r
116  */\r
117 /**\r
118  * \fn void genclk_config_read(struct genclk_config *cfg, unsigned int id)\r
119  * \brief Read the currently active configuration of the clock\r
120  * identified by \a id into \a cfg.\r
121  */\r
122 /**\r
123  * \fn void genclk_config_write(const struct genclk_config *cfg,\r
124  *              unsigned int id)\r
125  * \brief Activate the configuration \a cfg on the clock identified by\r
126  * \a id.\r
127  */\r
128 /**\r
129  * \fn void genclk_config_set_source(struct genclk_config *cfg,\r
130  *              enum genclk_source src)\r
131  * \brief Select a new source clock \a src in configuration \a cfg.\r
132  */\r
133 /**\r
134  * \fn void genclk_config_set_divider(struct genclk_config *cfg,\r
135  *              unsigned int divider)\r
136  * \brief Set a new \a divider in configuration \a cfg.\r
137  */\r
138 /**\r
139  * \fn void genclk_enable_source(enum genclk_source src)\r
140  * \brief Enable the source clock \a src used by a generic clock.\r
141  */\r
142  //@}\r
143 \r
144 //! \name Enabling and disabling Generic Clocks\r
145 //@{\r
146 /**\r
147  * \fn void genclk_enable(const struct genclk_config *cfg, unsigned int id)\r
148  * \brief Activate the configuration \a cfg on the clock identified by\r
149  * \a id and enable it.\r
150  */\r
151 /**\r
152  * \fn void genclk_disable(unsigned int id)\r
153  * \brief Disable the generic clock identified by \a id.\r
154  */\r
155 //@}\r
156 \r
157 /**\r
158  * \brief Enable the configuration defined by \a src and \a divider\r
159  * for the generic clock identified by \a id.\r
160  *\r
161  * \param id      The ID of the generic clock.\r
162  * \param src     The source clock of the generic clock.\r
163  * \param divider The divider used to generate the generic clock.\r
164  */\r
165 static inline void genclk_enable_config(unsigned int id, enum genclk_source src, unsigned int divider)\r
166 {\r
167         struct genclk_config gcfg;\r
168 \r
169         genclk_config_defaults(&gcfg, id);\r
170         genclk_enable_source(src);\r
171         genclk_config_set_source(&gcfg, src);\r
172         genclk_config_set_divider(&gcfg, divider);\r
173         genclk_enable(&gcfg, id);\r
174 }\r
175 \r
176 //! @}\r
177 \r
178 #endif /* CLK_GENCLK_H_INCLUDED */\r