µracoli Manual Version foo

- µracoli
- User Guide
- Reference Guide

rtc.h
1 /* Copyright (c) 2014, Daniel Thiele
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
7
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of the authors nor the names of its contributors
14 may be used to endorse or promote products derived from this software
15 without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE. */
28
29 #ifndef RTC_H
30 #define RTC_H
31
37 /* === includes ============================================================ */
38
39 /* === macros ============================================================== */
40
41 /* the following macros are defined by avr-gcc
42 *
43 * order is important because __AVR_MEGA__ is also defined on Xmega devices
44 */
45 #if defined(__AVR_XMEGA__)
46 #define RTC_AVR_XMEGA
47 #elif defined(__AVR_MEGA__)
48 #define RTC_AVR_MEGA
49 #else
50 #error "MCU class not defined, dont know what to do"
51 #endif
52
53 /* setup macros to end up with a tick of 1 second */
54 #if defined(RTC_AVR_MEGA)
55 #define RTC_PRESCALER (256)
56 #define RTC_PRESCALER_BITS (6)
57 #define RTC_HWTICK_NB (128)
58 #elif defined(RTC_AVR_MEGA_WATCHDOG)
59 /* empty */
60 #elif defined(RTC_AVR_XMEGA)
61 /* empty */
62 #else
63 /* empty */
64 #endif /* defined(RTC_MEGA_AVR) */
65
66 /* === types =============================================================== */
67
68 /* === prototypes ========================================================== */
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72
78 void rtc_init(void (*tickfunc)(void));
79
83 void rtc_start(void);
84
88 void rtc_stop(void);
89
90 #ifdef __cplusplus
91 } /* extern "C" */
92 #endif
93
94 #endif /* #ifndef RTC_H */
rtc_init
void rtc_init(void(*tickfunc)(void))
rtc_start
void rtc_start(void)
rtc_stop
void rtc_stop(void)