]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/asf/common/services/clock/genclk.h
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / CORTEX_M4_ATSAM4S_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  * Redistribution and use in source and binary forms, with or without\r
11  * modification, are permitted provided that the following conditions are met:\r
12  *\r
13  * 1. Redistributions of source code must retain the above copyright notice,\r
14  *    this list of conditions and the following disclaimer.\r
15  *\r
16  * 2. Redistributions in binary form must reproduce the above copyright notice,\r
17  *    this list of conditions and the following disclaimer in the documentation\r
18  *    and/or other materials provided with the distribution.\r
19  *\r
20  * 3. The name of Atmel may not be used to endorse or promote products derived\r
21  *    from this software without specific prior written permission.\r
22  *\r
23  * 4. This software may only be redistributed and used in connection with an\r
24  *    Atmel microcontroller product.\r
25  *\r
26  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED\r
27  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
28  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
29  * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR\r
30  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\r
34  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
35  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
36  * POSSIBILITY OF SUCH DAMAGE.\r
37  *\r
38  * \asf_license_stop\r
39  *\r
40  */\r
41 #ifndef CLK_GENCLK_H_INCLUDED\r
42 #define CLK_GENCLK_H_INCLUDED\r
43 \r
44 #include "parts.h"\r
45 \r
46 #if SAM3S\r
47 # include "sam3s/genclk.h"\r
48 #elif SAM3U\r
49 # include "sam3u/genclk.h"\r
50 #elif SAM3N\r
51 # include "sam3n/genclk.h"\r
52 #elif SAM3XA\r
53 # include "sam3x/genclk.h"\r
54 #elif SAM4S\r
55 # include "sam4s/genclk.h"\r
56 #elif (UC3A0 || UC3A1)\r
57 # include "uc3a0_a1/genclk.h"\r
58 #elif UC3A3\r
59 # include "uc3a3_a4/genclk.h"\r
60 #elif UC3B\r
61 # include "uc3b0_b1/genclk.h"\r
62 #elif UC3C\r
63 # include "uc3c/genclk.h"\r
64 #elif UC3D\r
65 # include "uc3d/genclk.h"\r
66 #elif UC3L\r
67 # include "uc3l/genclk.h"\r
68 #else\r
69 # error Unsupported chip type\r
70 #endif\r
71 \r
72 /**\r
73  * \ingroup clk_group\r
74  * \defgroup genclk_group Generic Clock Management\r
75  *\r
76  * Generic clocks are configurable clocks which run outside the system\r
77  * clock domain. They are often connected to peripherals which have an\r
78  * asynchronous component running independently of the bus clock, e.g.\r
79  * USB controllers, low-power timers and RTCs, etc.\r
80  *\r
81  * Note that not all platforms have support for generic clocks; on such\r
82  * platforms, this API will not be available.\r
83  *\r
84  * @{\r
85  */\r
86 \r
87 /**\r
88  * \def GENCLK_DIV_MAX\r
89  * \brief Maximum divider supported by the generic clock implementation\r
90  */\r
91 /**\r
92  * \enum genclk_source\r
93  * \brief Generic clock source ID\r
94  *\r
95  * Each generic clock may be generated from a different clock source.\r
96  * These are the available alternatives provided by the chip.\r
97  */\r
98 \r
99 //! \name Generic clock configuration\r
100 //@{\r
101 /**\r
102  * \struct genclk_config\r
103  * \brief Hardware representation of a set of generic clock parameters\r
104  */\r
105 /**\r
106  * \fn void genclk_config_defaults(struct genclk_config *cfg,\r
107  *              unsigned int id)\r
108  * \brief Initialize \a cfg to the default configuration for the clock\r
109  * identified by \a id.\r
110  */\r
111 /**\r
112  * \fn void genclk_config_read(struct genclk_config *cfg, unsigned int id)\r
113  * \brief Read the currently active configuration of the clock\r
114  * identified by \a id into \a cfg.\r
115  */\r
116 /**\r
117  * \fn void genclk_config_write(const struct genclk_config *cfg,\r
118  *              unsigned int id)\r
119  * \brief Activate the configuration \a cfg on the clock identified by\r
120  * \a id.\r
121  */\r
122 /**\r
123  * \fn void genclk_config_set_source(struct genclk_config *cfg,\r
124  *              enum genclk_source src)\r
125  * \brief Select a new source clock \a src in configuration \a cfg.\r
126  */\r
127 /**\r
128  * \fn void genclk_config_set_divider(struct genclk_config *cfg,\r
129  *              unsigned int divider)\r
130  * \brief Set a new \a divider in configuration \a cfg.\r
131  */\r
132 /**\r
133  * \fn void genclk_enable_source(enum genclk_source src)\r
134  * \brief Enable the source clock \a src used by a generic clock.\r
135  */\r
136  //@}\r
137 \r
138 //! \name Enabling and disabling Generic Clocks\r
139 //@{\r
140 /**\r
141  * \fn void genclk_enable(const struct genclk_config *cfg, unsigned int id)\r
142  * \brief Activate the configuration \a cfg on the clock identified by\r
143  * \a id and enable it.\r
144  */\r
145 /**\r
146  * \fn void genclk_disable(unsigned int id)\r
147  * \brief Disable the generic clock identified by \a id.\r
148  */\r
149 //@}\r
150 \r
151 /**\r
152  * \brief Enable the configuration defined by \a src and \a divider\r
153  * for the generic clock identified by \a id.\r
154  *\r
155  * \param id      The ID of the generic clock.\r
156  * \param src     The source clock of the generic clock.\r
157  * \param divider The divider used to generate the generic clock.\r
158  */\r
159 static inline void genclk_enable_config(unsigned int id, enum genclk_source src, unsigned int divider)\r
160 {\r
161         struct genclk_config gcfg;\r
162 \r
163         genclk_config_defaults(&gcfg, id);\r
164         genclk_enable_source(src);\r
165         genclk_config_set_source(&gcfg, src);\r
166         genclk_config_set_divider(&gcfg, divider);\r
167         genclk_enable(&gcfg, id);\r
168 }\r
169 \r
170 //! @}\r
171 \r
172 #endif /* CLK_GENCLK_H_INCLUDED */\r