OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [lwIP_AVR32_UC3/] [DRIVERS/] [PM/] [pm.h] - Blame information for rev 604

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 583 jeremybenn
/*This file has been prepared for Doxygen automatic documentation generation.*/
2
/*! \file *********************************************************************
3
 *
4
 * \brief Power Manager driver.
5
 *
6
 *
7
 * - Compiler:           IAR EWAVR32 and GNU GCC for AVR32
8
 * - Supported devices:  All AVR32 devices.
9
 * - AppNote:
10
 *
11
 * \author               Atmel Corporation: http://www.atmel.com \n
12
 *                       Support and FAQ: http://support.atmel.no/
13
 *
14
 *****************************************************************************/
15
 
16
/* Copyright (c) 2007, Atmel Corporation All rights reserved.
17
 *
18
 * Redistribution and use in source and binary forms, with or without
19
 * modification, are permitted provided that the following conditions are met:
20
 *
21
 * 1. Redistributions of source code must retain the above copyright notice,
22
 * this list of conditions and the following disclaimer.
23
 *
24
 * 2. Redistributions in binary form must reproduce the above copyright notice,
25
 * this list of conditions and the following disclaimer in the documentation
26
 * and/or other materials provided with the distribution.
27
 *
28
 * 3. The name of ATMEL may not be used to endorse or promote products derived
29
 * from this software without specific prior written permission.
30
 *
31
 * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
32
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
33
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
34
 * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
35
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
40
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
 */
42
 
43
 
44
#ifndef _PM_H_
45
#define _PM_H_
46
 
47
#include <avr32/io.h>
48
#include "compiler.h"
49
#include "preprocessor.h"
50
 
51
 
52
/*! \brief Sets the MCU in the specified sleep mode.
53
 *
54
 * \param mode Sleep mode:
55
 *   \arg \c AVR32_PM_SMODE_IDLE: Idle;
56
 *   \arg \c AVR32_PM_SMODE_FROZEN: Frozen;
57
 *   \arg \c AVR32_PM_SMODE_STANDBY: Standby;
58
 *   \arg \c AVR32_PM_SMODE_STOP: Stop;
59
 *   \arg \c AVR32_PM_SMODE_SHUTDOWN: Shutdown (DeepStop);
60
 *   \arg \c AVR32_PM_SMODE_STATIC: Static.
61
 */
62
#define SLEEP(mode)   {__asm__ __volatile__ ("sleep "STRINGZ(mode));}
63
 
64
 
65
/*! \brief Gets the MCU reset cause.
66
 *
67
 * \param pm Base address of the Power Manager instance (i.e. &AVR32_PM).
68
 *
69
 * \return The MCU reset cause which can be masked with the
70
 *         \c AVR32_PM_RCAUSE_x_MASK bit-masks to isolate specific causes.
71
 */
72
#if __GNUC__
73
__attribute__((__always_inline__))
74
#endif
75
extern __inline__ unsigned int pm_get_reset_cause(volatile avr32_pm_t *pm)
76
{
77
  return pm->rcause;
78
}
79
 
80
 
81
/*!
82
 * \brief This function will enable the external clock mode of the oscillator 0.
83
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
84
 */
85
extern void pm_enable_osc0_ext_clock(volatile avr32_pm_t *pm);
86
 
87
 
88
/*!
89
 * \brief This function will enable the crystal mode of the oscillator 0.
90
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
91
 * \param fosc0 Oscillator 0 crystal frequency (Hz)
92
 */
93
extern void pm_enable_osc0_crystal(volatile avr32_pm_t *pm, unsigned int fosc0);
94
 
95
 
96
/*!
97
 * \brief This function will enable the oscillator 0 to be used with a startup time.
98
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
99
 * \param startup Clock 0 startup time. Time is expressed in term of RCOsc periods (3-bit value)
100
 */
101
extern void pm_enable_clk0(volatile avr32_pm_t *pm, unsigned int startup);
102
 
103
 
104
/*!
105
 * \brief This function will disable the oscillator 0.
106
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
107
 */
108
extern void pm_disable_clk0(volatile avr32_pm_t *pm);
109
 
110
 
111
/*!
112
 * \brief This function will enable the oscillator 0 to be used with no startup time.
113
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
114
 * \param startup Clock 0 startup time. Time is expressed in term of RCOsc periods (3-bit value) but not checked.
115
 */
116
extern void pm_enable_clk0_no_wait(volatile avr32_pm_t *pm, unsigned int startup);
117
 
118
 
