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