]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/mbed/api/rtc_time.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / mbed / api / rtc_time.h
1 /* mbed Microcontroller Library
2 * Copyright (c) 2006-2013 ARM Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <time.h>
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 /** Implementation of the C time.h functions
24 *
25 * Provides mechanisms to set and read the current time, based
26 * on the microcontroller Real-Time Clock (RTC), plus some
27 * standard C manipulation and formating functions.
28 *
29 * Example:
30 * @code
31 * #include "mbed.h"
32 *
33 * int main() {
34 * set_time(1256729737); // Set RTC time to Wed, 28 Oct 2009 11:35:37
35 *
36 * while(1) {
37 * time_t seconds = time(NULL);
38 *
39 * printf("Time as seconds since January 1, 1970 = %d\n", seconds);
40 *
41 * printf("Time as a basic string = %s", ctime(&seconds));
42 *
43 * char buffer[32];
44 * strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
45 * printf("Time as a custom formatted string = %s", buffer);
46 *
47 * wait(1);
48 * }
49 * }
50 * @endcode
51 */
52
53 /** Set the current time
54 *
55 * Initialises and sets the time of the microcontroller Real-Time Clock (RTC)
56 * to the time represented by the number of seconds since January 1, 1970
57 * (the UNIX timestamp).
58 *
59 * @param t Number of seconds since January 1, 1970 (the UNIX timestamp)
60 *
61 * Example:
62 * @code
63 * #include "mbed.h"
64 *
65 * int main() {
66 * set_time(1256729737); // Set time to Wed, 28 Oct 2009 11:35:37
67 * }
68 * @endcode
69 */
70 void set_time(time_t t);
71
72 /** Attach an external RTC to be used for the C time functions
73 *
74 * Do not call this function from an interrupt while an RTC read/write operation may be occurring
75 *
76 * @param read_rtc pointer to function which returns current UNIX timestamp
77 * @param write_rtc pointer to function which sets current UNIX timestamp, can be NULL
78 * @param init_rtc pointer to funtion which initializes RTC, can be NULL
79 * @param isenabled_rtc pointer to function wich returns if the rtc is enabled, can be NULL
80 */
81 void attach_rtc(time_t (*read_rtc)(void), void (*write_rtc)(time_t), void (*init_rtc)(void), int (*isenabled_rtc)(void));
82
83 #ifdef __cplusplus
84 }
85 #endif
Imprint / Impressum