119
/*!
120
 * \brief This function will wait until the Osc0 clock is ready.
121
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
122
 */
123
extern void pm_wait_for_clk0_ready(volatile avr32_pm_t *pm);
124
 
125
 
126
/*!
127
 * \brief This function will enable the external clock mode of the oscillator 1.
128
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
129
 */
130
extern void pm_enable_osc1_ext_clock(volatile avr32_pm_t *pm);
131
 
132
 
133
/*!
134
 * \brief This function will enable the crystal mode of the oscillator 1.
135
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
136
 * \param fosc1 Oscillator 1 crystal frequency (Hz)
137
 */
138
extern void pm_enable_osc1_crystal(volatile avr32_pm_t *pm, unsigned int fosc1);
139
 
140
 
141
/*!
142
 * \brief This function will enable the oscillator 1 to be used with a startup time.
143
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
144
 * \param startup Clock 1 startup time. Time is expressed in term of RCOsc periods (3-bit value)
145
 */
146
extern void pm_enable_clk1(volatile avr32_pm_t *pm, unsigned int startup);
147
 
148
 
149
/*!
150
 * \brief This function will disable the oscillator 1.
151
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
152
 */
153
extern void pm_disable_clk1(volatile avr32_pm_t *pm);
154
 
155
 
156
/*!
157
 * \brief This function will enable the oscillator 1 to be used with no startup time.
158
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
159
 * \param startup Clock 1 startup time. Time is expressed in term of RCOsc periods (3-bit value) but not checked.
160
 */
161
extern void pm_enable_clk1_no_wait(volatile avr32_pm_t *pm, unsigned int startup);
162
 
163
 
164
/*!
165
 * \brief This function will wait until the Osc1 clock is ready.
166
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
167
 */
168
extern void pm_wait_for_clk1_ready(volatile avr32_pm_t *pm);
169
 
170
 
171
/*!
172
 * \brief This function will enable the external clock mode of the 32-kHz oscillator.
173
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
174
 */
175
extern void pm_enable_osc32_ext_clock(volatile avr32_pm_t *pm);
176
 
177
 
178
/*!
179
 * \brief This function will enable the crystal mode of the 32-kHz oscillator.
180
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
181
 */
182
extern void pm_enable_osc32_crystal(volatile avr32_pm_t *pm);
183
 
184
 
185
/*!
186
 * \brief This function will enable the oscillator 32 to be used with a startup time.
187
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
188
 * \param startup Clock 32 kHz startup time. Time is expressed in term of RCOsc periods (3-bit value)
189
 */
190
extern void pm_enable_clk32(volatile avr32_pm_t *pm, unsigned int startup);
191
 
192
 
193
/*!
194
 * \brief This function will disable the oscillator 32.
195
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
196
 */
197
extern void pm_disable_clk32(volatile avr32_pm_t *pm);
198
 
199
 
200
/*!
201
 * \brief This function will enable the oscillator 32 to be used with no startup time.
202
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
203
 * \param startup Clock 32 kHz startup time. Time is expressed in term of RCOsc periods (3-bit value) but not checked.
204
 */
205
extern void pm_enable_clk32_no_wait(volatile avr32_pm_t *pm, unsigned int startup);
206
 
207
 
208
/*!
209
 * \brief This function will wait until the osc32 clock is ready.
210
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
211
 */
212
extern void pm_wait_for_clk32_ready(volatile avr32_pm_t *pm);
213
 
214
 
215
/*!
216
 * \brief This function will select all the power manager clocks.
217
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
218
 * \param pbadiv Peripheral Bus A clock divisor enable
219
 * \param pbasel Peripheral Bus A select
220
 * \param pbbdiv Peripheral Bus B clock divisor enable
221
 * \param pbbsel Peripheral Bus B select
222
 * \param hsbdiv High Speed Bus clock divisor enable (CPU clock = HSB clock)
223
 * \param hsbsel High Speed Bus select (CPU clock = HSB clock )
224
 */
225
extern void pm_cksel(volatile avr32_pm_t *pm, unsigned int pbadiv, unsigned int pbasel, unsigned int pbbdiv, unsigned int pbbsel, unsigned int hsbdiv, unsigned int hsbsel);
226
 
227
 
228
/*!
229
 * \brief This function will setup a generic clock.
230
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
231
 * \param gc generic clock number (0 for gc0...)
232
 * \param osc_or_pll Use OSC (=0) or PLL (=1)
233
 * \param pll_osc Select Osc0/PLL0 or Osc1/PLL1
234
 * \param diven Generic clock divisor enable
235
 * \param div Generic clock divisor
236
 */
