source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/hardware/arduino/avr/firmwares/wifishield/wifiHD/src/SOFTWARE_FRAMEWORK/DRIVERS/RTC/rtc.h @ 4837

Last change on this file since 4837 was 4837, checked in by daduve, 2 years ago

Adding new version

File size: 6.6 KB
Line 
1/* This header file is part of the ATMEL AVR-UC3-SoftwareFramework-1.7.0 Release */
2
3/*This file is prepared for Doxygen automatic documentation generation.*/
4/*! \file *********************************************************************
5 *
6 * \brief RTC driver for AVR32 UC3.
7 *
8 * AVR32 Real Time Counter driver module.
9 *
10 * - Compiler:           GNU GCC for AVR32
11 * - Supported devices:  All AVR32 devices with an RTC and a PM module can be used.
12 * - AppNote:
13 *
14 * \author               Atmel Corporation: http://www.atmel.com \n
15 *                       Support and FAQ: http://support.atmel.no/
16 *
17 ******************************************************************************/
18
19/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
20 *
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions are met:
23 *
24 * 1. Redistributions of source code must retain the above copyright notice, this
25 * list of conditions and the following disclaimer.
26 *
27 * 2. Redistributions in binary form must reproduce the above copyright notice,
28 * this list of conditions and the following disclaimer in the documentation
29 * and/or other materials provided with the distribution.
30 *
31 * 3. The name of Atmel may not be used to endorse or promote products derived
32 * from this software without specific prior written permission.
33 *
34 * 4. This software may only be redistributed and used in connection with an Atmel
35 * AVR product.
36 *
37 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
38 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
39 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
40 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
41 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
42 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
45 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
46 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
47 *
48 */
49
50#ifndef _RTC_H_
51#define _RTC_H_
52
53#include "compiler.h"
54#include <avr32/io.h>
55
56
57/*! \name Oscillator Types
58 */
59//! @{
60#define RTC_OSC_32KHZ    1
61#define RTC_OSC_RC       0
62//! @}
63
64/*! \name Predefined PSEL Values
65 */
66//! @{
67
68//! The PSEL value to set the RTC source clock (after the prescaler) to 1 Hz,
69//! when using an external 32-kHz crystal.
70#define RTC_PSEL_32KHZ_1HZ    14
71
72//! The PSEL value to set the RTC source clock (after the prescaler) to 1.76 Hz,
73//! when using the internal RC oscillator (~ 115 kHz).
74#define RTC_PSEL_RC_1_76HZ    15
75
76//! @}
77
78
79/*!
80 * \brief This function will initialise the RTC module.
81 *        If you use the 32 KHz oscillator, it will enable this module.
82 *        This function also set the top value of the RTC to 0xFFFFFFFF
83 *        and the value to 0.
84 * \param rtc Base address of the RTC (i.e. &AVR32_RTC).
85 * \param osc_type The oscillator you want to use. If you need a better
86 *        accuracy, use the 32 KHz oscillator (i.e. RTC_OSC_32KHZ).
87 * \param psel The preselector value for the corresponding oscillator (4-bits).
88 *        To obtain this value, you can use this formula:
89 *        psel = log(Fosc/Frtc)/log(2)-1, where Fosc is the frequency of the
90 *        oscillator you are using (32 KHz or 115 KHz) and Frtc the frequency
91 *        desired.
92 * \return 1 if the initialisation succeds otherwize it will return 0.
93 */
94extern int rtc_init(volatile avr32_rtc_t *rtc, unsigned char osc_type, unsigned char psel);
95
96/*!
97 * \brief Enable the RTC.
98 * \param rtc Base address of the RTC (i.e. &AVR32_RTC).
99 */
100extern void rtc_enable(volatile avr32_rtc_t *rtc);
101
102/*!
103 * \brief Disable the RTC.
104 * \param rtc Base address of the RTC (i.e. &AVR32_RTC).
105 */
106extern void rtc_disable(volatile avr32_rtc_t *rtc);
107
108/*!
109 * \brief Enable the wake up feature of the RTC.
110 * \param rtc Base address of the RTC (i.e. &AVR32_RTC).
111 */
112extern void rtc_enable_wake_up(volatile avr32_rtc_t *rtc);
113
114/*!
115 * \brief Disable the wake up feature of the RTC.
116 * \param rtc Base address of the RTC (i.e. &AVR32_RTC).
117 */
118extern void rtc_disable_wake_up(volatile avr32_rtc_t *rtc);
119
120/*!
121 * \brief Enable the interrupt feature of the RTC.
122 *        An interrupt is raised when the value of the RTC
123 *        is equal to its top value.
124 * \param rtc Base address of the RTC (i.e. &AVR32_RTC).
125 */
126extern void rtc_enable_interrupt(volatile avr32_rtc_t *rtc);
127
128/*!
129 * \brief Disable the interrupt feature of the RTC.
130 * \param rtc Base address of the RTC (i.e. &AVR32_RTC).
131 */
132extern void rtc_disable_interrupt(volatile avr32_rtc_t *rtc);
133
134/*!
135 * \brief Clear the interrupt flag.
136 *        Call this function once you handled the interrupt.
137 * \param rtc Base address of the RTC (i.e. &AVR32_RTC).
138 */
139extern void rtc_clear_interrupt(volatile avr32_rtc_t *rtc);
140
141/*!
142 * \brief Get the status of interrupts.
143 * \param rtc Base address of the RTC (i.e. &AVR32_RTC).
144 * \return 1 if the interrupts are enabled otherwize it returns 0.
145 */
146extern int rtc_interrupt_enabled(volatile avr32_rtc_t *rtc);
147
148/*!
149 * \brief Check if an interrupt is raised.
150 * \param rtc Base address of the RTC (i.e. &AVR32_RTC).
151 * \return 1 if an interrupt is currently raised otherwize it returns 0.
152 */
153extern int rtc_is_interrupt(volatile avr32_rtc_t *rtc);
154
155/*!
156 * \brief This function sets the RTC current top value.
157 * \param rtc Base address of the RTC (i.e. &AVR32_RTC).
158 * \param top The top value you want to store.
159 */
160extern void rtc_set_top_value(volatile avr32_rtc_t *rtc, unsigned long top);
161
162/*!
163 * \brief This function returns the RTC current top value.
164 * \param rtc Base address of the RTC (i.e. &AVR32_RTC).
165 * \return The RTC current top value.
166 */
167extern unsigned long rtc_get_top_value(volatile avr32_rtc_t *rtc);
168
169/*!
170 * \brief This function checks if the RTC is busy or not.
171 * \param rtc Base address of the RTC (i.e. &AVR32_RTC).
172 * \return 1 if the RTC is busy otherwize it will return 0.
173 */
174extern int rtc_is_busy(volatile avr32_rtc_t *rtc);
175
176/*!
177 * \brief This function sets the RTC current value.
178 * \param rtc Base address of the RTC (i.e. &AVR32_RTC).
179 * \param val The value you want to store.
180 */
181extern void rtc_set_value(volatile avr32_rtc_t *rtc, unsigned long val);
182
183/*!
184 * \brief This function returns the RTC current value.
185 * \param rtc Base address of the RTC (i.e. &AVR32_RTC).
186 * \return The RTC current value.
187 */
188extern unsigned long rtc_get_value(volatile avr32_rtc_t *rtc);
189
190
191#endif  // _RTC_H_
Note: See TracBrowser for help on using the repository browser.