mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

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