237
extern void pm_gc_setup(volatile avr32_pm_t *pm, unsigned int gc, unsigned int osc_or_pll, unsigned int pll_osc, unsigned int diven, unsigned int div);
238
 
239
 
240
/*!
241
 * \brief This function will enable a generic clock.
242
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
243
 * \param gc generic clock number (0 for gc0...)
244
 */
245
extern void pm_gc_enable(volatile avr32_pm_t *pm, unsigned int gc);
246
 
247
 
248
/*!
249
 * \brief This function will disable a generic clock.
250
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
251
 * \param gc generic clock number (0 for gc0...)
252
 */
253
extern void pm_gc_disable(volatile avr32_pm_t *pm, unsigned int gc);
254
 
255
 
256
/*!
257
 * \brief This function will setup a PLL.
258
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
259
 * \param pll PLL number(0 for PLL0, 1 for PLL1)
260
 * \param mul PLL MUL in the PLL formula
261
 * \param div PLL DIV in the PLL formula
262
 * \param osc OSC number (0 for osc0, 1 for osc1)
263
 * \param lockcount PLL lockount
264
 */
265
extern void pm_pll_setup(volatile avr32_pm_t *pm, unsigned int pll, unsigned int mul, unsigned int div, unsigned int osc, unsigned int lockcount);
266
 
267
 
268
/*!
269
 * \brief This function will set a PLL option.
270
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
271
 * \param pll PLL number(0 for PLL0, 1 for PLL1)
272
 * \param pll_freq Set to 1 for VCO frequency range 80-180MHz, set to 0 for VCO frequency range 160-240Mhz.
273
 * \param pll_div2 Divide the PLL output frequency by 2 (this settings does not change the FVCO value)
274
 * \param pll_wbwdisable 1 Disable the Wide-Bandith Mode (Wide-Bandwith mode allow a faster startup time and out-of-lock time). 0 to enable the Wide-Bandith Mode.
275
 */
276
extern void pm_pll_set_option(volatile avr32_pm_t *pm, unsigned int pll, unsigned int  pll_freq, unsigned int  pll_div2, unsigned int  pll_wbwdisable);
277
 
278
 
279
/*!
280
 * \brief This function will get a PLL option.
281
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
282
 * \param pll PLL number(0 for PLL0, 1 for PLL1)
283
 * \return       Option
284
 */
285
extern unsigned int pm_pll_get_option(volatile avr32_pm_t *pm, unsigned int pll);
286
 
287
 
288
/*!
289
 * \brief This function will enable a PLL.
290
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
291
 * \param pll PLL number(0 for PLL0, 1 for PLL1)
292
 */
293
extern void pm_pll_enable(volatile avr32_pm_t *pm, unsigned int pll);
294
 
295
 
296
/*!
297
 * \brief This function will disable a PLL.
298
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
299
 * \param pll PLL number(0 for PLL0, 1 for PLL1)
300
 */
301
extern void pm_pll_disable(volatile avr32_pm_t *pm, unsigned int pll);
302
 
303
 
304
/*!
305
 * \brief This function will wait for PLL0 locked
306
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
307
 */
308
extern void pm_wait_for_pll0_locked(volatile avr32_pm_t *pm);
309
 
310
 
311
/*!
312
 * \brief This function will wait for PLL1 locked
313
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
314
 */
315
extern void pm_wait_for_pll1_locked(volatile avr32_pm_t *pm);
316
 
317
 
318
/*!
319
 * \brief This function will switch the power manager main clock.
320
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
321
 * \param clock Clock to be switched on. AVR32_PM_MCSEL_SLOW for RCOsc, AVR32_PM_MCSEL_OSC0 for Osc0, AVR32_PM_MCSEL_PLL0 for PLL0.
322
 */
323
extern void pm_switch_to_clock(volatile avr32_pm_t *pm, unsigned long clock);
324
 
325
 
326
/*!
327
 * \brief Switch main clock to clock Osc0 (crystal mode)
328
 * \param pm Base address of the Power Manager (i.e. &AVR32_PM)
329
 * \param fosc0 Oscillator 0 crystal frequency (Hz)
330
 * \param startup Crystal 0 startup time. Time is expressed in term of RCOsc periods (3-bit value)
331
 */
332
extern void pm_switch_to_osc0(volatile avr32_pm_t *pm, unsigned int fosc0, unsigned int startup);
333
 
334
 
335
#endif  // _PM_H_

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.