Gleb Klochkov / Mbed OS Climatcontroll_Main

Dependencies:   esp8266-driver

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_rtc_time.h Source File

mbed_rtc_time.h

00001 
00002 /** \addtogroup platform */
00003 /** @{*/
00004 /**
00005  * \defgroup platform_rtc_time rtc_time functions
00006  * @{
00007  */
00008 /* mbed Microcontroller Library
00009  * Copyright (c) 2006-2013 ARM Limited
00010  *
00011  * Licensed under the Apache License, Version 2.0 (the "License");
00012  * you may not use this file except in compliance with the License.
00013  * You may obtain a copy of the License at
00014  *
00015  *     http://www.apache.org/licenses/LICENSE-2.0
00016  *
00017  * Unless required by applicable law or agreed to in writing, software
00018  * distributed under the License is distributed on an "AS IS" BASIS,
00019  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020  * See the License for the specific language governing permissions and
00021  * limitations under the License.
00022  */
00023 
00024 #include <time.h>
00025 
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029 
00030 /** Implementation of the C time.h functions
00031  *
00032  * Provides mechanisms to set and read the current time, based
00033  * on the microcontroller Real-Time Clock (RTC), plus some
00034  * standard C manipulation and formating functions.
00035  *
00036  * Example:
00037  * @code
00038  * #include "mbed.h"
00039  *
00040  * int main() {
00041  *     set_time(1256729737);  // Set RTC time to Wed, 28 Oct 2009 11:35:37
00042  *
00043  *     while(1) {
00044  *         time_t seconds = time(NULL);
00045  *
00046  *         printf("Time as seconds since January 1, 1970 = %d\n", seconds);
00047  *
00048  *         printf("Time as a basic string = %s", ctime(&seconds));
00049  *
00050  *         char buffer[32];
00051  *         strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
00052  *         printf("Time as a custom formatted string = %s", buffer);
00053  *
00054  *         wait(1);
00055  *     }
00056  * }
00057  * @endcode
00058  */
00059 
00060 /** Set the current time
00061  *
00062  * Initialises and sets the time of the microcontroller Real-Time Clock (RTC)
00063  * to the time represented by the number of seconds since January 1, 1970
00064  * (the UNIX timestamp).
00065  *
00066  * @param t Number of seconds since January 1, 1970 (the UNIX timestamp)
00067  *
00068  * @note Synchronization level: Thread safe
00069  *
00070  * Example:
00071  * @code
00072  * #include "mbed.h"
00073  *
00074  * int main() {
00075  *     set_time(1256729737); // Set time to Wed, 28 Oct 2009 11:35:37
00076  * }
00077  * @endcode
00078  */
00079 void set_time(time_t t);
00080 
00081 /** Attach an external RTC to be used for the C time functions
00082  *
00083  * @note Synchronization level: Thread safe
00084  *
00085  * @param read_rtc pointer to function which returns current UNIX timestamp
00086  * @param write_rtc pointer to function which sets current UNIX timestamp, can be NULL
00087  * @param init_rtc pointer to funtion which initializes RTC, can be NULL
00088  * @param isenabled_rtc pointer to function wich returns if the rtc is enabled, can be NULL
00089  */
00090 void attach_rtc(time_t (*read_rtc)(void), void (*write_rtc)(time_t), void (*init_rtc)(void), int (*isenabled_rtc)(void));
00091 
00092 #ifdef __cplusplus
00093 }
00094 #endif
00095 
00096 /** @}*/
00097 /** @}*/